Implements Observer pattern into the library.

Process can be stopped any time now.

The GUI seem pretty nice and runs without errors.

TODO:
Implement a save session method
Implement GUI compatible with all oses
This commit is contained in:
2012-08-16 11:02:31 +02:00
parent 2503e3c03b
commit 89f51581cc
4 changed files with 14 additions and 3 deletions

View File

@@ -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")

View File

@@ -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.

Binary file not shown.

View File

@@ -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)