Only install latest apk of each app, other fixes

This commit is contained in:
Daniel Martí 2013-12-11 19:08:15 +01:00
parent 93d8d23cee
commit 21db79eea2
3 changed files with 61 additions and 50 deletions

View file

@ -877,6 +877,15 @@ def main():
allapps = metadata.read_metadata(xref=not options.onserver) allapps = metadata.read_metadata(xref=not options.onserver)
apps = common.read_app_args(args, options, allapps) apps = common.read_app_args(args, options, allapps)
apps = [app for app in apps if (options.force or not app['Disabled']) and
len(app['Repo Type']) > 0 and len(app['builds']) > 0]
if len(apps) == 0:
raise Exception("No apps to process.")
if options.latest:
for app in apps:
app['builds'] = app['builds'][-1:]
if options.wiki: if options.wiki:
import mwclient import mwclient

View file

@ -111,36 +111,31 @@ def read_config(opts, config_file='config.py'):
return config return config
def read_app_args(args, options, allapps): def read_app_args(args, options, allapps):
if args: if not args:
vercodes = {} return []
for p in args:
if ':' in p:
package, vercode = p.split(':')
else:
package, vercode = p, None
if package not in vercodes:
vercodes[package] = [vercode] if vercode else []
continue
elif vercode not in vercodes[package]:
vercodes[package] += [vercode] if vercode else []
packages = vercodes.keys()
apps = [app for app in allapps if app['id'] in packages]
if len(apps) != len(packages):
allids = [app["id"] for app in allapps]
for p in packages:
if p not in allids:
print "No such package: %s" % p
raise Exception("Found invalid app ids in arguments")
if hasattr(options, "force"): vercodes = {}
force = options.force for p in args:
else: if ':' in p:
force = False package, vercode = p.split(':')
else:
package, vercode = p, None
if package not in vercodes:
vercodes[package] = [vercode] if vercode else []
continue
elif vercode not in vercodes[package]:
vercodes[package] += [vercode] if vercode else []
packages = vercodes.keys()
apps = [app for app in allapps if app['id'] in packages]
if len(apps) != len(packages):
allids = [app["id"] for app in allapps]
for p in packages:
if p not in allids:
print "No such package: %s" % p
raise Exception("Found invalid app ids in arguments")
apps = [app for app in apps if (force or not app['Disabled']) and if not vercodes:
app['builds'] and len(app['Repo Type']) > 0 and len(app['builds']) > 0] return apps
if len(apps) == 0:
raise Exception("No apps to process.")
error = False error = False
for app in apps: for app in apps:
@ -153,8 +148,6 @@ def read_app_args(args, options, allapps):
for v in vercodes[app['id']]: for v in vercodes[app['id']]:
if v not in allvcs: if v not in allvcs:
print "No such vercode %s for app %s" % (v, app['id']) print "No such vercode %s for app %s" % (v, app['id'])
elif options.latest:
app['builds'] = app['builds'][-1:]
if error: if error:
raise Exception("Found invalid vercodes for some apps") raise Exception("Found invalid vercodes for some apps")

View file

@ -59,26 +59,35 @@ def main():
apps = common.read_app_args(args, options, allapps) apps = common.read_app_args(args, options, allapps)
for app in apps: for app in apps:
for thisbuild in app['builds']: last = None
apk = os.path.join(output_dir, common.getapkname(app, thisbuild)) for build in app['builds']:
if not os.path.exists(apk): apk = os.path.join(output_dir, common.getapkname(app, build))
raise Exception("No such signed apk: %s" % apk) if os.path.exists(apk):
continue last = build
# Get device list each time to avoid device not found errors if last is None:
devs = devices() raise Exception("No available signed apks for %s" % app['id'])
if not devs:
raise Exception("No attached devices found") for app in apps:
print "Installing %s..." % apk build = app['builds'][0]
for dev in devs: apk = os.path.join(output_dir, common.getapkname(app, build))
print "Installing %s on %s..." % (apk, dev) if not os.path.exists(apk):
p = FDroidPopen(["adb", "-s", dev, "install", apk ]) raise Exception("No such signed apk: %s" % apk)
fail= "" continue
for line in p.stdout.splitlines(): # Get device list each time to avoid device not found errors
if line.startswith("Failure"): devs = devices()
fail = line[9:-1] if not devs:
if fail: raise Exception("No attached devices found")
raise Exception("Failed to install %s on %s: %s" % ( print "Installing %s..." % apk
apk, dev, fail)) for dev in devs:
print "Installing %s on %s..." % (apk, dev)
p = FDroidPopen(["adb", "-s", dev, "install", apk ])
fail= ""
for line in p.stdout.splitlines():
if line.startswith("Failure"):
fail = line[9:-1]
if fail:
raise Exception("Failed to install %s on %s: %s" % (
apk, dev, fail))
print "\nFinished" print "\nFinished"