changeset 6:f7120eba6877

py3
author Jeff Hammel <k0scist@gmail.com>
date Tue, 24 Nov 2020 12:58:36 -0800
parents bf5386d3c7e4
children 394648c67478
files toolbox/factory.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/toolbox/factory.py	Tue Nov 03 10:10:44 2020 -0800
+++ b/toolbox/factory.py	Tue Nov 24 12:58:36 2020 -0800
@@ -4,14 +4,16 @@
 WSGI -> HTTP server factories for toolbox
 """
 
+import argparse
 import os
 import sys
 
-from dispatcher import Dispatcher
+from .dispatcher import Dispatcher
 from paste.urlparser import StaticURLParser
 from pkg_resources import resource_filename
 from theslasher import TheSlasher
 
+
 class PassthroughFileserver(object):
     """serve files if they exist"""
 
@@ -46,8 +48,8 @@
     app = Dispatcher()
     app = PassthroughFileserver(app, resource_filename(__name__, 'static'))
     server = simple_server.make_server(host=host, port=int(port), app=app)
-    fqdn = '127.0.0.1' if host =='0.0.0.0' else host
-    print "Serving toolbox at http://%s:%d/" % (fqdn, port)
+    fqdn = '127.0.0.1' if host == '0.0.0.0' else host
+    print("Serving toolbox at http://%s:%d/" % (fqdn, port))
     server.serve_forever()
 
 
@@ -60,7 +62,7 @@
 
     # parse command line
     usage = '%prog [options]'
-    import argparse
+
     parser = argparse.ArgumentParser(usage=usage, description=__doc__.strip())
     parser.add_argument('--factory', default='wsgiref',
                         choices=factories.keys(),
@@ -72,8 +74,8 @@
     # serve toolbox
     factory = factories[args.__dict__.pop('factory')]
     factory_args = args.__dict__
-    print "Serving using factory: %s" % getattr(factory, '__name__', str(factory))
-    print "Factory arguments: %s" % factory_args
+    print("Serving using factory: %s" % getattr(factory, '__name__', str(factory)))
+    print("Factory arguments: %s" % factory_args)
     factory(**factory_args)
 
 if __name__ == '__main__':