More switching from Popen to FDroidPopen

This commit is contained in:
Daniel Martí 2014-01-27 16:07:30 +01:00
parent 7967cfa6a6
commit 9bc8dc95ff

View file

@ -296,9 +296,8 @@ class vcs_git(vcs):
# fdroidserver) and then we'll proceed to destroy it! This is called as # fdroidserver) and then we'll proceed to destroy it! This is called as
# a safety check. # a safety check.
def checkrepo(self): def checkrepo(self):
p = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'], p = FDroidPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local)
stdout=subprocess.PIPE, cwd=self.local) result = p.stdout.rstrip()
result = p.communicate()[0].rstrip()
if not result.endswith(self.local): if not result.endswith(self.local):
raise VCSException('Repository mismatch') raise VCSException('Repository mismatch')
@ -353,9 +352,8 @@ class vcs_git(vcs):
def gettags(self): def gettags(self):
self.checkrepo() self.checkrepo()
p = subprocess.Popen(['git', 'tag'], p = FDroidPopen(['git', 'tag'], cwd=self.local)
stdout=subprocess.PIPE, cwd=self.local) return p.stdout.splitlines()
return p.communicate()[0].splitlines()
class vcs_gitsvn(vcs): class vcs_gitsvn(vcs):
@ -375,9 +373,8 @@ class vcs_gitsvn(vcs):
# fdroidserver) and then we'll proceed to destory it! This is called as # fdroidserver) and then we'll proceed to destory it! This is called as
# a safety check. # a safety check.
def checkrepo(self): def checkrepo(self):
p = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'], p = FDroidPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local)
stdout=subprocess.PIPE, cwd=self.local) result = p.stdout.rstrip()
result = p.communicate()[0].rstrip()
if not result.endswith(self.local): if not result.endswith(self.local):
raise VCSException('Repository mismatch') raise VCSException('Repository mismatch')
@ -422,12 +419,8 @@ class vcs_gitsvn(vcs):
if rev: if rev:
nospaces_rev = rev.replace(' ', '%20') nospaces_rev = rev.replace(' ', '%20')
# Try finding a svn tag # Try finding a svn tag
p = subprocess.Popen(['git', 'checkout', 'tags/' + nospaces_rev], p = FDroidPopen(['git', 'checkout', 'tags/' + nospaces_rev], cwd=self.local)
cwd=self.local, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if p.returncode != 0:
out, err = p.communicate()
if p.returncode == 0:
print out
else:
# No tag found, normal svn rev translation # No tag found, normal svn rev translation
# Translate svn rev into git format # Translate svn rev into git format
rev_split = rev.split('/') rev_split = rev.split('/')
@ -441,27 +434,19 @@ class vcs_gitsvn(vcs):
treeish = 'master' treeish = 'master'
svn_rev = rev svn_rev = rev
p = subprocess.Popen(['git', 'svn', 'find-rev', 'r' + svn_rev, treeish], p = FDroidPopen(['git', 'svn', 'find-rev', 'r' + svn_rev, treeish],
cwd=self.local, stdout=subprocess.PIPE) cwd=self.local)
git_rev = p.communicate()[0].rstrip() git_rev = p.stdout.rstrip()
if p.returncode != 0 or not git_rev: if p.returncode != 0 or not git_rev:
# Try a plain git checkout as a last resort # Try a plain git checkout as a last resort
p = subprocess.Popen(['git', 'checkout', rev], cwd=self.local, p = subprocess.Popen(['git', 'checkout', rev], cwd=self.local)
stdout=subprocess.PIPE, stderr=subprocess.PIPE) if p.returncode != 0:
out, err = p.communicate()
if p.returncode == 0:
print out
else:
raise VCSException("No git treeish found and direct git checkout failed") raise VCSException("No git treeish found and direct git checkout failed")
else: else:
# Check out the git rev equivalent to the svn rev # Check out the git rev equivalent to the svn rev
p = subprocess.Popen(['git', 'checkout', git_rev], cwd=self.local, p = FDroidPopen(['git', 'checkout', git_rev], cwd=self.local)
stdout=subprocess.PIPE, stderr=subprocess.PIPE) if p.returncode != 0:
out, err = p.communicate()
if p.returncode == 0:
print out
else:
raise VCSException("Git svn checkout failed") raise VCSException("Git svn checkout failed")
# Get rid of any uncontrolled files left behind # Get rid of any uncontrolled files left behind
@ -474,9 +459,10 @@ class vcs_gitsvn(vcs):
def getref(self): def getref(self):
self.checkrepo() self.checkrepo()
p = subprocess.Popen(['git', 'svn', 'find-rev', 'HEAD'], p = FDroidPopen(['git', 'svn', 'find-rev', 'HEAD'], cwd=self.local)
stdout=subprocess.PIPE, cwd=self.local) if p.returncode != 0:
return p.communicate()[0].strip() return None
return p.stdout.strip()
class vcs_svn(vcs): class vcs_svn(vcs):
@ -513,11 +499,11 @@ class vcs_svn(vcs):
raise VCSException("Svn update failed") raise VCSException("Svn update failed")
def getref(self): def getref(self):
p = subprocess.Popen(['svn', 'info'], p = FDroidPopen(['svn', 'info'], cwd=self.local)
stdout=subprocess.PIPE, cwd=self.local)
for line in p.communicate()[0].splitlines(): for line in p.communicate()[0].splitlines():
if line and line.startswith('Last Changed Rev: '): if line and line.startswith('Last Changed Rev: '):
return line[18:] return line[18:]
return None
class vcs_hg(vcs): class vcs_hg(vcs):