2018-05-04 11:53:29 +00:00
|
|
|
#!/usr/bin/env python3
|
2016-12-09 07:46:37 +00:00
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
'''
|
|
|
|
Flask global variables shared accross modules
|
|
|
|
'''
|
2018-04-17 14:06:32 +00:00
|
|
|
import configparser
|
2016-12-09 07:46:37 +00:00
|
|
|
import redis
|
|
|
|
import os
|
|
|
|
|
|
|
|
# FLASK #
|
|
|
|
app = None
|
|
|
|
|
|
|
|
# CONFIG #
|
|
|
|
configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg')
|
|
|
|
if not os.path.exists(configfile):
|
|
|
|
raise Exception('Unable to find the configuration file. \
|
|
|
|
Did you set environment variables? \
|
|
|
|
Or activate the virtualenv.')
|
|
|
|
|
2018-04-17 14:06:32 +00:00
|
|
|
cfg = configparser.ConfigParser()
|
2016-12-09 07:46:37 +00:00
|
|
|
cfg.read(configfile)
|
|
|
|
|
|
|
|
|
|
|
|
# REDIS #
|
|
|
|
r_serv = redis.StrictRedis(
|
|
|
|
host=cfg.get("Redis_Queues", "host"),
|
|
|
|
port=cfg.getint("Redis_Queues", "port"),
|
2018-05-04 11:53:29 +00:00
|
|
|
db=cfg.getint("Redis_Queues", "db"),
|
|
|
|
decode_responses=True)
|
2016-12-09 07:46:37 +00:00
|
|
|
|
|
|
|
r_serv_log = redis.StrictRedis(
|
|
|
|
host=cfg.get("Redis_Log", "host"),
|
|
|
|
port=cfg.getint("Redis_Log", "port"),
|
2018-05-04 11:53:29 +00:00
|
|
|
db=cfg.getint("Redis_Log", "db"),
|
|
|
|
decode_responses=True)
|
2016-12-09 07:46:37 +00:00
|
|
|
|
|
|
|
r_serv_charts = redis.StrictRedis(
|
2018-05-07 12:50:40 +00:00
|
|
|
host=cfg.get("ARDB_Trending", "host"),
|
|
|
|
port=cfg.getint("ARDB_Trending", "port"),
|
|
|
|
db=cfg.getint("ARDB_Trending", "db"),
|
2018-05-04 11:53:29 +00:00
|
|
|
decode_responses=True)
|
2016-12-09 07:46:37 +00:00
|
|
|
|
|
|
|
r_serv_sentiment = redis.StrictRedis(
|
2018-05-07 12:50:40 +00:00
|
|
|
host=cfg.get("ARDB_Sentiment", "host"),
|
|
|
|
port=cfg.getint("ARDB_Sentiment", "port"),
|
|
|
|
db=cfg.getint("ARDB_Sentiment", "db"),
|
2018-05-04 11:53:29 +00:00
|
|
|
decode_responses=True)
|
2016-12-09 07:46:37 +00:00
|
|
|
|
|
|
|
r_serv_term = redis.StrictRedis(
|
2018-05-07 12:50:40 +00:00
|
|
|
host=cfg.get("ARDB_TermFreq", "host"),
|
|
|
|
port=cfg.getint("ARDB_TermFreq", "port"),
|
|
|
|
db=cfg.getint("ARDB_TermFreq", "db"),
|
2018-05-04 11:53:29 +00:00
|
|
|
decode_responses=True)
|
2016-12-09 07:46:37 +00:00
|
|
|
|
2017-07-18 14:57:15 +00:00
|
|
|
r_serv_cred = redis.StrictRedis(
|
2018-05-07 12:50:40 +00:00
|
|
|
host=cfg.get("ARDB_TermCred", "host"),
|
|
|
|
port=cfg.getint("ARDB_TermCred", "port"),
|
|
|
|
db=cfg.getint("ARDB_TermCred", "db"),
|
2018-05-04 11:53:29 +00:00
|
|
|
decode_responses=True)
|
2017-07-18 14:57:15 +00:00
|
|
|
|
2016-12-09 07:46:37 +00:00
|
|
|
r_serv_pasteName = redis.StrictRedis(
|
|
|
|
host=cfg.get("Redis_Paste_Name", "host"),
|
|
|
|
port=cfg.getint("Redis_Paste_Name", "port"),
|
2018-05-04 11:53:29 +00:00
|
|
|
db=cfg.getint("Redis_Paste_Name", "db"),
|
|
|
|
decode_responses=True)
|
2016-12-09 07:46:37 +00:00
|
|
|
|
2018-05-15 21:28:47 +00:00
|
|
|
r_serv_tags = redis.StrictRedis(
|
|
|
|
host=cfg.get("ARDB_Tags", "host"),
|
|
|
|
port=cfg.getint("ARDB_Tags", "port"),
|
|
|
|
db=cfg.getint("ARDB_Tags", "db"),
|
|
|
|
decode_responses=True)
|
|
|
|
|
|
|
|
r_serv_metadata = redis.StrictRedis(
|
|
|
|
host=cfg.get("ARDB_Metadata", "host"),
|
|
|
|
port=cfg.getint("ARDB_Metadata", "port"),
|
|
|
|
db=cfg.getint("ARDB_Metadata", "db"),
|
|
|
|
decode_responses=True)
|
|
|
|
|
2016-12-09 07:46:37 +00:00
|
|
|
# VARIABLES #
|
|
|
|
max_preview_char = int(cfg.get("Flask", "max_preview_char")) # Maximum number of character to display in the tooltip
|
|
|
|
max_preview_modal = int(cfg.get("Flask", "max_preview_modal")) # Maximum number of character to display in the modal
|
|
|
|
|
2017-12-12 10:00:26 +00:00
|
|
|
DiffMaxLineLength = int(cfg.get("Flask", "DiffMaxLineLength"))#Use to display the estimated percentage instead of a raw value
|