[elbe-devel] [PATCH 1/6] elbepack: daemon: convert port through optparse

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Jun 25 16:25:33 CEST 2024


Instead of manually converting the port argument to a number,
let optparse do it.
This also provides better errormessages.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/commands/daemon.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/elbepack/commands/daemon.py b/elbepack/commands/daemon.py
index 04bc1a6c6987..da811da8b717 100644
--- a/elbepack/commands/daemon.py
+++ b/elbepack/commands/daemon.py
@@ -24,7 +24,7 @@ def run_command(argv):
     oparser = OptionParser(usage='usage: %prog')
     oparser.add_option('--host', dest='host', default='0.0.0.0',
                        help='interface to host daemon')
-    oparser.add_option('--port', dest='port', default=7587,
+    oparser.add_option('--port', dest='port', type=int, default=7587,
                        help='port to host daemon')
 
     for d in daemons:
@@ -44,7 +44,7 @@ def run_command(argv):
     cherrypy.server.unsubscribe()
     server = cherrypy._cpserver.Server()
     server.socket_host = opt.host
-    server.socket_port = int(opt.port)
+    server.socket_port = opt.port
     server.thread_pool = 30
 
     # For SSL Support

-- 
2.45.2



More information about the elbe-devel mailing list