minor fixes

pull/387/head
Igor Chubin 5 years ago
parent 4986f92592
commit b1ea9be11f

@ -63,7 +63,6 @@ def load_translations():
return translations return translations
TRANSLATIONS = load_translations() TRANSLATIONS = load_translations()
def _find_srv_for_query(path, query): # pylint: disable=unused-argument def _find_srv_for_query(path, query): # pylint: disable=unused-argument
return 'http://api.worldweatheronline.com' return 'http://api.worldweatheronline.com'
@ -206,8 +205,8 @@ def proxy(path):
if response: if response:
headers = {} headers = {}
headers['Content-Type'] = response.headers['content-type'] headers['Content-Type'] = response.headers['content-type']
_save_content_and_headers(path, query_string, response.content, headers)
content = add_translations(response.content, lang) content = add_translations(response.content, lang)
_save_content_and_headers(path, query_string, content, headers)
else: else:
content = "{}" content = "{}"

@ -301,14 +301,14 @@ def wttr(location, request):
return _wrap_response(output, html_output) return _wrap_response(output, html_output)
except RuntimeError as exception: except Exception as exception:
if 'Malformed response' in str(exception) \ # if 'Malformed response' in str(exception) \
or 'API key has reached calls per day allowed limit' in str(exception): # or 'API key has reached calls per day allowed limit' in str(exception):
if html_output: if html_output:
return _wrap_response(MALFORMED_RESPONSE_HTML_PAGE, html_output) return _wrap_response(MALFORMED_RESPONSE_HTML_PAGE, html_output)
return _wrap_response(get_message('CAPACITY_LIMIT_REACHED', lang).encode('utf-8'), html_output) return _wrap_response(get_message('CAPACITY_LIMIT_REACHED', lang).encode('utf-8'), html_output)
logging.error("Exception has occured", exc_info=1) # logging.error("Exception has occured", exc_info=1)
return "ERROR" # return "ERROR"
if __name__ == "__main__": if __name__ == "__main__":
import doctest import doctest

Loading…
Cancel
Save