diff requestdumpster/dumpster.py @ 7:83c51f45b82d

optparse -> argparse and the like
author Jeff Hammel <k0scist@gmail.com>
date Wed, 16 Dec 2015 10:31:00 -0800
parents aa19f80caa63
children eb260393caef
line wrap: on
line diff
--- a/requestdumpster/dumpster.py	Wed Jul 01 08:42:12 2015 -0700
+++ b/requestdumpster/dumpster.py	Wed Dec 16 10:31:00 2015 -0800
@@ -5,7 +5,7 @@
 """
 
 # imports
-import optparse
+import argparse
 import os
 import sys
 import time
@@ -30,12 +30,12 @@
     """CLI"""
 
     # parse command line arguments
-    parser = optparse.OptionParser(description=__doc__)
-    parser.add_option('-p', '--port', dest='port',
-                      type='int', default=9555,
-                      help="port to serve on")
-    parser.add_option('-d', '--directory', dest='directory',
-                      help="directory to output requests to")
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument('-p', '--port', dest='port',
+                        type=int, default=9555,
+                        help="port to serve on")
+    parser.add_argument('-d', '--directory', dest='directory',
+                        help="directory to output requests to")
     options = parser.parse_args()
 
     # instantiate WSGI app
@@ -46,7 +46,12 @@
 
     # serve some web
     server = simple_server.make_server(host=host, port=int(port), app=app)
-    server.serve_forever()
+    print url
+    try:
+        server.serve_forever()
+    except KeyboardInterrupt:
+        pass
+
 
 if __name__ == '__main__':
     main()