-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
62 lines (50 loc) · 1.32 KB
/
app.py
File metadata and controls
62 lines (50 loc) · 1.32 KB
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
57
58
59
60
61
62
from src import create_app
import os
import argparse
import sys
import getopt
from typing import Tuple
argumentlist = sys.argv[1:]
shortOps = "gh"
gnuOptions = ["generate", "help"]
APP_ENV = os.environ.get("APP_ENV")
FLASK_ENV = os.environ.get("FLASK_ENV")
if FLASK_ENV is None:
if APP_ENV is None:
FLASK_ENV = "production"
else:
FLASK_ENV = APP_ENV
if __name__ == "__main__":
try:
arg_values: tuple = getopt.getopt(
argumentlist,
shortOps,
gnuOptions
)
except getopt.error as err:
print(str(err))
sys.exit(2)
options: list = []
if (len(arg_values) > 0):
options = [arg[0][0] for arg in arg_values if len(arg) > 0 and len(arg[0]) > 0]
if "--help" in options or "-h" in options:
print(
"""
Usage: python app.py [Options]
app.py is used to run the development WSGI server or
to generate the initial data csv from ODOO by id you
use the -g or --generate flag
Options
-------
--help -h Print this message
--generate -g Generate the data csv from Odoo
"""
)
sys.exit(0)
elif not "--generate" in options and not "-g" in options:
app, server = create_app(FLASK_ENV)
app.run_server()
else:
create_app(FLASK_ENV)
else:
app, server = create_app(FLASK_ENV)