Skip to content

Commit ad58fee

Browse files
committed
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.
1 parent 99798ec commit ad58fee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

roundup/scripts/roundup_server.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ class ThreadingServer(socketserver.ThreadingMixIn,
753753
kwargs['ssl_pem'] = self["PEM"]
754754
httpd = server_class(*args, **kwargs)
755755
except socket.error as e:
756-
if e[0] == errno.EADDRINUSE:
756+
if e.args[0] == errno.EADDRINUSE:
757757
raise socket.error(_("Unable to bind to port %s, port already in use.") \
758758
% self["PORT"])
759759
raise
@@ -1036,7 +1036,12 @@ def run(port=undefined, success_message=None):
10361036
daemonize(config["PIDFILE"])
10371037

10381038
# create the server
1039-
httpd = config.get_server()
1039+
try:
1040+
httpd = config.get_server()
1041+
except Exception as e:
1042+
# capture all exceptions and pretty print them
1043+
print(e)
1044+
sys.exit(2)
10401045

10411046
if success_message:
10421047
print(success_message)

0 commit comments

Comments
 (0)