From 12e4585410ae1a59acf0f6213f06691eb7eb4a28 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 14:07:26 -0400 Subject: [PATCH 1/3] MM2: formatted some code --- python_apps/media-monitor2/media/monitor/pure.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/pure.py b/python_apps/media-monitor2/media/monitor/pure.py index 4d768b0f8..89c859ace 100644 --- a/python_apps/media-monitor2/media/monitor/pure.py +++ b/python_apps/media-monitor2/media/monitor/pure.py @@ -274,20 +274,24 @@ def organized_path(old_path, root_path, orig_md): if key in dictionary: return len(dictionary[key]) == 0 else: return True # We set some metadata elements to a default "unknown" value because we use - # these fields to create a path hence they cannot be empty - # Here "normal" means normalized only for organized path + # these fields to create a path hence they cannot be empty Here "normal" + # means normalized only for organized path + + # MDATA_KEY_BITRATE is in bytes/second i.e. (256000) we want to turn this + # into 254kbps normal_md = default_to_f(orig_md, path_md, unicode_unknown, default_f) if normal_md['MDATA_KEY_BITRATE']: formatted = str(int(normal_md['MDATA_KEY_BITRATE']) / 1000) normal_md['MDATA_KEY_BITRATE'] = formatted + 'kbps' else: normal_md['MDATA_KEY_BITRATE'] = unicode_unknown + if is_airtime_recorded(normal_md): title_re = re.match("(?P\w+)-(?P\d+-\d+-\d+-\d+:\d+:\d+)$", normal_md['MDATA_KEY_TITLE']) - show_name, = title_re.group('show'), - date = title_re.group('date').replace(':','-') + show_name, = title_re.group('show'), + date = title_re.group('date').replace(':','-') yyyy, mm, _ = normal_md['MDATA_KEY_YEAR'].split('-',2) - fname_base = '%s-%s-%s.%s' % \ + fname_base = '%s-%s-%s.%s' % \ (date, show_name, normal_md['MDATA_KEY_BITRATE'], ext) filepath = os.path.join(root_path, yyyy, mm, fname_base) elif len(normal_md['MDATA_KEY_TRACKNUMBER']) == 0: From 1090226fc307515654efb45c7e12a9fec8d1a267 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 14:19:11 -0400 Subject: [PATCH 2/3] cc-4255: registered component so that status works --- python_apps/media-monitor2/mm2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python_apps/media-monitor2/mm2.py b/python_apps/media-monitor2/mm2.py index 752076da2..dbfa1ebd5 100644 --- a/python_apps/media-monitor2/mm2.py +++ b/python_apps/media-monitor2/mm2.py @@ -127,6 +127,8 @@ def main(global_config, api_client_config, log_config, tt = ToucherThread(path=config['index_path'], interval=int(config['touch_interval'])) + apiclient.register_component('media-monitor') + pyi = manager.pyinotify() pyi.loop() From 36c3bf5763c2dfa8ee38ae48e5c2bf22b2b1028f Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 21 Aug 2012 15:12:45 -0400 Subject: [PATCH 3/3] cc-4240: added recorder stacktrace print --- python_apps/pypo/recorder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python_apps/pypo/recorder.py b/python_apps/pypo/recorder.py index de48afd1c..e4c1e85f7 100644 --- a/python_apps/pypo/recorder.py +++ b/python_apps/pypo/recorder.py @@ -9,6 +9,7 @@ import sys import pytz import signal import math +import traceback from configobj import ConfigObj @@ -310,6 +311,7 @@ class Recorder(Thread): self.logger.error(e) try: self.handle_message() except Exception, e: + self.logger.error( traceback.format_exc() ) self.logger.error('Pypo Recorder Exception: %s', e) time.sleep(PUSH_INTERVAL) self.loops += 1