1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-09 00:40:11 +01:00

More logging switching

This commit is contained in:
Daniel Martí 2014-01-27 17:08:54 +01:00
parent 1b743e8b74
commit 1e3c2eee25
5 changed files with 32 additions and 27 deletions

View File

@ -22,6 +22,7 @@ import sys
import os
import glob
from optparse import OptionParser, OptionError
import logging
import common
from common import FDroidPopen
@ -61,7 +62,7 @@ def main():
output_dir = 'repo'
if not os.path.isdir(output_dir):
print "No signed output directory - nothing to do"
logging.info("No signed output directory - nothing to do")
sys.exit(0)
if args:
@ -93,22 +94,24 @@ def main():
devs = devices()
if not devs:
raise Exception("No attached devices found")
print "Installing %s..." % apk
logging.info("Installing %s..." % apk)
for dev in devs:
print "Installing %s on %s..." % (apk, dev)
logging.info("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:
if fail == "INSTALL_FAILED_ALREADY_EXISTS":
print "%s is already installed on %s." % (apk, dev)
else:
raise Exception("Failed to install %s on %s: %s" % (
apk, dev, fail))
if not fail:
continue
print "\nFinished"
if fail == "INSTALL_FAILED_ALREADY_EXISTS":
logging.warn("%s is already installed on %s." % (apk, dev))
else:
raise Exception("Failed to install %s on %s: %s" % (
apk, dev, fail))
logging.info("\nFinished")
if __name__ == "__main__":
main()

View File

@ -19,6 +19,7 @@
from optparse import OptionParser
import re
import logging
import common, metadata
config = None
@ -31,7 +32,7 @@ def warn(message):
if appid:
print "%s:" % appid
appid = None
print(' %s' % message)
print ' %s' % message
def main():
@ -136,7 +137,7 @@ def main():
if not appid:
print
print "Finished."
logging.info("Finished.")
if __name__ == "__main__":
main()

View File

@ -24,6 +24,7 @@ import shutil
import md5
import glob
from optparse import OptionParser
import logging
import common, metadata
from common import FDroidPopen, BuildException
@ -45,22 +46,22 @@ def main():
log_dir = 'logs'
if not os.path.isdir(log_dir):
print "Creating log directory"
logging.info("Creating log directory")
os.makedirs(log_dir)
tmp_dir = 'tmp'
if not os.path.isdir(tmp_dir):
print "Creating temporary directory"
logging.info("Creating temporary directory")
os.makedirs(tmp_dir)
output_dir = 'repo'
if not os.path.isdir(output_dir):
print "Creating output directory"
logging.info("Creating output directory")
os.makedirs(output_dir)
unsigned_dir = 'unsigned'
if not os.path.isdir(unsigned_dir):
print "No unsigned directory - nothing to do"
logging.info("No unsigned directory - nothing to do")
sys.exit(0)
# It was suggested at https://dev.guardianproject.info/projects/bazaar/wiki/FDroid_Audit
@ -79,11 +80,10 @@ def main():
m.update(app['id'])
keyalias = m.hexdigest()[:8]
if keyalias in allaliases:
print "There is a keyalias collision - publishing halted"
logging.info("There is a keyalias collision - publishing halted")
sys.exit(1)
allaliases.append(keyalias)
if options.verbose:
print "{0} apps, {0} key aliases".format(len(allapps), len(allaliases))
logging.info("{0} apps, {0} key aliases".format(len(allapps), len(allaliases)))
# Process any apks that are waiting to be signed...
for apkfile in sorted(glob.glob(os.path.join(unsigned_dir, '*.apk'))):
@ -95,7 +95,7 @@ def main():
if appid in vercodes and vercodes[appid]:
if vercode not in vercodes[appid]:
continue
print "Processing " + apkfile
logging.info("Processing " + apkfile)
# Figure out the key alias name we'll use. Only the first 8
# characters are significant, so we'll use the first 8 from
@ -114,7 +114,7 @@ def main():
m = md5.new()
m.update(appid)
keyalias = m.hexdigest()[:8]
print "Key alias: " + keyalias
logging.info("Key alias: " + keyalias)
# See if we already have a key for this application, and
# if not generate one...
@ -122,7 +122,7 @@ def main():
'-alias', keyalias, '-keystore', config['keystore'],
'-storepass', config['keystorepass']])
if p.returncode !=0:
print "Key does not exist - generating..."
logging.info("Key does not exist - generating...")
p = FDroidPopen(['keytool', '-genkey',
'-keystore', config['keystore'], '-alias', keyalias,
'-keyalg', 'RSA', '-keysize', '2048',
@ -155,7 +155,7 @@ def main():
shutil.move(os.path.join(unsigned_dir, tarfilename),
os.path.join(output_dir, tarfilename))
print 'Published ' + apkfilename
logging.info('Published ' + apkfilename)
if __name__ == "__main__":

View File

@ -21,6 +21,7 @@ import sys
import os
import subprocess
from optparse import OptionParser
import logging
import common
config = None
@ -40,11 +41,11 @@ def main():
config = common.read_config(options)
if len(args) != 1:
print "Specify a single command"
logging.critical("Specify a single command")
sys.exit(1)
if args[0] != 'init' and args[0] != 'update':
print "The only commands currently supported are 'init' and 'update'"
logging.critical("The only commands currently supported are 'init' and 'update'")
sys.exit(1)
serverwebroot = config['serverwebroot'].rstrip('/').replace('//', '/')

View File

@ -109,8 +109,8 @@ def main():
notverified += 1
logging.info("Finished")
print "{0} successfully verified".format(verified)
print "{0} NOT verified".format(notverified)
logging.info("{0} successfully verified".format(verified))
logging.info("{0} NOT verified".format(notverified))
if __name__ == "__main__":
main()