55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
import argparse
|
|
import configparser
|
|
import os
|
|
import inspect
|
|
|
|
global languages
|
|
languages = {}
|
|
|
|
|
|
def set_languages(languages_dict):
|
|
global languages
|
|
languages = languages_dict
|
|
return True
|
|
|
|
|
|
def get_languages():
|
|
global languages
|
|
return languages
|
|
|
|
|
|
def init():
|
|
global config
|
|
global app_language
|
|
|
|
app_language = 'en_US'
|
|
# Decide what config-file to use
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('-e', '--environment', choices=['dev', 'prod', 'test'],
|
|
default='prod',
|
|
help='choose what environment type to run.'
|
|
' Defaults to prod')
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.environment == 'dev':
|
|
print("Using devsite.conf")
|
|
configfile = '/../devsite.conf'
|
|
elif args.environment == 'test':
|
|
print("Using testsite.conf")
|
|
configfile = '/../testsite.conf'
|
|
else:
|
|
print("Using site.conf")
|
|
configfile = '/../site.conf'
|
|
|
|
config = configparser.RawConfigParser()
|
|
config.read(os.path.dirname(
|
|
os.path.abspath(inspect.getfile(
|
|
inspect.currentframe()))) + configfile)
|
|
|
|
|
|
# Constructor for the API-endpoint
|
|
def host_endpoint():
|
|
return ('http://' + config.get('API', 'host') + ':' +
|
|
config.get('API', 'port'))
|