From 8efde54ebc965f047a8958c894c1003b7fc369a1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 10 Jul 2015 23:31:47 -0700 Subject: [PATCH 1/3] Merge branch 'android_branch', remote branch 'origin/android_branch' into android_branch From fe91c9e04eba6c8ab5f82ecf7b8b8f07ee58d2ff Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 25 Jul 2015 21:56:48 -0700 Subject: [PATCH 2/3] update to serve newest debug as well as release builds, and to know about variants --- xwords4/android/scripts/info.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/xwords4/android/scripts/info.py b/xwords4/android/scripts/info.py index 0a59f6be5..7c9c95a7a 100755 --- a/xwords4/android/scripts/info.py +++ b/xwords4/android/scripts/info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # Script meant to be installed on eehouse.org. -import logging, shelve, hashlib, sys, json, subprocess, glob, os, struct, random +import logging, shelve, hashlib, sys, json, subprocess, glob, os, struct, random, string import mk_for_download, mygit import xwconfig @@ -161,10 +161,13 @@ def getDictSums(): openShelf() return s_shelf[k_SUMS] -def getOrderedApks( path ): +def getOrderedApks( path, debug ): + # logging.debug( "getOrderedApks(" + path + ")" ) apks = [] - pattern = path + "/XWords4-release_*android_beta_*.apk" + pattern = path + if debug: pattern += "/XWords4-debug-android_*.apk" + else: pattern += "/XWords4-release_*android_beta_*.apk" files = ((os.stat(apk).st_mtime, apk) for apk in glob.glob(pattern)) for mtime, file in sorted(files, reverse=True): @@ -173,6 +176,14 @@ def getOrderedApks( path ): return apks +def getVariantDir( name ): + result = '' + splits = string.split( name, '.' ) + last = splits[-1] + if not last == 'xw4': result = last + '/' + # logging.debug( 'getVariantDir(' + name + ") => " + result ) + return result + # public, but deprecated def curVersion( req, name, avers = 41, gvers = None, installer = None ): global k_versions @@ -218,11 +229,16 @@ def getApp( params, name ): if k_NAME in params: name = params[k_NAME] if name: + variantDir = getVariantDir( name ) # If we're a dev device, always push the latest if k_DEBUG in params and params[k_DEBUG]: - pass # we don't upgrade DEBUG builds + dir = k_filebase + k_apkDir + variantDir + apks = getOrderedApks( dir, True ) + if 0 < len(apks): + url = k_urlbase + '/' + k_apkDir + variantDir + apks[0][len(dir):] + result = {k_URL: url} elif k_DEVOK in params and params[k_DEVOK]: - apks = getOrderedApks( k_filebase + k_apkDir ) + apks = getOrderedApks( k_filebase + k_apkDir, False ) if 0 < len(apks): apk = apks[0] # Does path NOT contain name of installed file @@ -438,7 +454,6 @@ def getUpdates( req, params ): else: logging.debug( "NOT FOUND xlate info" ) - logging.debug( 'getUpdates done:', ) result = json.dumps( result ) # logging.debug( result ) return result @@ -493,7 +508,7 @@ def main(): if argc >= 4: usage() path = "" if argc >= 3: path = sys.argv[2] - apks = getOrderedApks( path ) + apks = getOrderedApks( path, False ) if 0 == len(apks): print "No apks in", path for apk in apks: print apk From e31c7ae4f595940f9e54feb588e38fcc75aa0dc3 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 27 Jul 2015 07:12:44 -0700 Subject: [PATCH 3/3] update to not notify of debug build updates when version matches what's installed --- xwords4/android/scripts/info.py | 38 ++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/xwords4/android/scripts/info.py b/xwords4/android/scripts/info.py index 310758fd9..ab07fb279 100755 --- a/xwords4/android/scripts/info.py +++ b/xwords4/android/scripts/info.py @@ -1,7 +1,7 @@ #!/usr/bin/python # Script meant to be installed on eehouse.org. -import logging, shelve, hashlib, sys, json, subprocess, glob, os, struct, random +import logging, shelve, hashlib, sys, json, subprocess, glob, os, struct, random, string import mk_for_download, mygit import xwconfig @@ -161,10 +161,13 @@ def getDictSums(): openShelf() return s_shelf[k_SUMS] -def getOrderedApks( path ): +def getOrderedApks( path, debug ): + # logging.debug( "getOrderedApks(" + path + ")" ) apks = [] - pattern = path + "/XWords4-release_*android_beta_*.apk" + pattern = path + if debug: pattern += "/XWords4-debug-android_*.apk" + else: pattern += "/XWords4-release_*android_beta_*.apk" files = ((os.stat(apk).st_mtime, apk) for apk in glob.glob(pattern)) for mtime, file in sorted(files, reverse=True): @@ -173,6 +176,14 @@ def getOrderedApks( path ): return apks +def getVariantDir( name ): + result = '' + splits = string.split( name, '.' ) + last = splits[-1] + if not last == 'xw4': result = last + '/' + # logging.debug( 'getVariantDir(' + name + ") => " + result ) + return result + # public, but deprecated def curVersion( req, name, avers = 41, gvers = None, installer = None ): global k_versions @@ -218,12 +229,24 @@ def getApp( params, name ): if k_NAME in params: name = params[k_NAME] if name: + variantDir = getVariantDir( name ) # If we're a dev device, always push the latest if k_DEBUG in params and params[k_DEBUG]: - url = k_urlbase + '/' + k_apkDir + 'XWords4-debug.apk' - result = {k_URL: url} + dir = k_filebase + k_apkDir + variantDir + apks = getOrderedApks( dir, True ) + if 0 < len(apks): + apk = apks[0] + logging.debug("got: " + apk) + curApk = params[k_GVERS] + '.apk' + if curApk in apk: + logging.debug( "already have " + curApk ) + else: + url = k_urlbase + '/' + k_apkDir + variantDir + apk[len(dir):] + logging.debug("url: " + url) + result = {k_URL: url} + logging.debug("DONE") elif k_DEVOK in params and params[k_DEVOK]: - apks = getOrderedApks( k_filebase + k_apkDir ) + apks = getOrderedApks( k_filebase + k_apkDir, False ) if 0 < len(apks): apk = apks[0] # Does path NOT contain name of installed file @@ -439,7 +462,6 @@ def getUpdates( req, params ): else: logging.debug( "NOT FOUND xlate info" ) - logging.debug( 'getUpdates done:', ) result = json.dumps( result ) # logging.debug( result ) return result @@ -494,7 +516,7 @@ def main(): if argc >= 4: usage() path = "" if argc >= 3: path = sys.argv[2] - apks = getOrderedApks( path ) + apks = getOrderedApks( path, False ) if 0 == len(apks): print "No apks in", path for apk in apks: print apk