mirror of
https://github.com/chubin/cheat.sh.git
synced 2026-06-20 21:26:44 +02:00
lib/globals.py clean up
This commit is contained in:
+22
-12
@@ -1,29 +1,39 @@
|
||||
"""
|
||||
Global configuration of the project.
|
||||
All hardcoded pathes should be (theoretically) here.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
MYDIR = os.path.abspath(os.path.dirname( os.path.dirname('__file__') ))
|
||||
MYDIR = os.path.abspath(os.path.dirname(os.path.dirname('__file__')))
|
||||
|
||||
ANSI2HTML = os.path.join( MYDIR, "share/ansi2html.sh" )
|
||||
ANSI2HTML = os.path.join(MYDIR, "share/ansi2html.sh")
|
||||
|
||||
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' )
|
||||
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')
|
||||
|
||||
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/"
|
||||
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/"
|
||||
PATH_CHEAT_SHEETS_SPOOL = "/home/igor/cheat.sheets/spool/"
|
||||
|
||||
def error(text):
|
||||
"""
|
||||
Log error `text` and produce a RuntimeError exception
|
||||
"""
|
||||
if not text.startswith('Too many queries'):
|
||||
print text
|
||||
logging.error("ERROR "+text)
|
||||
logging.error("ERROR %s", text)
|
||||
raise RuntimeError(text)
|
||||
|
||||
def log(text):
|
||||
"""
|
||||
Log error `text` (if it does not start with 'Too many queries')
|
||||
"""
|
||||
if not text.startswith('Too many queries'):
|
||||
print text
|
||||
logging.info(text)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user