mirror of
https://github.com/chubin/wttr.in
synced 2024-12-26 11:43:08 +00:00
globals.py clean up
This commit is contained in:
parent
ed52219acd
commit
eb8b1cc92d
1 changed files with 27 additions and 18 deletions
|
@ -1,3 +1,7 @@
|
|||
"""
|
||||
global configuration of the project
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
@ -33,6 +37,8 @@ MALFORMED_RESPONSE_HTML_PAGE = open(os.path.join(STATIC, 'malformed-response.htm
|
|||
LISTEN_HOST = ""
|
||||
LISTEN_PORT = 8002
|
||||
|
||||
MY_EXTERNAL_IP = '5.9.243.187'
|
||||
|
||||
PLAIN_TEXT_AGENTS = [
|
||||
"curl",
|
||||
"httpie",
|
||||
|
@ -46,21 +52,24 @@ PLAIN_TEXT_PAGES = [':help', ':bash.function', ':translation']
|
|||
IP2LOCATION_KEY = ''
|
||||
|
||||
def error(text):
|
||||
"log error `text` and raise 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` and do not raise any exceptions"
|
||||
|
||||
if not text.startswith('Too many queries'):
|
||||
print text
|
||||
logging.info(text)
|
||||
|
||||
def get_help_file(lang):
|
||||
"Return help file for `lang`"
|
||||
|
||||
help_file = os.path.join(MYDIR, 'share/translations/%s-help.txt' % lang)
|
||||
print ">>>", help_file
|
||||
if os.path.exists(help_file):
|
||||
return help_file
|
||||
else:
|
||||
return HELP_FILE
|
||||
|
||||
|
|
Loading…
Reference in a new issue