From: Advaith Menon Date: Fri, 30 Jan 2026 23:35:51 +0000 (-0500) Subject: Add S3 exception dialog X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=82a5d2e8990e118a8e5cf9a5f30f0cfe46425079;p=4180kiosk.git Add S3 exception dialog --- diff --git a/ohdisp/exception_dialog.py b/ohdisp/exception_dialog.py index 5bbdafc..6659745 100644 --- a/ohdisp/exception_dialog.py +++ b/ohdisp/exception_dialog.py @@ -1,22 +1,31 @@ import os import sys import threading +import time +import uuid import tkinter as tk from tkinter import messagebox +from tkinter import simpledialog from tkinter.font import Font +import urllib3 + class ExceptionDialog(tk.Toplevel): def __init__(self, parent, txt, *args, **kwargs): super().__init__(parent, *args, **kwargs); self.title("Unhandled Exception"); - self.attributes("-topmost", True); + # self.attributes("-topmost", True); + # self.grab_set() self.wm_protocol("WM_DELETE_WINDOW", self.destroy) + self.ex_txt = txt + tit_lbl = tk.Label(self, text=("An unhandled exception has occured!\n" - "Send a screenshot to advaith@gatech.edu\n" + "Try uploading logs to S3\n" + "If that fails, Send a screenshot to advaith@gatech.edu\n" "Press Quit to quit/restart the " "application."), anchor='w', padx=2, pady=2, justify='left') @@ -45,6 +54,41 @@ class ExceptionDialog(tk.Toplevel): padx=5, pady=5) self.expand_btn.pack(side='right') + self.upload_btn = tk.Button(self, text="Upload to S3", + command=self.w_upload_to_s3, + padx=5, pady=5); + self.upload_btn.pack(side='right') + def w_maximize(self): self.state("zoomed"); self.expand_btn.destroy(); + + def w_upload_to_s3(self): + filename = hex(uuid.getnode())[2:].upper() \ + + "-" + str(time.time()) \ + + "-" + uuid.uuid4().hex \ + + ".txt"; + comment = "" + while not comment: + comment = simpledialog.askstring("Unhandled Exception", + "Enter what last happened.\n" + "This includes anything that was said and heard."); + + try: + urllib3.request("PUT", + "https://w94n7w8zq5.execute-api.us-east-1.amazonaws.com/dev/" + + filename, + body="User comment: {}\n\n\n{}".format(comment, + self.ex_txt), + headers={"Content-Type": "text/plain"}) + except: + messagebox.showerror("Upload Failed", + "Upload Failed.\n" + "Send a screenshot to advaith@gatech.edu " + "instead"); + else: + messagebox.showinfo("Upload Success", + "Uploaded to:\n" + filename + + "\nPlease send this name to advaith@gatech.edu"); + finally: + self.upload_btn.destroy() diff --git a/ohdisp/views.py b/ohdisp/views.py index cfb35c0..6c6e31f 100644 --- a/ohdisp/views.py +++ b/ohdisp/views.py @@ -1,6 +1,7 @@ import os import sys import threading +import traceback import tkinter as tk from tkinter import messagebox