From 4bbbdaca7bf505960de350e2f2eceb135a2efb53 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 1 Feb 2019 12:14:01 +0100 Subject: [PATCH] T support for /Moon (fixes #175) --- lib/wttr.py | 8 +++++++- lib/wttr_srv.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/wttr.py b/lib/wttr.py index aadf59c..13cb9c7 100644 --- a/lib/wttr.py +++ b/lib/wttr.py @@ -207,7 +207,10 @@ def get_wetter(location, ip, html=False, lang=None, query=None, location_name=No return open(filename).read() -def get_moon(location, html=False, lang=None): +def get_moon(location, html=False, lang=None, query=None): + if query is None: + query = {} + date = None if '@' in location: date = location[location.index('@')+1:] @@ -228,6 +231,9 @@ def get_moon(location, html=False, lang=None): p = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env) stdout = p.communicate()[0] + if query.get('no-terminal', False): + stdout = remove_ansi(stdout) + if html: p = Popen(["bash", ANSI2HTML, "--palette=solarized", "--bg=dark"], stdin=PIPE, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate(stdout) diff --git a/lib/wttr_srv.py b/lib/wttr_srv.py index adef8c2..51f4d2a 100644 --- a/lib/wttr_srv.py +++ b/lib/wttr_srv.py @@ -230,7 +230,7 @@ def wttr(location, request): return response if location == 'moon' or location.startswith('moon@'): - output = get_moon(location, html=html_output, lang=lang) + output = get_moon(location, html=html_output, lang=lang, query=query) else: output = get_wetter(location, ip_addr, html=html_output,