]> Devi Nivas Git - 4180kiosk.git/commitdiff
Add OH schedule
authorAdvaith Menon <noreply-git@bp4k.net>
Sat, 31 Jan 2026 00:09:25 +0000 (19:09 -0500)
committerAdvaith Menon <noreply-git@bp4k.net>
Sat, 31 Jan 2026 00:09:25 +0000 (19:09 -0500)
default_confs/site.conf
ohdisp/model.py

index c3f4bfc1a8fb848f0d300cf4fc1c56ca19a3d5a4..78e5e1c405908ca7de3b8806558302d63ddd4e29 100644 (file)
@@ -6,9 +6,11 @@ queue_title = Queue
 
 nobody_avatar = default_confs/pictures/placeholder.png
 
+oh_start = 09:00
+oh_end = 18:30
+
 ; Actual conf
 api_path_q = https://proxyembedded.bp4k.net/4180q.py
 api_q_element = queue.checkoffQueue,queue.helpQueue
 
 
-api_key = doesnt-matter
index 7246cea20c1fcfe64571d5f8c7b2e51da41d9261..016a1d6dee1fc58027c8f99b4b4a612e7dab1308 100644 (file)
@@ -20,6 +20,13 @@ class QueueModel(object):
         self._cfg = config;
         self._funcs = tuple(self.parse_cfg(self._cfg.site.api_q_element));
 
+        self.oh_start = datetime.time.strptime(
+                self._cfg.site.oh_start,
+                "%H:%M");
+        self.oh_end = datetime.time.strptime(
+                self._cfg.site.oh_end,
+                "%H:%M");
+
     def fetch(self):
         resp = urllib3.request(
                 "GET",
@@ -52,15 +59,43 @@ class QueueModel(object):
         cur_students = [];
         self.build_elements(cur_students, tk_parent);
         while True:
-            students = self.fetch();
-            nu_students = len(students);
-            d = self.diff_students(cur_students, students);
-            if len(d[1]):
-                self.build_elements(students, tk_parent);
-                self.announce(d);
-            n_students = nu_students;
-            cur_students = students;
-            time.sleep(2);
+            cur_time = datetime.datetime.now().time()
+            if cur_time >= self.oh_start \
+                    and cur_time <= self.oh_end:
+                students = self.fetch();
+                nu_students = len(students);
+                d = self.diff_students(cur_students, students);
+                if len(d[1]):
+                    self.build_elements(students, tk_parent);
+                    self.announce(d);
+                n_students = nu_students;
+                cur_students = students;
+                time.sleep(2);
+            else:
+                for el in tk_parent.winfo_children():
+                    el.destroy()
+                null_fnt = Font(tk_parent,
+                                family=self._cfg.style.q_empty__family,
+                                size=int(self._cfg.style.q_empty__size),
+                                weight=self._cfg.style.q_empty__weight,
+                                slant=self._cfg.style.q_empty__slant,
+                                );
+
+                lbl = tk.Label(tk_parent,
+                               text=("Office Hours are closed!\n"
+                                    "Please come between office hours:\n")\
+                                   + self.oh_start.strftime("%I:%M %p") \
+                                   + " - " \
+                                   + self.oh_end.strftime("%I:%M %p"),
+                               font=null_fnt,
+                               fg=self._cfg.style.q_empty__fgcolor,
+                               bg=self._cfg.style.q_empty__bgcolor,
+                               padx=4,
+                               pady=4,
+                               anchor='n'
+                               );
+                lbl.pack(side='top', fill='x', anchor='n', expand=1);
+                time.sleep(60);
 
     def announce(self, data):
         new_joinees, d = data