Permalink
Browse files

add optparsing magic for port numbers

git-svn-id: https://modestmaps.googlecode.com/svn/trunk/py@468 a23cadb0-8de1-11de-82e5-a1837a67dc72
  • Loading branch information...
1 parent 62de22d commit 6a7aff83cfa14e26d269ff647d3c302298c63a68 asc committed Jan 27, 2008
Showing with 18 additions and 14 deletions.
  1. +9 −7 ws-compose.py
  2. +9 −7 ws-pinwin.py
View
@@ -1,10 +1,12 @@
-import sys
+import optparse
import wscompose
-if __name__ == "__main__" :
- try:
- port = int(sys.argv[1])
- except:
- port = None
- app = wscompose.server(wscompose.handler, port)
+if __name__ == "__main__" :
+
+ parser = optparse.OptionParser()
+ parser.add_option("-p", "--port", dest="port", help="port number that the ws-compose HTTP server will listen on", default=9999)
+
+ (opts, args) = parser.parse_args()
+
+ app = wscompose.server(wscompose.handler, int(opts.port))
app.loop()
View
@@ -1,11 +1,13 @@
-import sys
+import optparse
import wscompose
import wscompose.pinwin
-if __name__ == "__main__" :
- try:
- port = int(sys.argv[1])
- except:
- port = None
- app = wscompose.server(wscompose.pinwin.handler, port)
+if __name__ == "__main__" :
+
+ parser = optparse.OptionParser()
+ parser.add_option("-p", "--port", dest="port", help="port number that the ws-pinwin HTTP server will listen on", default=9999)
+
+ (opts, args) = parser.parse_args()
+
+ app = wscompose.server(wscompose.pinwin.handler, int(opts.port))
app.loop()

0 comments on commit 6a7aff8

Please sign in to comment.