# HG changeset patch # User Jeff Hammel # Date 1606251516 28800 # Node ID f7120eba68775d81dd45c97fd7bcdd2712f96b59 # Parent bf5386d3c7e48637609e92172e94e4d3a2301ba2 py3 diff -r bf5386d3c7e4 -r f7120eba6877 toolbox/factory.py --- 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__':