From bb17342b063afea42df5f567f6ac88a27f4dd974 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sat, 4 Apr 2020 14:22:26 +0200 Subject: [PATCH] import view, import format --- lib/wttr.py | 4 ++-- lib/wttr_srv.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/wttr.py b/lib/wttr.py index a1982dc..c9c33c8 100644 --- a/lib/wttr.py +++ b/lib/wttr.py @@ -194,7 +194,7 @@ def get_wetter(location, ip, html=False, lang=None, query=None, location_name=No cmd += ["--bg=dark"] p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE ) - stdout, stderr = p.communicate(stdout) + stdout, stderr = p.communicate(stdout.encode("utf-8")) stdout = stdout.decode("utf-8") stderr = stderr.decode("utf-8") if p.returncode != 0: @@ -238,8 +238,8 @@ def get_moon(location, html=False, lang=None, query=None): if lang: env['LANG'] = lang p = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env) - stdout = stdout.decode("utf-8") stdout = p.communicate()[0] + stdout = stdout.decode("utf-8") if query.get('no-terminal', False): stdout = remove_ansi(stdout) diff --git a/lib/wttr_srv.py b/lib/wttr_srv.py index 802dafe..547b65f 100644 --- a/lib/wttr_srv.py +++ b/lib/wttr_srv.py @@ -10,7 +10,7 @@ import os import time from flask import render_template, send_file, make_response -import wttrin_png +import format.png import parse_query from translations import get_message, FULL_TRANSLATION, PARTIAL_TRANSLATION, SUPPORTED_LANGS from buttons import add_buttons @@ -23,7 +23,7 @@ from globals import get_help_file, log, \ from location import is_location_blocked, location_processing from limits import Limits from wttr import get_wetter, get_moon -from wttr_line import wttr_line +from view.line import wttr_line import cache @@ -266,7 +266,7 @@ def wttr(location, request): 'location': location} options.update(query) - cached_png_file = wttrin_png.make_wttr_in_png(png_filename, options=options) + cached_png_file = format.png.make_wttr_in_png(png_filename, options=options) response = make_response(send_file(cached_png_file, attachment_filename=png_filename, mimetype='image/png'))