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')
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()