Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yesss #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions weather/weather.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
import pyowm
import os
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import os
import os
import sys
default_place = "Gerbrunn,de"

see suggestion below


API_key = "229c25e22cfd9c434134d5c88a1ae588"
pklaschka marked this conversation as resolved.
Show resolved Hide resolved
owm = pyowm.OWM(API_key, language='de')

owm.is_API_online()
observation = owm.weather_at_place("Gerbrunn,de")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
observation = owm.weather_at_place("Gerbrunn,de")
observation = owm.weather_at_place(sys.argv[0] if len(sys.argv) > 0 else default_place)

You can use the process arguments to search dynamically for a place and use a fallback value for missing process arguments.

w = observation.get_weather()

with open("/tmp/weather.txt", "w") as weather_file:
weather_file.write(
"{} {}°C; {}%h, Wind: {}m/s, {}°C - {}°C\n".format(
w.get_detailed_status(),
w.get_temperature(unit="celsius")["temp"],
w.get_humidity(),
w.get_wind()["speed"],
w.get_temperature(unit="celsius")["temp_min"],
w.get_temperature(unit="celsius")["temp_max"]))

weather_file.close()