[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] Return status codes from subcommands.



commit 933c0dedb0454acf9bd575f2dcbba3614135dc2e
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Tue Nov 19 03:07:44 2013 +0000

    Return status codes from subcommands.
    
    Apparently, "unhandled" SystemExits make Travis CI angry.
---
 lib/bridgedb/Main.py   |   11 ++++++++---
 lib/bridgedb/runner.py |    7 +++++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index cdf1d12..8e22719 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -584,6 +584,8 @@ def runSubcommand(options, config):
     # mentioned above with the EmailServer and HTTPServer.
     from bridgedb import runner
 
+    statuscode = 0
+
     if options['dump-bridges']:
         runner.doDumpBridges(config)
 
@@ -591,15 +593,18 @@ def runSubcommand(options, config):
         logging.debug("Running BridgeDB command: '%s'" % options.subCommand)
 
         if 'descriptors' in options.subOptions:
-            runner.generateDescriptors(options.subOptions['descriptors'],
-                                       config.RUN_IN_DIR)
+            statuscode = runner.generateDescriptors(
+                options.subOptions['descriptors'], config.RUN_IN_DIR)
 
         if options.subCommand == 'test':
             if options.subOptions['trial']:
                 runner.runTrial(options.subOptions)
             if options.subOptions['unittests']:
                 runner.runTests(options.subOptions)
-        raise SystemExit("Subcommand '%s' finished." % options.subCommand)
+
+        logging.info("Subcommand '%s' finished with status %s."
+                     % (options.subCommand, statuscode))
+        sys.exit(statuscode)
 
 def run(options):
     """This is the main entry point into BridgeDB.
diff --git a/lib/bridgedb/runner.py b/lib/bridgedb/runner.py
index 1f30dfb..8c641f6 100644
--- a/lib/bridgedb/runner.py
+++ b/lib/bridgedb/runner.py
@@ -44,6 +44,7 @@ def generateDescriptors(count=None, rundir=None):
     import os.path
 
     proc = None
+    statuscode = 0
     script = 'gen_bridge_descriptors'
     rundir = rundir if os.path.isdir(rundir) else None
     count = count if count else 3
@@ -56,9 +57,11 @@ def generateDescriptors(count=None, rundir=None):
             if proc.returncode:
                 print("There was an error generating bridge descriptors.",
                       "(Returncode: %d)" % proc.returncode)
+                statuscode = proc.returncode
             else:
-                print("Sucessfully bridge generated descriptors.")
-    del subprocess
+                print("Sucessfully generated %s descriptors." % str(count))
+        del subprocess
+        return statuscode
 
 def runTrial(options):
     """Run Twisted trial based unittests, optionally with coverage.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits