mirror of
https://github.com/chubin/wttr.in.git
synced 2024-10-05 01:42:07 +02:00
T support for /Moon (fixes #175)
This commit is contained in:
parent
067be9c319
commit
4bbbdaca7b
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user