Only try to show !w country when it is available. closes #72
This commit is contained in:
parent
3c51348fec
commit
2ed1cf2e4a
1 changed files with 6 additions and 3 deletions
|
@ -49,8 +49,11 @@ class Module(ModuleManager.BaseModule):
|
|||
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
|
||||
if page:
|
||||
if "weather" in page.data:
|
||||
location = "%s, %s" % (page.data["name"], page.data["sys"][
|
||||
"country"])
|
||||
location_parts = [page.data["name"]]
|
||||
if "country" in page.data["sys"]:
|
||||
location_parts.append(page.data["sys"]["country"])
|
||||
location_str = ", ".join(location_parts)
|
||||
|
||||
celsius = "%dC" % page.data["main"]["temp"]
|
||||
fahrenheit = "%dF" % ((page.data["main"]["temp"]*(9/5))+32)
|
||||
description = page.data["weather"][0]["description"].title()
|
||||
|
@ -59,7 +62,7 @@ class Module(ModuleManager.BaseModule):
|
|||
|
||||
event["stdout"].write(
|
||||
"(%s) %s/%s | %s | Humidity: %s | Wind: %s" % (
|
||||
location, celsius, fahrenheit, description, humidity,
|
||||
location_str, celsius, fahrenheit, description, humidity,
|
||||
wind_speed))
|
||||
else:
|
||||
event["stderr"].write("No weather information for this location")
|
||||
|
|
Loading…
Reference in a new issue