Mercurial > cgi-bin > hgweb.cgi > tincan
comparison launch @ 25:e93e5e746cc5 draft header-includes
Preliminary debugging, still not fully tested.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 26 May 2019 11:43:48 -0700 |
parents | e88ab99914cf |
children | ce67eac10fc7 |
comparison
equal
deleted
inserted
replaced
24:34d3cfcd37ef | 25:e93e5e746cc5 |
---|---|
16 # M a i n P r o g r a m | 16 # M a i n P r o g r a m |
17 | 17 |
18 parser = ArgumentParser(prog=sys.argv[0], usage="%(prog)s [options] [directory [path]]") | 18 parser = ArgumentParser(prog=sys.argv[0], usage="%(prog)s [options] [directory [path]]") |
19 opt = parser.add_argument | 19 opt = parser.add_argument |
20 opt("-b", "--bind", default="localhost", help="address to bind to") | 20 opt("-b", "--bind", default="localhost", help="address to bind to") |
21 opt("-d", "--debug", action="store_true", help="enable debug mode") | |
22 opt("-f", "--force", action="store_true", help="do not abort on errors") | |
21 opt("-p", "--port", default=8080, help="port to listen on") | 23 opt("-p", "--port", default=8080, help="port to listen on") |
22 opt("directory", default=".", help="directory to serve", nargs='?') | 24 opt("directory", default=".", help="directory to serve", nargs='?') |
23 opt("path", default="/", help="URL path to serve", nargs='?') | 25 opt("path", default="/", help="URL path to serve", nargs='?') |
24 args = parser.parse_args(sys.argv[1:]) | 26 args = parser.parse_args(sys.argv[1:]) |
25 app, errors = launch(fsroot=args.directory, urlroot=args.path) | 27 app, errors = launch(fsroot=args.directory, urlroot=args.path, debug=args.debug) |
26 if errors: | 28 if errors: |
27 sys.stderr.write("{0}: {1} error{2} detected, aborting\n".format( | 29 action = "continuing" if args.force else "aborting" |
28 MYNAME, errors, "" if errors == 1 else "s")) | 30 sys.stderr.write("{0}: {1} error{2} detected, {3}\n".format( |
29 sys.exit(1) | 31 MYNAME, errors, "" if errors == 1 else "s", action)) |
32 if not args.force: sys.exit(1) | |
30 app.run(host=args.bind, port=args.port) | 33 app.run(host=args.bind, port=args.port) |