forked from NicolasNimetz/backend-python-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (27 loc) · 695 Bytes
/
main.py
File metadata and controls
33 lines (27 loc) · 695 Bytes
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
"""AlayaNotes
Usage:
main.py [run]
main.py initdb
"""
from docopt import docopt
import subprocess
import os
from alayatodo import app
def _run_sql(filename):
try:
subprocess.check_output(
"sqlite3 %s < %s" % (app.config['DATABASE'], filename),
stderr=subprocess.STDOUT,
shell=True
)
except subprocess.CalledProcessError, ex:
print ex.output
os.exit(1)
if __name__ == '__main__':
args = docopt(__doc__)
if args['initdb']:
_run_sql('resources/database.sql')
_run_sql('resources/fixtures.sql')
print "AlayaTodo: Database initialized."
else:
app.run(use_reloader=True)