Mercurial > piecrust2
comparison foodtruck/main.py @ 588:b884bef3e611
admin: New `admin` command to manage FoodTruck-related things.
Remove old FoodTruck command and packaging.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 17 Jan 2016 21:44:41 -0800 |
parents | d4a01a023998 |
children | d7baac1d01e6 |
comparison
equal
deleted
inserted
replaced
587:d4a01a023998 | 588:b884bef3e611 |
---|---|
1 import sys | |
2 import logging | 1 import logging |
3 import argparse | |
4 from .web import app | |
5 | 2 |
6 | 3 |
7 logger = logging.getLogger(__name__) | 4 logger = logging.getLogger(__name__) |
8 | 5 |
9 | 6 |
10 def main(): | 7 def run_foodtruck(debug=False): |
11 parser = argparse.ArgumentParser( | 8 from .web import app |
12 description="FoodTruck command line utility") | |
13 parser.add_argument( | |
14 '--debug', | |
15 help="Show debug information", | |
16 action='store_true') | |
17 parser.add_argument( | |
18 '--version', | |
19 help="Print version and exit", | |
20 action='store_true') | |
21 | |
22 args = parser.parse_args() | |
23 if args.version: | |
24 try: | |
25 from .__version__ import version | |
26 except ImportError: | |
27 print("Can't find version information.") | |
28 args.exit(1) | |
29 print("FoodTruck %s" % version) | |
30 args.exit(0) | |
31 | |
32 root_logger = logging.getLogger() | |
33 root_logger.setLevel(logging.INFO) | |
34 if args.debug: | |
35 root_logger.setLevel(logging.DEBUG) | |
36 | |
37 log_handler = logging.StreamHandler(sys.stdout) | |
38 if args.debug: | |
39 log_handler.setLevel(logging.DEBUG) | |
40 else: | |
41 log_handler.setLevel(logging.INFO) | |
42 root_logger.addHandler(log_handler) | |
43 | |
44 try: | 9 try: |
45 app.run(debug=args.debug, threaded=True) | 10 app.run(debug=debug, threaded=True) |
46 except SystemExit: | 11 except SystemExit: |
47 # This is needed for Werkzeug's code reloader to be able to correctly | 12 # This is needed for Werkzeug's code reloader to be able to correctly |
48 # shutdown the child process in order to restart it (otherwise, SSE | 13 # shutdown the child process in order to restart it (otherwise, SSE |
49 # generators will keep it alive). | 14 # generators will keep it alive). |
50 from .views import baking | 15 from .views import baking |