mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Adds Errors handling in GUI
This commit is contained in:
@@ -48,8 +48,7 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
Trigerred by IvolutionWindow.
|
||||
Uses the Observer pattern to inform the user about the progress of the GUI.
|
||||
"""
|
||||
if len(message) == 1:
|
||||
# system commands
|
||||
if len(message) == 1: # system commands
|
||||
if message[0] == "STOP":
|
||||
self.console_logger.debug("Facemovie is going to stop")
|
||||
self.my_logger.debug("Facemovie is going to stop")
|
||||
@@ -61,13 +60,20 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
self.my_logger.debug("Unrecognized system command")
|
||||
#self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
elif len(message) == 2:
|
||||
# notifications
|
||||
elif len(message) == 2: # notifications
|
||||
|
||||
#self.console_logger.debug(message)
|
||||
self.my_logger.debug(message)
|
||||
# notify gui about small updates
|
||||
self.notify(["STATUS", message[0], message[1]])
|
||||
|
||||
# checking for fatal error
|
||||
if message[0] == "Error":
|
||||
self.console_logger.debug("Fatal Error detected")
|
||||
self.my_logger.debug("Fatal Error detected")
|
||||
self.stop_process = True
|
||||
self.notify(["STOP"])
|
||||
|
||||
else:
|
||||
self.console_logger.debug("Unrecognized command")
|
||||
self.my_logger.debug("Unrecognized command")
|
||||
|
||||
@@ -192,7 +192,6 @@ class FaceMovie(object, Observable, Observer):
|
||||
message = message_root + " %d / %d" % (num, den)
|
||||
self.notify([message, self.percent(num, den)])
|
||||
except (ArithmeticError, ZeroDivisionError):
|
||||
#pass
|
||||
self.notify(["Error", 0])
|
||||
|
||||
def clean_guys(self):
|
||||
@@ -221,7 +220,8 @@ class FaceMovie(object, Observable, Observer):
|
||||
if self.number_guys() == 0:
|
||||
self.console_logger.error("No face has been found in the whole repository! Exiting. . . ")
|
||||
self.my_logger.error("No face has been found in the whole repository! Exiting. . . ")
|
||||
sys.exit(0) # FIXME : Find better way to do that
|
||||
self.notify(["Error", 0])
|
||||
sys.exit(0)
|
||||
|
||||
# normalize faces to make them clean
|
||||
self.set_guys_ratio() # sets all faces to the same size, by calculating a ratio to a reference
|
||||
|
||||
@@ -490,6 +490,12 @@ class IvolutionWindow(wx.Frame, Observer, Observable):
|
||||
self.process_running = False
|
||||
|
||||
elif message[0] == "STATUS": # status label
|
||||
if message[1] == "Error":
|
||||
wx.MutexGuiEnter() # to avoid thread problems
|
||||
self.sb.SetStatusText("Error detected", 0)
|
||||
self.progressgauge.SetValue(0)
|
||||
wx.MutexGuiLeave()
|
||||
|
||||
wx.MutexGuiEnter() # to avoid thread problems
|
||||
self.sb.SetStatusText(message[1], 1)
|
||||
wx.MutexGuiLeave()
|
||||
|
||||
Reference in New Issue
Block a user