mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Warns user when no image found, or source folder not found. Avoids ugly error
This commit is contained in:
@@ -92,7 +92,15 @@ class FacemovieThread(threading.Thread, Observable, Observer):
|
||||
|
||||
self.my_logger.debug("Listing pictures")
|
||||
self.notify(["Interface", ["PROGRESS", "Listing pictures", 0.0]])
|
||||
self.facemovie.list_guys()
|
||||
num_guys = self.facemovie.list_guys()
|
||||
|
||||
# FIXME: Later to be done in Lib
|
||||
if num_guys < 0:
|
||||
self.notify(["Interface", ["STATUS", "Source folder not found", 0.0]])
|
||||
self.stop_process = True
|
||||
elif num_guys == 0:
|
||||
self.notify(["Interface", ["STATUS", "No image found in source folder", 0.0]])
|
||||
self.stop_process = True
|
||||
|
||||
if not self.stop_process:
|
||||
self.my_logger.debug("Detecting Faces")
|
||||
|
||||
@@ -91,7 +91,10 @@ class FaceMovie(object, Observable, Observer):
|
||||
except: # find precise exception
|
||||
#self.console_logger.critical("Source folder not found ! Exiting. . .")
|
||||
self.my_logger.critical("Source folder not found ! Exiting. . .")
|
||||
sys.exit(0)
|
||||
|
||||
self.run = False
|
||||
#sys.exit(0)
|
||||
return -1
|
||||
|
||||
# loading images, create Guys and store it into guys
|
||||
ptr = 0
|
||||
@@ -126,9 +129,13 @@ class FaceMovie(object, Observable, Observer):
|
||||
#self.console_logger.info("Skipping %s. Not an image file" % (guy_source))
|
||||
self.my_logger.info("Skipping %s. Not an image file" % (guy_source))
|
||||
|
||||
self.sort_guys()
|
||||
##self.console_logger.info("%d guys found in source folder." % (self.number_guys()))
|
||||
self.my_logger.info("%d guys found in source folder." % (self.number_guys()))
|
||||
# Checking if we have at least one image
|
||||
if self.number_guys > 0:
|
||||
self.sort_guys()
|
||||
##self.console_logger.info("%d guys found in source folder." % (self.number_guys()))
|
||||
self.my_logger.info("%d guys found in source folder." % (self.number_guys()))
|
||||
|
||||
return self.number_guys()
|
||||
|
||||
def sort_guys(self):
|
||||
"""
|
||||
|
||||
@@ -275,7 +275,7 @@ either expressed or implied, of the FreeBSD Project."""
|
||||
self.my_logger.setLevel(logging.DEBUG)
|
||||
# create file handler which logs even debug messages
|
||||
|
||||
#fh = logging.StreamHandler()
|
||||
#fh = logging.StreamHandler() # uncomment here for console output
|
||||
fh = logging.FileHandler(log_file)
|
||||
|
||||
fh.setLevel(logging.DEBUG)
|
||||
@@ -283,7 +283,7 @@ either expressed or implied, of the FreeBSD Project."""
|
||||
#self.console_logger = logging.getLogger('ConsoleLog')
|
||||
#self.console_logger.setLevel(logging.DEBUG) # not needed
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
#ch = logging.StreamHandler()
|
||||
#ch.setLevel(logging.DEBUG) # not needed
|
||||
|
||||
# add the handlers to the logger
|
||||
|
||||
Reference in New Issue
Block a user