)
return True
except Exception as e:
+ logger.exception(e)
print("********* TRYING TO REFRESH GCAL CLIENT *********")
# self.oauth.refresh_token()
# self.client = self.oauth.calendar_service()
return False
- except:
- raise
def look_for_triggered_events(self) -> bool:
with file_writer.file_writer(constants.gcal_imminent_pagename) as f:
for event in self.sortable_events:
eventstamp = event.start_time
if eventstamp is None:
- return False
+ continue
delta = eventstamp - now
x = int(delta.total_seconds())
- if x > 0 and x <= constants.seconds_per_minute * 3:
+ if x > -120 and x < 4 * constants.seconds_per_minute:
days = divmod(x, constants.seconds_per_day)
hours = divmod(days[1], constants.seconds_per_hour)
minutes = divmod(hours[1], constants.seconds_per_minute)
contents = contents.replace(
"\u2610 ", '<LI><INPUT TYPE="checkbox"> '
)
- contents = linkify.sub(r'<a href="\1">\1</a>', contents)
+ #contents = linkify.sub(r'<a href="\1">\1</a>', contents)
individual_lines = contents.split("\n")
num_lines = len(individual_lines)
# Test
+#logger.setLevel(logging.DEBUG)
+#ch = logging.StreamHandler()
+#ch.setLevel(logging.DEBUG)
+#formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+#ch.setFormatter(formatter)
+#logger.addHandler(ch)
#x = gkeep_renderer({"Test", 1234})
#x.periodic_render("Test")
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>
return True
-#x = weather_renderer({"Stevens": 1000}, "stevens")
-#x.periodic_render("Stevens")
+x = weather_renderer({"Stevens": 1000}, "stevens")
+x.periodic_render("Stevens")