Rename PopenResult.stdout to output since it also contains stderr

This commit is contained in:
Daniel Martí 2014-07-01 18:04:41 +02:00
parent 22f4ed4b7a
commit 8888962ace
6 changed files with 41 additions and 41 deletions

View file

@ -84,7 +84,7 @@ def vagrant(params, cwd=None, printout=False):
is the stdout (and stderr) from vagrant is the stdout (and stderr) from vagrant
""" """
p = FDroidPopen(['vagrant'] + params, cwd=cwd) p = FDroidPopen(['vagrant'] + params, cwd=cwd)
return (p.returncode, p.stdout) return (p.returncode, p.output)
def get_vagrant_sshinfo(): def get_vagrant_sshinfo():
@ -136,7 +136,7 @@ def get_clean_vm(reset=False):
p = FDroidPopen(['VBoxManage', 'snapshot', p = FDroidPopen(['VBoxManage', 'snapshot',
get_builder_vm_id(), 'list', get_builder_vm_id(), 'list',
'--details'], cwd='builder') '--details'], cwd='builder')
if 'fdroidclean' in p.stdout: if 'fdroidclean' in p.output:
logging.info("...snapshot exists - resetting build server to " logging.info("...snapshot exists - resetting build server to "
"clean state") "clean state")
retcode, output = vagrant(['status'], cwd='builder') retcode, output = vagrant(['status'], cwd='builder')
@ -163,7 +163,7 @@ def get_clean_vm(reset=False):
logging.info("...failed to reset to snapshot") logging.info("...failed to reset to snapshot")
else: else:
logging.info("...snapshot doesn't exist - " logging.info("...snapshot doesn't exist - "
"VBoxManage snapshot list:\n" + p.stdout) "VBoxManage snapshot list:\n" + p.output)
# If we can't use the existing machine for any reason, make a # If we can't use the existing machine for any reason, make a
# new one from scratch. # new one from scratch.
@ -227,7 +227,7 @@ def get_clean_vm(reset=False):
p = FDroidPopen(['VBoxManage', 'snapshot', get_builder_vm_id(), p = FDroidPopen(['VBoxManage', 'snapshot', get_builder_vm_id(),
'list', '--details'], 'list', '--details'],
cwd='builder') cwd='builder')
if 'fdroidclean' not in p.stdout: if 'fdroidclean' not in p.output:
raise BuildException("Failed to take snapshot.") raise BuildException("Failed to take snapshot.")
return sshinfo return sshinfo
@ -494,7 +494,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
if p is not None and p.returncode != 0: if p is not None and p.returncode != 0:
raise BuildException("Error cleaning %s:%s" % raise BuildException("Error cleaning %s:%s" %
(app['id'], thisbuild['version']), p.stdout) (app['id'], thisbuild['version']), p.output)
logging.info("Getting rid of Gradle wrapper binaries...") logging.info("Getting rid of Gradle wrapper binaries...")
for root, dirs, files in os.walk(build_dir): for root, dirs, files in os.walk(build_dir):
@ -560,7 +560,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
if p.returncode != 0: if p.returncode != 0:
raise BuildException("Error running build command for %s:%s" % raise BuildException("Error running build command for %s:%s" %
(app['id'], thisbuild['version']), p.stdout) (app['id'], thisbuild['version']), p.output)
# Build native stuff if required... # Build native stuff if required...
if thisbuild['buildjni'] and thisbuild['buildjni'] != ['no']: if thisbuild['buildjni'] and thisbuild['buildjni'] != ['no']:
@ -588,7 +588,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
del manifest_text del manifest_text
p = FDroidPopen(cmd, cwd=os.path.join(root_dir, d)) p = FDroidPopen(cmd, cwd=os.path.join(root_dir, d))
if p.returncode != 0: if p.returncode != 0:
raise BuildException("NDK build failed for %s:%s" % (app['id'], thisbuild['version']), p.stdout) raise BuildException("NDK build failed for %s:%s" % (app['id'], thisbuild['version']), p.output)
p = None p = None
# Build the release... # Build the release...
@ -725,12 +725,12 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
bindir = os.path.join(root_dir, 'bin') bindir = os.path.join(root_dir, 'bin')
if p is not None and p.returncode != 0: if p is not None and p.returncode != 0:
raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), p.stdout) raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), p.output)
logging.info("Successfully built version " + thisbuild['version'] + ' of ' + app['id']) logging.info("Successfully built version " + thisbuild['version'] + ' of ' + app['id'])
if thisbuild['type'] == 'maven': if thisbuild['type'] == 'maven':
stdout_apk = '\n'.join([ stdout_apk = '\n'.join([
line for line in p.stdout.splitlines() if any(a in line for a in ('.apk', '.ap_'))]) line for line in p.output.splitlines() if any(a in line for a in ('.apk', '.ap_'))])
m = re.match(r".*^\[INFO\] .*apkbuilder.*/([^/]*)\.apk", m = re.match(r".*^\[INFO\] .*apkbuilder.*/([^/]*)\.apk",
stdout_apk, re.S | re.M) stdout_apk, re.S | re.M)
if not m: if not m:
@ -766,7 +766,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
src = os.path.join(dd, 'build', 'apk', name + '.apk') src = os.path.join(dd, 'build', 'apk', name + '.apk')
elif thisbuild['type'] == 'ant': elif thisbuild['type'] == 'ant':
stdout_apk = '\n'.join([ stdout_apk = '\n'.join([
line for line in p.stdout.splitlines() if '.apk' in line]) line for line in p.output.splitlines() if '.apk' in line])
src = re.match(r".*^.*Creating (.+) for release.*$.*", stdout_apk, src = re.match(r".*^.*Creating (.+) for release.*$.*", stdout_apk,
re.S | re.M).group(1) re.S | re.M).group(1)
src = os.path.join(bindir, src) src = os.path.join(bindir, src)
@ -792,7 +792,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
version = None version = None
foundid = None foundid = None
nativecode = None nativecode = None
for line in p.stdout.splitlines(): for line in p.output.splitlines():
if line.startswith("package:"): if line.startswith("package:"):
pat = re.compile(".*name='([a-zA-Z0-9._]*)'.*") pat = re.compile(".*name='([a-zA-Z0-9._]*)'.*")
m = pat.match(line) m = pat.match(line)

