chiark / gitweb /
More logging switching
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 27 Jan 2014 16:08:54 +0000 (17:08 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 27 Jan 2014 20:49:29 +0000 (21:49 +0100)
fdroidserver/install.py
fdroidserver/lint.py
fdroidserver/publish.py
fdroidserver/server.py
fdroidserver/verify.py

index 66be06636415ced70bf7234b54e03880fb0b8837..fccc5c2c7404e208a10c68dccd1f1c79a52ebe91 100644 (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))
-
-    print "\nFinished"
+            if not fail:
+                continue
+
+            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()
index df8104baae310724dfd44d0cb3fed37b962e6334..da6a5234df4407a3f4a41870d8f161d4637e511c 100644 (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()
index 35c6c9c1fe7b6a978d3f9f7f358c6b5504774ce0..1d8d8dbab5ab4e633afb7a713a446c00d8b3bcf2 100644 (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__":
index 43ea05fd4e7117288773778d53a7a7415a07ddc8..f04dc264d182229ea7e7fad30f66eca9c6ffef7d 100644 (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('//', '/')
index 0192f7132719dc17fbc141e4b975fa03141b57d2..4c99f4ad8149188e17f426d24de99cca256b186c 100644 (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()