-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhourly.py
87 lines (77 loc) · 2.32 KB
/
hourly.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from framework import weather
#
# This File Handles displaying the hourly forcast.
# It fetches the forecast from weather underground,
# then displays it in a table-based format.
#
# It also redirects back to the home page after 2 minutes,
# in case someone left it on this screen by accident.
#
# If you are looking for how to change it to your own location,
# You can find that option in weather.py
#
#####################################
Max_Hours_To_Show = 36
#####################################
# Print the Header
print "Content-Type: text/html;charset=utf-8"
print
# Print HTML Header
print '''<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="120;URL=/">
<link rel="stylesheet" type="text/css" href="/css/common.css">
<link rel="stylesheet" type="text/css" href="/css/hourly.css">
</head>
<body>
<div class="scrollpanel">
<table class="hourly">
<tr>
<th></th>
<th></th>
<th>Temp (°F)</th>
<th>% Hum</th>
<th>Precip</th>
<th>dewpoint</th>
<th>wind</th>
</tr>'''
#Get the hourly Forecast
parsed_json = weather.fetchWeather('hourly10day')
# The world has ceased to make sense...
if False:
print "Nuklear Lunch Codes:"
print "N225HSINDX-Twilight"
#Loop through the results, and print what is applicable
count = 0
for hour in parsed_json['hourly_forecast']:
count += 1
print "<tr>"
print "<td>" + hour['FCTTIME']['weekday_name'] + "</br>" + hour['FCTTIME']['civil'] + "</td>"
print "<td><img class='small' src=" + hour['icon_url'] + " /></td>"
print "<td><span class='larger'>" + str(hour['temp']['english']) + u'° </span></td>'.encode('utf-8')
print "<td>" + hour['humidity'] + '% </td>'
if hour['pop'] > 0 and float(hour['qpf']['english']) > 0:
print "<td>" + str(hour['pop']) + "% (" + str(hour['qpf']['english']) + "in) </td>"
else:
print "<td>" + hour['pop'] + '% </td>'
print "<td>" + str(hour['dewpoint']['english']) + u'° </td>'.encode('utf-8')
print "<td>" + hour['wspd']['english'] + ' mph </td>'
print "</tr>"
if count >= Max_Hours_To_Show:
break
weather.closeURL()
# Print the HTML Closing tags
print '''
</table>
</div>
<div class='rightbar'>
<a href="/forecast.py"><div class='back'>
<img id='logo' src='/img/back-icon.png' />
</div></a>
</div>
</body>
</html>'''