View file

@ -414,7 +414,7 @@ class vcs_git(vcs):
# a safety check. # a safety check.
def checkrepo(self): def checkrepo(self):
p = SilentPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local) p = SilentPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local)
result = p.stdout.rstrip() result = p.output.rstrip()
if not result.endswith(self.local): if not result.endswith(self.local):
raise VCSException('Repository mismatch') raise VCSException('Repository mismatch')
@ -492,7 +492,7 @@ class vcs_git(vcs):
def gettags(self): def gettags(self):
self.checkrepo() self.checkrepo()
p = SilentPopen(['git', 'tag'], cwd=self.local) p = SilentPopen(['git', 'tag'], cwd=self.local)
return p.stdout.splitlines() return p.output.splitlines()
def latesttags(self, alltags, number): def latesttags(self, alltags, number):
self.checkrepo() self.checkrepo()
@ -500,7 +500,7 @@ class vcs_git(vcs):
+ 'xargs -I@ git log --format=format:"%at @%n" -1 @ | ' + 'xargs -I@ git log --format=format:"%at @%n" -1 @ | '
+ 'sort -n | awk \'{print $2}\''], + 'sort -n | awk \'{print $2}\''],
cwd=self.local, shell=True) cwd=self.local, shell=True)
return p.stdout.splitlines()[-number:] return p.output.splitlines()[-number:]
class vcs_gitsvn(vcs): class vcs_gitsvn(vcs):
@ -521,7 +521,7 @@ class vcs_gitsvn(vcs):
# a safety check. # a safety check.
def checkrepo(self): def checkrepo(self):
p = SilentPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local) p = SilentPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local)
result = p.stdout.rstrip() result = p.output.rstrip()
if not result.endswith(self.local): if not result.endswith(self.local):
raise VCSException('Repository mismatch') raise VCSException('Repository mismatch')
@ -587,7 +587,7 @@ class vcs_gitsvn(vcs):
svn_rev = rev svn_rev = rev
p = SilentPopen(['git', 'svn', 'find-rev', 'r' + svn_rev, treeish], cwd=self.local) p = SilentPopen(['git', 'svn', 'find-rev', 'r' + svn_rev, treeish], cwd=self.local)
git_rev = p.stdout.rstrip() git_rev = p.output.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
@ -614,7 +614,7 @@ class vcs_gitsvn(vcs):
p = SilentPopen(['git', 'svn', 'find-rev', 'HEAD'], cwd=self.local) p = SilentPopen(['git', 'svn', 'find-rev', 'HEAD'], cwd=self.local)
if p.returncode != 0: if p.returncode != 0:
return None return None
return p.stdout.strip() return p.output.strip()
class vcs_svn(vcs): class vcs_svn(vcs):
@ -654,7 +654,7 @@ class vcs_svn(vcs):
def getref(self): def getref(self):
p = SilentPopen(['svn', 'info'], cwd=self.local) p = SilentPopen(['svn', 'info'], cwd=self.local)
for line in p.stdout.splitlines(): for line in p.output.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 return None
@ -688,7 +688,7 @@ class vcs_hg(vcs):
raise VCSException("Hg checkout of '%s' failed" % rev) raise VCSException("Hg checkout of '%s' failed" % rev)
p = SilentPopen(['hg', 'purge', '--all'], cwd=self.local) p = SilentPopen(['hg', 'purge', '--all'], cwd=self.local)
# Also delete untracked files, we have to enable purge extension for that: # Also delete untracked files, we have to enable purge extension for that:
if "'purge' is provided by the following extension" in p.stdout: if "'purge' is provided by the following extension" in p.output:
with open(self.local + "/.hg/hgrc", "a") as myfile: with open(self.local + "/.hg/hgrc", "a") as myfile:
myfile.write("\n[extensions]\nhgext.purge=\n") myfile.write("\n[extensions]\nhgext.purge=\n")
p = SilentPopen(['hg', 'purge', '--all'], cwd=self.local) p = SilentPopen(['hg', 'purge', '--all'], cwd=self.local)
@ -699,7 +699,7 @@ class vcs_hg(vcs):
def gettags(self): def gettags(self):
p = SilentPopen(['hg', 'tags', '-q'], cwd=self.local) p = SilentPopen(['hg', 'tags', '-q'], cwd=self.local)
return p.stdout.splitlines()[1:] return p.output.splitlines()[1:]
class vcs_bzr(vcs): class vcs_bzr(vcs):
@ -730,7 +730,7 @@ class vcs_bzr(vcs):
def gettags(self): def gettags(self):
p = SilentPopen(['bzr', 'tags'], cwd=self.local) p = SilentPopen(['bzr', 'tags'], cwd=self.local)
return [tag.split(' ')[0].strip() for tag in return [tag.split(' ')[0].strip() for tag in
p.stdout.splitlines()] p.output.splitlines()]
def retrieve_string(app_dir, string, xmlfiles=None): def retrieve_string(app_dir, string, xmlfiles=None):
@ -1036,7 +1036,7 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None,
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=libdir) p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=libdir)
if p.returncode != 0: if p.returncode != 0:
raise BuildException("Error running prepare command for srclib %s" raise BuildException("Error running prepare command for srclib %s"
% name, p.stdout) % name, p.output)
if basepath: if basepath:
libdir = sdir libdir = sdir
@ -1088,7 +1088,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir) p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
if p.returncode != 0: if p.returncode != 0:
raise BuildException("Error running init command for %s:%s" % raise BuildException("Error running init command for %s:%s" %
(app['id'], build['version']), p.stdout) (app['id'], build['version']), p.output)
# Apply patches if any # Apply patches if any
if build['patch']: if build['patch']:
@ -1292,7 +1292,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir) p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
if p.returncode != 0: if p.returncode != 0:
raise BuildException("Error running prebuild command for %s:%s" % raise BuildException("Error running prebuild command for %s:%s" %
(app['id'], build['version']), p.stdout) (app['id'], build['version']), p.output)
# Generate (or update) the ant build file, build.xml... # Generate (or update) the ant build file, build.xml...
if build['update'] and build['update'] != ['no'] and build['type'] == 'ant': if build['update'] and build['update'] != ['no'] and build['type'] == 'ant':
@ -1320,8 +1320,8 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
# Check to see whether an error was returned without a proper exit # Check to see whether an error was returned without a proper exit
# code (this is the case for the 'no target set or target invalid' # code (this is the case for the 'no target set or target invalid'
# error) # error)
if p.returncode != 0 or p.stdout.startswith("Error: "): if p.returncode != 0 or p.output.startswith("Error: "):
raise BuildException("Failed to update project at %s" % d, p.stdout) raise BuildException("Failed to update project at %s" % d, p.output)
# Clean update dirs via ant # Clean update dirs via ant
if d != '.': if d != '.':
logging.info("Cleaning subproject %s" % d) logging.info("Cleaning subproject %s" % d)
@ -1553,7 +1553,7 @@ def isApkDebuggable(apkfile, config):
if p.returncode != 0: if p.returncode != 0:
logging.critical("Failed to get apk manifest information") logging.critical("Failed to get apk manifest information")
sys.exit(1) sys.exit(1)
for line in p.stdout.splitlines(): for line in p.output.splitlines():
if 'android:debuggable' in line and not line.endswith('0x0'): if 'android:debuggable' in line and not line.endswith('0x0'):
return True return True
return False return False
@ -1585,7 +1585,7 @@ class AsynchronousFileReader(threading.Thread):
class PopenResult: class PopenResult:
returncode = None returncode = None
stdout = '' output = ''
def SilentPopen(commands, cwd=None, shell=False): def SilentPopen(commands, cwd=None, shell=False):
@ -1622,7 +1622,7 @@ def FDroidPopen(commands, cwd=None, shell=False, output=True):
# Output directly to console # Output directly to console
sys.stdout.write(line) sys.stdout.write(line)
sys.stdout.flush() sys.stdout.flush()
result.stdout += line result.output += line
time.sleep(0.1) time.sleep(0.1)

