Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added getWeather(location). Hu records the weather now.

  • Loading branch information...
commit e835323e0740e43fd0d411668b1faa8d14aef650 1 parent 9f44d16
@scottjacksonx authored
Showing with 30 additions and 1 deletion.
  1. +30 −1 hu.py
View
31 hu.py
@@ -1 +1,30 @@
-print "Spoiler alert: I'm a demon."
+import pywapi
+import time
+
+print "Spoiler alert: I'm a demon."
+
+def getWeather(location):
+ """
+ Gets the weather from Google.
+ """
+ googleWeather = pywapi.get_weather_from_google(location)
+ condition = googleWeather['current_conditions']['condition']
+ temp = googleWeather['current_conditions']['temp_c']
+ return "Weather: " + condition + ", " + temp + "c" + "\n"
+
+def takeSnapshot():
+ """
+ Makes a new file named after the timestamp it was created at and records the weather.
+ """
+ # get current time.
+ currentTime = int(time.time())
+ # make and open new file for that time.
+ newFile = open("hu-notes/hu-" + str(currentTime), "w")
+ # put weather in file.
+ weather = getWeather("brisbane,australia")
+ newFile.write(weather)
+ # close the file.
+ newFile.close()
+
+takeSnapshot()
+
Please sign in to comment.
Something went wrong with that request. Please try again.