diff --git a/ivolution/FacemovieThread.py b/ivolution/FacemovieThread.py index 27d8b57..72a97f5 100644 --- a/ivolution/FacemovieThread.py +++ b/ivolution/FacemovieThread.py @@ -39,6 +39,7 @@ class FacemovieThread(threading.Thread, Observable, Observer): self.face_params = face_params self.facemovie = Facemovie_lib.FaceMovie(self.face_params) self.facemovie.subscribe(self) # Subscribing to facemovie reports + self.subscribe(self.facemovie) # Used to send request to stop self.my_logger = logging.getLogger('FileLog') self.console_logger = logging.getLogger('ConsoleLog') @@ -55,6 +56,7 @@ class FacemovieThread(threading.Thread, Observable, Observer): self.my_logger.debug("Facemovie is going to stop") self.stop_process = True + self.notify(["STOP"]) else : self.console_logger.debug("Unrecognized system command") self.my_logger.debug("Unrecognized system command") diff --git a/ivolution/Facemovie_lib.py b/ivolution/Facemovie_lib.py index 721b03f..e430e24 100644 --- a/ivolution/Facemovie_lib.py +++ b/ivolution/Facemovie_lib.py @@ -18,8 +18,9 @@ from util import exif import Guy from util.Notifier import Observable +from util.Notifier import Observer -class FaceMovie(object, Observable): +class FaceMovie(object, Observable, Observer): ''' Main class of the whole application. Contains the core image processing functions. @@ -39,6 +40,7 @@ class FaceMovie(object, Observable): :type face_param: string """ Observable.__init__(self) # used to send notifications to process + Observer.__init__(self, "Library") # used to receive notification to stop self.console_logger = logging.getLogger('ConsoleLog') # Used to send messages to the console self.my_logger = logging.getLogger('FileLog') # Used to save events into a file @@ -84,6 +86,13 @@ class FaceMovie(object, Observable): self.run = True # command used to stop the processing if needed + def update(self, message): + """ + Used to receive system commands, using the Observer pattern + """ + if len(message) == 1: # system command + self.run = False + def list_guys(self): """ Aims at populating the guys list, using the source folder as an input. diff --git a/ivolution/data/samples/output.avi b/ivolution/data/samples/output.avi index fb2dc1a..893b5a8 100644 Binary files a/ivolution/data/samples/output.avi and b/ivolution/data/samples/output.avi differ diff --git a/ivolution/gui/IvolutionWindow.py b/ivolution/gui/IvolutionWindow.py index 2e62767..e851232 100755 --- a/ivolution/gui/IvolutionWindow.py +++ b/ivolution/gui/IvolutionWindow.py @@ -250,7 +250,7 @@ class IvolutionWindow(Observer, Observable): if float(message[2]) >= 1.0: # 100% of process self.my_logger.debug("Reached end of facemovie process") - self.console_logger.debug("Reached end of facemovie process") + #self.console_logger.debug("Reached end of facemovie process") self.process_running = False elif message[0] == "STATUS": # status label @@ -258,7 +258,7 @@ class IvolutionWindow(Observer, Observable): GLib.idle_add(self.statuslabel.set_text, message[1]) #pass - else: + elif len(message) > 1: #system commands shall be ignored self.console_logger.debug("Unrecognized command") self.my_logger.debug("Unrecognized command") self.console_logger.debug(message)