View file

@ -81,12 +81,12 @@ def genkey(keystore, repo_keyalias, password, keydname):
'-dname', keydname]) '-dname', keydname])
# TODO keypass should be sent via stdin # TODO keypass should be sent via stdin
if p.returncode != 0: if p.returncode != 0:
raise BuildException("Failed to generate key", p.stdout) raise BuildException("Failed to generate key", p.output)
# now show the lovely key that was just generated # now show the lovely key that was just generated
p = FDroidPopen(['keytool', '-list', '-v', p = FDroidPopen(['keytool', '-list', '-v',
'-keystore', keystore, '-alias', repo_keyalias, '-keystore', keystore, '-alias', repo_keyalias,
'-storepass:file', config['keystorepassfile']]) '-storepass:file', config['keystorepassfile']])
logging.info(p.stdout.strip() + '\n\n') logging.info(p.output.strip() + '\n\n')
def main(): def main():

View file

@ -34,8 +34,8 @@ config = None
def devices(): def devices():
p = FDroidPopen(["adb", "devices"]) p = FDroidPopen(["adb", "devices"])
if p.returncode != 0: if p.returncode != 0:
raise Exception("An error occured when finding devices: %s" % p.stdout) raise Exception("An error occured when finding devices: %s" % p.output)
lines = p.stdout.splitlines() lines = p.output.splitlines()
if lines[0].startswith('* daemon not running'): if lines[0].startswith('* daemon not running'):
lines = lines[2:] lines = lines[2:]
if len(lines) < 3: if len(lines) < 3:
@ -102,7 +102,7 @@ def main():
logging.info("Installing %s on %s..." % (apk, dev)) logging.info("Installing %s on %s..." % (apk, dev))
p = FDroidPopen(["adb", "-s", dev, "install", apk]) p = FDroidPopen(["adb", "-s", dev, "install", apk])
fail = "" fail = ""
for line in p.stdout.splitlines(): for line in p.output.splitlines():
if line.startswith("Failure"): if line.startswith("Failure"):
fail = line[9:-1] fail = line[9:-1]
if not fail: if not fail:

