|
24 | 24 | __author__ = '[email protected] (Joe Gregorio)'
|
25 | 25 | __all__ = ['argparser', 'run_flow', 'run', 'message_if_missing']
|
26 | 26 |
|
27 |
| -import argparse |
28 | 27 | import BaseHTTPServer
|
29 | 28 | import logging
|
30 | 29 | import socket
|
|
51 | 50 | # argparser is an ArgumentParser that contains command-line options expected
|
52 | 51 | # by tools.run(). Pass it in as part of the 'parents' argument to your own
|
53 | 52 | # ArgumentParser.
|
54 |
| -argparser = argparse.ArgumentParser(add_help=False) |
55 |
| -argparser.add_argument('--auth_host_name', default='localhost', |
56 |
| - help='Hostname when running a local web server.') |
57 |
| -argparser.add_argument('--noauth_local_webserver', action='store_true', |
58 |
| - default=False, help='Do not run a local web server.') |
59 |
| -argparser.add_argument('--auth_host_port', default=[8080, 8090], type=int, |
60 |
| - nargs='*', help='Port web server should listen on.') |
61 |
| -argparser.add_argument('--logging_level', default='ERROR', |
62 |
| - choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', |
63 |
| - 'CRITICAL'], |
64 |
| - help='Set the logging level of detail.') |
| 53 | +argparser = _CreateArgumentParser() |
| 54 | + |
| 55 | +def _CreateArgumentParser(): |
| 56 | + try: |
| 57 | + import argparse |
| 58 | + except ImportError: |
| 59 | + return None |
| 60 | + argparser = argparse.ArgumentParser(add_help=False) |
| 61 | + argparser.add_argument('--auth_host_name', default='localhost', |
| 62 | + help='Hostname when running a local web server.') |
| 63 | + argparser.add_argument('--noauth_local_webserver', action='store_true', |
| 64 | + default=False, help='Do not run a local web server.') |
| 65 | + argparser.add_argument('--auth_host_port', default=[8080, 8090], type=int, |
| 66 | + nargs='*', help='Port web server should listen on.') |
| 67 | + argparser.add_argument('--logging_level', default='ERROR', |
| 68 | + choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', |
| 69 | + 'CRITICAL'], |
| 70 | + help='Set the logging level of detail.') |
| 71 | + return argparser |
65 | 72 |
|
66 | 73 |
|
67 | 74 | class ClientRedirectServer(BaseHTTPServer.HTTPServer):
|
|
0 commit comments