-
Notifications
You must be signed in to change notification settings - Fork 2
/
manage.py
executable file
·56 lines (39 loc) · 1.35 KB
/
manage.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
54
55
56
#!env/bin/python
import subprocess
from flask_script import Manager, Command, Option
from flask_migrate import MigrateCommand
from app import create_app
import scripts.load_zips
import scripts.demo_data
import scripts.pandemic_demo_data
app = create_app()
manager = Manager(app)
class DemoDataCommand(Command):
def run(self):
scripts.demo_data.load()
class PandemicDemoDataCommand(Command):
def run(self):
scripts.pandemic_demo_data.load()
class ServerCommand(Command):
def __init__(self, default_port=manager.app.config['SERVER_PORT']):
self.default_port=default_port
def get_options(self):
return [
Option('--port', '-p', dest='port', default=self.default_port),
]
def run(self, port):
port = int(port)
manager.app.run(host=manager.app.config['SERVER_HOST'], port=port)
class ZipLoaderCommand(Command):
def run(self):
scripts.load_zips.load()
class TestCommand(Command):
def run(self):
subprocess.run(["python", "-m", "unittest", "discover", "-s", "tests"])
manager.add_command('db', MigrateCommand)
manager.add_command('serve', ServerCommand())
manager.add_command('zips', ZipLoaderCommand())
manager.add_command('demo', DemoDataCommand())
manager.add_command('pdemo', PandemicDemoDataCommand())
manager.add_command('test', TestCommand())
manager.run()