days_seen.add(formatted_date)
total = len(days_seen)
+ first_day = True
days_seen = set()
for n, date in enumerate(sorted(highs.keys())):
if n % 3 == 0:
aggregate = r + s
aggregate_precip += aggregate
precip[date].append(aggregate)
+ if first_day:
+ while len(precip[date]) < 8:
+ precip[date].insert(0, 0)
+ first_day = False
day = datetime.fromtimestamp(ts[date])
formatted_date = day.strftime("%a %e %b")
)
# Date
- f.write(
- " <tr><td colspan=3 height=50><b><center><font size=6>"
- + formatted_date
- + "</font></center></b></td></tr>\n"
- )
+ f.write(f'''
+<tr>
+ <td colspan=3 height=50>
+ <center>
+ <font size=7><b>{formatted_date}</b></font>
+ </center>
+ </td>
+</tr>''')
# Conditions icon
- f.write(
- ' <tr><td colspan=3 height=100><center><img src="/kiosk/images/weather/%s" height=125></center></td></tr>\n'
- % self.pick_icon(conditions[date], rain[date], snow[date])
- )
+ icon = self.pick_icon(conditions[date], rain[date], snow[date])
+ f.write(f'''
+<tr>
+ <td colspan=3 height=100>
+ <center>
+ <img src="/kiosk/images/weather/{icon}" height=145>
+ </center>
+ </td>
+</tr>''')
- # Low temp
+ # Low temp -- left
color = "#000099"
if lows[date] <= 32.5:
color = "#009999"
f.write(f'''
<tr>
<td width=33% align=left>
- <font color="{color}">
+ <font color="{color}" size=6>
<b>{int(lows[date])}°F </b>
</font>
</td>
f.write(f'''
<td width=33%>
<center>
- <font style="background-color:#dfdfff; color:#003355">
- <b>{aggregate_precip:3.1f}"</b>
+ <font style="background-color:#dfdfff; color:#003355" size=6>
+ <b>{aggregate_precip:3.1f}”</b>
</font>
</center>
</td>
color = "#AA0000"
f.write(f'''
<td align=right>
- <font color="{color}">
+ <font color="{color}" size=6>
<b> {int(highs[date])}°F</b>
</font>
</td>
-</tr>
+</tr>''')
+
+ # Precip graph
+ f.write(f'''
<tr>
<td colspan=3 style="vertical-align:top;">
- <canvas id="myChart{n}" style="width:100%;max-width:300px"></canvas>
+ <canvas id="myChart{n}" style="width:100%;max-width:400px;height:180px;"></canvas>
</td>
</tr>
<script>