-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
50 lines (39 loc) · 1.42 KB
/
config.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
# Note this will not override existing environment settings
#from dotenv import load_dotenv
import os
#load_dotenv()
def file_must_exist(f):
if os.path.exists(f): return
msg = f + " not found."
try:
raise FileNotFoundError(msg)
except:
raise IOError(msg)
class Config(object):
""" Read environment here to create configuration data. """
# Config.LMUTIL will be set to a list of args to pass to subprocess.
TEST_MODE = False
TEST_FILE = 'lmstat.txt'
DBSERVER = os.environ.get('DBSERVER')
DATABASE = os.environ.get('DATABASE')
DBUSER = os.environ.get('DBUSER')
DBPASSWORD = os.environ.get('DBPASSWORD')
LMHOME = os.environ.get('LMHOME') or '/home/flexlm'
LICENSE = os.environ.get('LICENSE') or 'service.txt'
_LMUTIL = os.environ.get('LMUTIL')
if _LMUTIL:
# Holy cow but Windows was super fussy about this section.
# It would not accept running the actual file with .exe on it.
# It was impossible to pass spaces in args. Gag me, let me have Linux.
os.chdir(LMHOME)
file_must_exist(_LMUTIL)
file_must_exist(LICENSE)
LMUTIL = ["/lib/x86_64-linux-gnu/ld-2.24.so", _LMUTIL, 'lmstat', '-c', LICENSE, '-a']
else:
print("TEST MODE INVOKED.")
TEST_MODE = True
if not TEST_MODE:
file_must_exist(LICENSE)
PORT = os.environ.get('PORT') or 5000
pass
# That's all!