Blender-Pipeline/troubleshooter/error_notify.py

85 lines
2.3 KiB
Python
Raw Normal View History

2021-05-10 21:57:03 +02:00
####################################
# #
# COPYRIGHT NOTICE #
# #
# This file is a part of Victori- #
# ous Children Studio Organizer. #
# Or simply VCStudio. Copyright #
# of J.Y.Amihud. But don't be sad #
# because I released the entire #
# project under a GNU GPL license. #
# You may use Version 3 or later. #
# See www.gnu.org/licenses if your #
# copy has no License file. Please #
# note. Ones I used the GPL v2 for #
# it. It's no longer the case. #
# #
####################################
import os
import sys
import traceback
from settings import oscalls
# We gonna have this show run when ever any mistake is caught when running
# the UI. The concept is to give users an easy to understand UI message what
# an arror had happened.
# The main problem is that if the UI is not loading it will give an error
# too. Meaning that we need to deal with this kind of error too.
def show():
# Printing the message of the python error
message = str(traceback.format_exc())
print(message)
# Parsing the message to get the filename of the last file that had
# an issue. Hope you know a better way of doing it. I spent a whole
# day trying to come up with a way.
Filename = "run.py"
for i in message.split("\n"):
if 'File "' in i:
Filename = i[i.find('"')+1:i.replace('"'," ",1).find('"')]
# trying to do this with a window
try:
from gi.repository import Gtk
# If we are able to access the
dialogWindow = Gtk.MessageDialog(
#transient_for=self,
flags=0,
message_type=Gtk.MessageType.WARNING,
buttons=("Edit Source",1, "Report Bug", 2, "Ignore", 3),
text="BUG :(\n\n"+message,
)
response = dialogWindow.run()
# Now we want to do something with what the user decides.
if response == 1:
oscalls.Open(Filename) # Edit source open the error file in
# the text editor
elif response == 2:
oscalls.Open("https://notabug.org/jyamihud/VCStudio/issues")
dialogWindow.destroy()
except:
raise