forked from yeti-platform/yeti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yeti.py
executable file
·53 lines (36 loc) · 1.23 KB
/
yeti.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import argparse
from core.web import webapp
logging.basicConfig(
format='%(levelname)s:%(module)s:%(message)s', level=logging.ERROR)
def webserver(args):
# Enable debug and autoreload in dev
webapp.debug = args.debug
if webapp.debug:
webapp.jinja_env.auto_reload = True
webapp.config['TEMPLATES_AUTO_RELOAD'] = True
syncdb()
print("[+] Yeti started. Point browser to http://localhost:5000/{}".format(
" (debug)" if args.debug else ""))
webapp.run(host="0.0.0.0")
def syncdb(args=None):
from core.internals import Internals
Internals.syncdb()
COMMANDS = {
'webserver': webserver,
'syncdb': syncdb,
}
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(help='sub-command help', dest="command")
webserver = subparsers.add_parser('webserver', help='Launch yeti webserver')
webserver.add_argument(
'--debug', action='store_true', help="Run Flask in debug mode")
subparsers.add_parser('syncdb', help='Sync database with Yeti version')
args = parser.parse_args()
command = args.command
COMMANDS[command](args)
if __name__ == '__main__':
main()