2018-05-05 01:58:21 +03:00
|
|
|
"""
|
|
|
|
Global configuration of the project.
|
|
|
|
All hardcoded pathes should be (theoretically) here.
|
|
|
|
"""
|
|
|
|
|
2017-05-09 00:21:19 +03:00
|
|
|
import logging
|
|
|
|
import os
|
2018-05-05 23:38:31 +03:00
|
|
|
from pygments.styles import get_all_styles
|
2017-05-09 00:21:19 +03:00
|
|
|
|
2018-05-05 01:58:21 +03:00
|
|
|
MYDIR = os.path.abspath(os.path.dirname(os.path.dirname('__file__')))
|
2017-05-09 00:21:19 +03:00
|
|
|
|
2018-05-05 01:58:21 +03:00
|
|
|
ANSI2HTML = os.path.join(MYDIR, "share/ansi2html.sh")
|
2017-05-09 00:21:19 +03:00
|
|
|
|
2018-05-05 01:58:21 +03:00
|
|
|
LOG_FILE = os.path.join(MYDIR, 'log/main.log')
|
|
|
|
FILE_QUERIES_LOG = os.path.join(MYDIR, 'log/queries.log')
|
|
|
|
TEMPLATES = os.path.join(MYDIR, 'share/templates')
|
|
|
|
STATIC = os.path.join(MYDIR, 'share/static')
|
|
|
|
PATH_VIM_ENVIRONMENT = os.path.join(MYDIR, 'share/vim')
|
2017-05-09 00:21:19 +03:00
|
|
|
|
2018-05-05 01:58:21 +03:00
|
|
|
PATH_TLDR_PAGES = "/home/igor/.tldr/cache/pages/*/*.md"
|
|
|
|
PATH_CHEAT_PAGES = "/usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/*"
|
|
|
|
PATH_CHEAT_SHEETS = "/home/igor/cheat.sheets/sheets/"
|
2017-05-09 00:21:19 +03:00
|
|
|
PATH_CHEAT_SHEETS_SPOOL = "/home/igor/cheat.sheets/spool/"
|
|
|
|
|
2018-05-05 23:38:31 +03:00
|
|
|
COLOR_STYLES = sorted(list(get_all_styles()))
|
|
|
|
|
2017-05-09 00:21:19 +03:00
|
|
|
def error(text):
|
2018-05-05 01:58:21 +03:00
|
|
|
"""
|
|
|
|
Log error `text` and produce a RuntimeError exception
|
|
|
|
"""
|
2017-05-09 00:21:19 +03:00
|
|
|
if not text.startswith('Too many queries'):
|
|
|
|
print text
|
2018-05-05 01:58:21 +03:00
|
|
|
logging.error("ERROR %s", text)
|
2017-05-09 00:21:19 +03:00
|
|
|
raise RuntimeError(text)
|
|
|
|
|
|
|
|
def log(text):
|
2018-05-05 01:58:21 +03:00
|
|
|
"""
|
|
|
|
Log error `text` (if it does not start with 'Too many queries')
|
|
|
|
"""
|
2017-05-09 00:21:19 +03:00
|
|
|
if not text.startswith('Too many queries'):
|
|
|
|
print text
|
|
|
|
logging.info(text)
|