diff roundup/scripts/roundup_server.py @ 5712:320a1692a473

Fix exception handling code for case where port already in use. Change e[0] to e.args[0] (old style to new style reference??) Also wrap call to config.get_server in try/except block and print any exception to disable traceback.
author John Rouillard <rouilj@ieee.org>
date Wed, 17 Apr 2019 20:35:56 -0400
parents 5ad31de777a8
children 1a835db41674
line wrap: on
line diff
--- a/roundup/scripts/roundup_server.py	Mon Apr 15 21:41:06 2019 -0400
+++ b/roundup/scripts/roundup_server.py	Wed Apr 17 20:35:56 2019 -0400
@@ -753,7 +753,7 @@
                 kwargs['ssl_pem'] = self["PEM"]
             httpd = server_class(*args, **kwargs)
         except socket.error as e:
-            if e[0] == errno.EADDRINUSE:
+            if e.args[0] == errno.EADDRINUSE:
                 raise socket.error(_("Unable to bind to port %s, port already in use.") \
                     % self["PORT"])
             raise
@@ -1036,7 +1036,12 @@
                 daemonize(config["PIDFILE"])
 
     # create the server
-    httpd = config.get_server()
+    try:
+        httpd = config.get_server()
+    except Exception as e:
+        # capture all exceptions and pretty print them
+        print(e)
+        sys.exit(2)
 
     if success_message:
         print(success_message)

Roundup Issue Tracker: http://roundup-tracker.org/