diff --git a/python_apps/media-monitor/airtimefilemonitor/replaygain.py b/python_apps/media-monitor/airtimefilemonitor/replaygain.py index c41f3308d..cc0f148f9 100644 --- a/python_apps/media-monitor/airtimefilemonitor/replaygain.py +++ b/python_apps/media-monitor/airtimefilemonitor/replaygain.py @@ -13,7 +13,7 @@ def get_process_output(command): """ Run subprocess and return stdout """ - logger.debug(command) + #logger.debug(command) p = Popen(command, shell=True, stdout=PIPE) return p.communicate()[0].strip() @@ -40,7 +40,7 @@ def duplicate_file(file_path): fsrc = open(file_path, 'r') fdst = tempfile.NamedTemporaryFile(delete=False) - logger.info("Copying %s to %s" % (file_path, fdst.name)) + #logger.info("Copying %s to %s" % (file_path, fdst.name)) shutil.copyfileobj(fsrc, fdst) diff --git a/python_apps/media-monitor2/media/monitor/handler.py b/python_apps/media-monitor2/media/monitor/handler.py index 3afef8ffc..78d954b99 100644 --- a/python_apps/media-monitor2/media/monitor/handler.py +++ b/python_apps/media-monitor2/media/monitor/handler.py @@ -16,14 +16,15 @@ class Handles(object): class ReportHandler(Handles): __metaclass__ = abc.ABCMeta - def __init__(self, signal): + def __init__(self, signal, weak=False): self.signal = signal self.report_signal = "badfile" def dummy(sender, event): self.handle(sender,event) dispatcher.connect(dummy, signal=signal, sender=dispatcher.Any, - weak=False) + weak=weak) def report_problem_file(self, event, exception=None): + import ipdb; ipdb.set_trace() dispatcher.send(signal=self.report_signal, sender=self, event=event, exception=exception) diff --git a/python_apps/media-monitor2/media/monitor/listeners.py b/python_apps/media-monitor2/media/monitor/listeners.py index 07b31e105..b5cb4fc9f 100644 --- a/python_apps/media-monitor2/media/monitor/listeners.py +++ b/python_apps/media-monitor2/media/monitor/listeners.py @@ -85,13 +85,17 @@ class BaseListener(object): class OrganizeListener(BaseListener, pyinotify.ProcessEvent, Loggable): # this class still don't handle the case where a dir was copied recursively - def process_IN_CLOSE_WRITE(self, event): self.process_to_organize(event) + def process_IN_CLOSE_WRITE(self, event): + self.process_to_organize(event) # got cookie - def process_IN_MOVED_TO(self, event): self.process_to_organize(event) + def process_IN_MOVED_TO(self, event): + self.process_to_organize(event) def flush_events(self, path): - """organize the whole directory at path. (pretty much by doing what - handle does to every file""" + """ + organize the whole directory at path. (pretty much by doing what + handle does to every file + """ flushed = 0 for f in mmp.walk_supported(path, clean_empties=True): self.logger.info("Bootstrapping: File in 'organize' directory: \ @@ -104,6 +108,8 @@ class OrganizeListener(BaseListener, pyinotify.ProcessEvent, Loggable): @mediate_ignored @IncludeOnly(mmp.supported_extensions) def process_to_organize(self, event): + print("I AM COMPLETELY INNOCENT") + import ipdb; ipdb.set_trace() dispatcher.send(signal=self.signal, sender=self, event=OrganizeFile(event)) diff --git a/python_apps/media-monitor2/media/monitor/organizer.py b/python_apps/media-monitor2/media/monitor/organizer.py index 3f2ee808a..f014b2269 100644 --- a/python_apps/media-monitor2/media/monitor/organizer.py +++ b/python_apps/media-monitor2/media/monitor/organizer.py @@ -13,11 +13,13 @@ class Organizer(ReportHandler,Loggable): directory". The "storage" directory picks up all of its events through pyinotify. (These events are fed to it through StoreWatchListener) """ + def __init__(self, channel, target_path, recorded_path): self.channel = channel self.target_path = target_path self.recorded_path = recorded_path - super(Organizer, self).__init__(signal=self.channel) + super(Organizer, self).__init__(signal=self.channel, weak=True) + def handle(self, sender, event): """ Intercept events where a new file has been added to the organize @@ -28,6 +30,7 @@ class Organizer(ReportHandler,Loggable): # We must select the target_path based on whether file was recorded # by airtime or not. # Do we need to "massage" the path using mmp.organized_path? + print("Organizing: %s" % event.path) target_path = self.recorded_path if event.metadata.is_recorded() \ else self.target_path new_path = mmp.organized_path(event.path, target_path, @@ -39,5 +42,6 @@ class Organizer(ReportHandler,Loggable): self.report_problem_file(event=event, exception=e) # probably general error in mmp.magic.move... except Exception as e: + self.unexpected_exception( e ) self.report_problem_file(event=event, exception=e) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index 6eb5b5e81..baeb47a80 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -11,7 +11,7 @@ import locale from media.monitor.exceptions import FailedToSetLocale, FailedToCreateDir -supported_extensions = [u"mp3", u"ogg"] +supported_extensions = [u"mp3", u"ogg", u"oga"] unicode_unknown = u'unknown' class LazyProperty(object): @@ -31,8 +31,8 @@ class LazyProperty(object): class IncludeOnly(object): """ - A little decorator to help listeners only be called on extensions they - support + A little decorator to help listeners only be called on extensions + they support NOTE: this decorator only works on methods and not functions. Maybe fix this? """ @@ -138,6 +138,7 @@ def magic_move(old, new): Moves path old to new and constructs the necessary to directories for new along the way """ + print("'%s' ==> '%s'" % (old, new)) new_dir = os.path.dirname(new) if not os.path.exists(new_dir): os.makedirs(new_dir) shutil.move(old,new)