mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-13 02:30:11 +01:00
Make FDroidPopen a lot simpler, pythonize a few things
This commit is contained in:
parent
5cdca44b69
commit
3638edd252
@ -485,7 +485,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||
if 'mvnflags' in thisbuild:
|
||||
mvncmd += thisbuild['mvnflags']
|
||||
|
||||
p = FDroidPopen(mvncmd, cwd=maven_dir, apkoutput=True)
|
||||
p = FDroidPopen(mvncmd, cwd=maven_dir)
|
||||
|
||||
elif 'gradle' in thisbuild:
|
||||
print "Building Gradle project..."
|
||||
@ -537,7 +537,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||
cmd += [thisbuild['antcommand']]
|
||||
else:
|
||||
cmd += ['release']
|
||||
p = FDroidPopen(cmd, cwd=root_dir, apkoutput=True)
|
||||
p = FDroidPopen(cmd, cwd=root_dir)
|
||||
|
||||
if p.returncode != 0:
|
||||
raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), p.stdout, p.stderr)
|
||||
@ -554,15 +554,17 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||
else:
|
||||
bindir = os.path.join(root_dir, 'bin')
|
||||
if 'maven' in thisbuild:
|
||||
stdout_apk = '\n'.join([
|
||||
line for line in p.stdout.splitlines() if 'apk' in line])
|
||||
m = re.match(r".*^\[INFO\] .*apkbuilder.*/([^/]*)\.apk",
|
||||
p.stdout_apk, re.S|re.M)
|
||||
stdout_apk, re.S|re.M)
|
||||
if not m:
|
||||
m = re.match(r".*^\[INFO\] Creating additional unsigned apk file .*/([^/]+)\.apk[^l]",
|
||||
p.stdout_apk, re.S|re.M)
|
||||
stdout_apk, re.S|re.M)
|
||||
if not m:
|
||||
# This format is found in com.github.mobile, com.yubico.yubitotp and com.botbrew.basil for example...
|
||||
m = re.match(r'.*^\[INFO\] [^$]*aapt \[package,[^$]*' + bindir + '/([^/]+)\.ap[_k][,\]]',
|
||||
p.stdout_apk, re.S|re.M)
|
||||
stdout_apk, re.S|re.M)
|
||||
if not m:
|
||||
raise BuildException('Failed to find output')
|
||||
src = m.group(1)
|
||||
@ -577,7 +579,9 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||
name = '-'.join([os.path.basename(dd), flavour, 'release', 'unsigned'])
|
||||
src = os.path.join(dd, 'build', 'apk', name+'.apk')
|
||||
else:
|
||||
src = re.match(r".*^.*Creating (.+) for release.*$.*", p.stdout_apk,
|
||||
stdout_apk = '\n'.join([
|
||||
line for line in p.stdout.splitlines() if 'apk' in line])
|
||||
src = re.match(r".*^.*Creating (.+) for release.*$.*", stdout_apk,
|
||||
re.S|re.M).group(1)
|
||||
src = os.path.join(bindir, src)
|
||||
|
||||
|
@ -1406,9 +1406,8 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path,
|
||||
and build.get('gradle', 'no') == 'no'):
|
||||
parms = [os.path.join(sdk_path, 'tools', 'android'),
|
||||
'update', 'project']
|
||||
if 'target' in build:
|
||||
parms.append('-t')
|
||||
parms.append(build['target'])
|
||||
if 'target' in build and build['target']:
|
||||
parms += ['-t', build['target']]
|
||||
update_dirs = None
|
||||
if updatemode == 'auto':
|
||||
update_dirs = ['.'] + ant_subprojects(root_dir)
|
||||
@ -1859,9 +1858,7 @@ class KnownApks:
|
||||
else:
|
||||
apps[appid] = added
|
||||
sortedapps = sorted(apps.iteritems(), key=operator.itemgetter(1))[-num:]
|
||||
lst = []
|
||||
for app, added in sortedapps:
|
||||
lst.append(app)
|
||||
lst = [app for app,added in sortedapps]
|
||||
lst.reverse()
|
||||
return lst
|
||||
|
||||
@ -1913,13 +1910,11 @@ class PopenResult:
|
||||
stderr = ''
|
||||
stdout_apk = ''
|
||||
|
||||
def FDroidPopen(commands, cwd,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
apkoutput=False):
|
||||
def FDroidPopen(commands, cwd):
|
||||
"""
|
||||
Runs a command the FDroid way and returns return code and output
|
||||
|
||||
:param commands, cwd, stdout, stderr: like subprocess.Popen
|
||||
:param commands, cwd: like subprocess.Popen
|
||||
"""
|
||||
|
||||
if options.verbose:
|
||||
@ -1927,7 +1922,8 @@ def FDroidPopen(commands, cwd,
|
||||
print " > %s" % ' '.join(commands)
|
||||
|
||||
result = PopenResult()
|
||||
p = subprocess.Popen(commands, cwd=cwd, stdout=stdout, stderr=stderr)
|
||||
p = subprocess.Popen(commands, cwd=cwd,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
stdout_queue = Queue.Queue()
|
||||
stdout_reader = AsynchronousFileReader(p.stdout, stdout_queue)
|
||||
@ -1945,8 +1941,6 @@ def FDroidPopen(commands, cwd,
|
||||
# Output directly to console
|
||||
sys.stdout.write(line)
|
||||
sys.stdout.flush()
|
||||
if apkoutput and 'apk' in line:
|
||||
result.stdout_apk += line
|
||||
result.stdout += line
|
||||
|
||||
# Show what we received from standard error
|
||||
|
Loading…
Reference in New Issue
Block a user