View file

@ -387,7 +387,7 @@ def scan_apks(apps, apkcache, repodir, knownapks):
else: else:
logging.error("Failed to get apk information, skipping " + apkfile) logging.error("Failed to get apk information, skipping " + apkfile)
continue continue
for line in p.stdout.splitlines(): for line in p.output.splitlines():
if line.startswith("package:"): if line.startswith("package:"):
try: try:
thisinfo['id'] = re.match(name_pat, line).group(1) thisinfo['id'] = re.match(name_pat, line).group(1)
@ -470,10 +470,10 @@ def scan_apks(apps, apkcache, repodir, knownapks):
sys.exit(1) sys.exit(1)
p = FDroidPopen(['java', '-cp', os.path.join(os.path.dirname(__file__), 'getsig'), p = FDroidPopen(['java', '-cp', os.path.join(os.path.dirname(__file__), 'getsig'),
'getsig', os.path.join(os.getcwd(), apkfile)]) 'getsig', os.path.join(os.getcwd(), apkfile)])
if p.returncode != 0 or not p.stdout.startswith('Result:'): if p.returncode != 0 or not p.output.startswith('Result:'):
logging.critical("Failed to get apk signature") logging.critical("Failed to get apk signature")
sys.exit(1) sys.exit(1)
thisinfo['sig'] = p.stdout[7:].strip() thisinfo['sig'] = p.output[7:].strip()
apk = zipfile.ZipFile(apkfile, 'r') apk = zipfile.ZipFile(apkfile, 'r')
@ -672,8 +672,8 @@ def make_index(apps, apks, repodir, archive, categories):
logging.critical(msg) logging.critical(msg)
sys.exit(1) sys.exit(1)
global repo_pubkey_fingerprint global repo_pubkey_fingerprint
repo_pubkey_fingerprint = cert_fingerprint(p.stdout) repo_pubkey_fingerprint = cert_fingerprint(p.output)
return "".join("%02x" % ord(b) for b in p.stdout) return "".join("%02x" % ord(b) for b in p.output)
repoel.setAttribute("pubkey", extract_pubkey()) repoel.setAttribute("pubkey", extract_pubkey())

View file

@ -101,9 +101,9 @@ def main():
raise Exception("Failed to unpack remote build of " + apkfilename) raise Exception("Failed to unpack remote build of " + apkfilename)
p = FDroidPopen(['diff', '-r', 'this_apk', 'that_apk'], cwd=tmp_dir) p = FDroidPopen(['diff', '-r', 'this_apk', 'that_apk'], cwd=tmp_dir)
lines = p.stdout.splitlines() lines = p.output.splitlines()
if len(lines) != 1 or 'META-INF' not in lines[0]: if len(lines) != 1 or 'META-INF' not in lines[0]:
raise Exception("Unexpected diff output - " + p.stdout) raise Exception("Unexpected diff output - " + p.output)
logging.info("...successfully verified") logging.info("...successfully verified")
verified += 1 verified += 1