Example #1
0
def exit_on_error(traceback, fatal=False):
    # Note that nothing is being called on app.
    # This is because the __main__ file as a try/except/finally
    # and the finally called app.halt()
    # Since we are raising SystemExit, finally *WILL*
    # take place before the system quits. Therefore,
    # it is redundant (and dangerous since app.halt() closes files)
    # to call end twice. Therefore, when you raise SystemExit
    # app.halt() is called in the finally clause of the
    # __main__.py file
    alert = mtk.Ttk("alert win in CLS: HandleError")
    alert.title("Fatal Error")
    alertlabel = mtk.TLabel(alert,
                            text="Something went wrong and PyEdit needs to"
                                 "close.\nYou may lose unsaved changes."
                                 "\nWe Apologize for the inconvenience.")
    alerterror = mtk.TLabel(alert, text="\n\n{}\n\n".format(traceback))
    if fatal:
        alertbutton = mtk.Button(alert, text="Quit",
                                 command=pyedit_panic)
    else:
        alertbutton = mtk.Button(alert, text="Quit",
                                 command=alert.destroy)
    alertlabel.pack()
    alerterror.pack()
    alertbutton.pack()
    alert.mainloop()
Example #2
0
def failedToSend(reason):
    al = mtk.Ttk("Bug Send Error Win")
    al.geometry('200x200')
    al.title("Error")
    mtk.Label(al, text=reason).pack()
    mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack()
    al.mainloop()
Example #3
0
def sendReport(report, win):
    win.destroy()
    win.quit()

    r = requests.post('https://pyeditbugserver.herokuapp.com/bug-report',
                      json=report.toJson())
    if (r.status_code != 200):
        al = mtk.Ttk("Bug Send Error Win")
        al.title("Error")
        mtk.Label(al, text=r.reason).pack()
        mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack()
        al.mainloop()
    else:
        al = mtk.Ttk("Bug Report Successfully Sent")
        al.title("Success!")
        mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack()
        al.mainloop()
Example #4
0
def failedToSend(reason):
    al = mtk.Ttk("Bug Send Error Win")
    al.geometry('600x600')
    al.title("Error")
    t = mtk.Text(al,width=500, height=500, wrap=word)
    t.insert(0.0, reason)
    t.pack()
    mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack()
    al.mainloop()
Example #5
0
def askToSubmitBugs(name, steps, info, app, br):
    br.quit()
    _name = name.get()
    _steps = steps.get(0.0, mtk.END)
    _info = info.get(0.0, mtk.END)
    br.destroy()
    error_report = writeBugReport(_name, _steps, _info, app)
    tosend = mtk.Ttk("To Send")
    tosend.title("Bug Report")
    mtk.TLabel(tosend,
               text="The following information will be submitted \n"
                    "(no personally identifiable information is sent) ").pack()
    a = mtk.Text(tosend, width=125, height=30)
    a.insert(0.0, error_report)
    a.pack()
    can = mtk.Button(tosend, text='Cancel', command=lambda: quitWin(tosend))
    can.pack()
    qu = mtk.Button(tosend, text="Go",
                    command=lambda: sendReport(error_report, tosend))
    qu.pack()
    tosend.mainloop()
Example #6
0
def sendReport(report, win):
    win.destroy()
    win.quit()

    if os.environ['PY_EDIT_DEBUG']:
        r = requests.post('http://localhost:8099/bug-report', json=report.toJson());
    else:
        r = requests.post('https://pyeditbugserver.herokuapp.com/bug-report', json=report.toJson())
    if (r.status_code != 200):
        al = mtk.Ttk("Bug Send Error Win")
        al.geometry('200x200')
        al.title("Error")
        mtk.Label(al,
                  text=r.reason).pack()
        mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack()
        al.mainloop()
    else:
        al = mtk.Ttk("Bug Report Successfully Sent")
        al.geometry('200x200')
        al.title("Success!")
        mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack()
        al.mainloop()
Example #7
0
def askForBugs(app):
    """Dependent on <app> argument being PyEdit. Not a good repurpose"""
    bug_report = mtk.Ttk("Bug Report")
    bug_report.protocol("WM_DELETE_WINDOW", lambda: quitWin(bug_report))
    bug_report.title("Submit a Bug")
    mtk.TLabel(bug_report, text="Enter a name: ").pack()
    name = mtk.Entry(bug_report)
    name.pack()
    mtk.TLabel(bug_report,
               text="Describe the steps to recreate the bug: ").pack()
    steps = mtk.Text(bug_report, width=40, height=10)
    steps.pack()
    mtk.TLabel(bug_report,
               text="Include any other additional"
                    "information that could help: ").pack()
    info = mtk.Text(bug_report, width=40, height=10)
    info.pack()
    qu = mtk.Button(bug_report, text="Next...",
                    command=lambda: askToSubmitBugs(name, steps, info, app,
                                                    bug_report))
    qu.pack()
    bug_report.mainloop()
Example #8
0
def sendReport(report, win):
    win.destroy()
    win.quit()

    try:
        if os.environ['PY_EDIT_DEBUG']:
            r = requests.post('http://localhost:8099/bug-report',
                              json=report.toJson())
        else:
            r = requests.post(
                'https://pyeditbugserver.herokuapp.com/bug-report', json=report.toJson())
    except Exception as e:
        failedToSend("{}: {}".format(type(e), e.args[0]))
        return

    if (r.status_code != 200):
        failedToSend(r.reason)
    else:
        al = mtk.Ttk("Bug Report Successfully Sent")
        al.geometry('200x200')
        al.title("Success!")
        mtk.Button(al, text='ok', command=lambda: quitWin(al)).pack()
        al.mainloop()