Changes.
authorScott Gasch <[email protected]>
Thu, 24 Feb 2022 17:25:45 +0000 (09:25 -0800)
committerScott Gasch <[email protected]>
Thu, 24 Feb 2022 17:25:45 +0000 (09:25 -0800)
gcal_renderer.py
gkeep_renderer.py
kiosk.py
weather_renderer.py

index 19b818d8ad3309890eff6ef0d7f7b4b21ba63aed..edb9546e6a35980a2a225c56d1b6c947ff81ca3a 100644 (file)
@@ -342,12 +342,11 @@ var fn = setInterval(function() {
                 )
             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:
@@ -358,10 +357,10 @@ var fn = setInterval(function() {
             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)
index 443abc10e8e4c89a1037c3dc88a0fa9e234e0eb1..d7765c8a32950a3d21bfb7d71536f9731e3b418e 100644 (file)
@@ -65,7 +65,7 @@ class gkeep_renderer(renderer.abstaining_renderer):
                 contents = contents.replace(
                     "\u2610 ", '<LI><INPUT TYPE="checkbox">&nbsp;'
                 )
-                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)
@@ -141,5 +141,11 @@ class gkeep_renderer(renderer.abstaining_renderer):
 
 
 # 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")
index 99d40c30b7f7ebbf427d54d5adef02f7bdf7dc29..13fb2c95e824abb9dd8ca2839e5fdcd66ac04b74 100755 (executable)
--- a/kiosk.py
+++ b/kiosk.py
@@ -362,6 +362,7 @@ def emit_wrapped(f,
 <HEAD>
   <TITLE>Kitchen Kiosk</TITLE>
   <LINK rel="stylesheet" type="text/css" href="style.css">
+  <meta name="google" content="notranslate">
   <SCRIPT TYPE="text/javascript">
 
   // Zoom the 'contents' div to fit without scrollbars and then make
index 4a5663cfb612469b3890a2cb0a5be68b6a639a1d..c72a8620cc3f1f9b5ef7f22be8adc0f89a0ea11c 100644 (file)
@@ -246,6 +246,7 @@ function makePrecipChart(name, xValues, yValues) {
                 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:
@@ -264,6 +265,10 @@ function makePrecipChart(name, xValues, yValues) {
                     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")
@@ -275,26 +280,34 @@ function makePrecipChart(name, xValues, yValues) {
                 )
 
                 # 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])}&deg;F&nbsp;&nbsp;</b>
     </font>
   </td>
@@ -306,8 +319,8 @@ function makePrecipChart(name, xValues, yValues) {
                     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}&#8221;</b>
       </font>
     </center>
   </td>
@@ -321,14 +334,17 @@ function makePrecipChart(name, xValues, yValues) {
                     color = "#AA0000"
                 f.write(f'''
   <td align=right>
-    <font color="{color}">
+    <font color="{color}" size=6>
       <b>&nbsp;&nbsp;{int(highs[date])}&deg;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>
@@ -345,5 +361,5 @@ makePrecipChart("myChart{n}", xValues{n}, yValues{n});
         return True
 
 
-#x = weather_renderer({"Stevens": 1000}, "stevens")
-#x.periodic_render("Stevens")
+x = weather_renderer({"Stevens": 1000}, "stevens")
+x.periodic_render("Stevens")