From a8b3745bf402afa4bab04560d509de08aa94707d Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 11 Jul 2011 14:24:08 -0400 Subject: [PATCH 1/2] -found another unicode encoding error -code cleanup --- .../airtimefilemonitor/airtimenotifier.py | 2 +- .../airtimefilemonitor/airtimeprocessevent.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py b/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py index 0eb403fcd..d05af0282 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py @@ -122,7 +122,7 @@ class AirtimeNotifier(Notifier): mode = d['mode'] md = {} - md['MDATA_KEY_FILEPATH'] = filepath + md['MDATA_KEY_FILEPATH'] = filepath.encode("utf_8") if 'data' in d: file_md = d['data'] diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 687b201b7..562dcedfb 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -25,23 +25,24 @@ class AirtimeProcessEvent(ProcessEvent): keyworded arguments passed to ProcessEvent.__init__() are then delegated to my_init(). """ - self.logger = logging.getLogger() self.config = airtime_config #put the file path into this dict if we want to ignore certain #events. For example, when deleting a file from the web ui, we - #are going to delete it on the server side, so media-monitor doesn't - #need to contact the server and tell it to delete again. + #are going to delete it from the db on the server side, so media-monitor + #doesn't need to contact the server and tell it to delete again. self.ignore_event = set() self.supported_file_formats = ['mp3', 'ogg'] + + """ self.temp_files = {} self.renamed_files = {} - """ self.moved_files = {} self.gui_replaced = {} """ + self.cookies_IN_MOVED_FROM = {} self.file_events = [] self.multi_queue = queue @@ -61,6 +62,7 @@ class AirtimeProcessEvent(ProcessEvent): directory = os.path.normpath(directory) return (directory == filepath[0:len(directory)]) + """ def is_temp_file(self, filename): info = filename.split(".") @@ -68,6 +70,7 @@ class AirtimeProcessEvent(ProcessEvent): return True else: return False + """ def is_audio_file(self, filename): info = filename.split(".") @@ -98,7 +101,6 @@ class AirtimeProcessEvent(ProcessEvent): return readable def set_needed_file_permissions(self, item, is_dir): - try: omask = os.umask(0) @@ -259,10 +261,10 @@ class AirtimeProcessEvent(ProcessEvent): if not dir: self.logger.debug("PROCESS_IN_CREATE: %s, name: %s, pathname: %s ", dir, name, pathname) #event is because of a created file - if self.is_temp_file(name) : + #if self.is_temp_file(name) : #file created is a tmp file which will be modified and then moved back to the original filename. - self.temp_files[pathname] = None - elif self.is_audio_file(pathname): + #self.temp_files[pathname] = None + if self.is_audio_file(pathname): if self.is_parent_directory(pathname, self.config.organize_directory): #file was created in /srv/airtime/stor/organize. Need to process and move #to /srv/airtime/stor/imported From 2659932cfb0a64a7af426c72cf27c0e63a070bbc Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 11 Jul 2011 14:44:23 -0400 Subject: [PATCH 2/2] -added new exception for when apache isn't responding --- python_apps/api_clients/api_client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index d6473809b..fc0fee7f7 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -365,12 +365,15 @@ class AirTimeApiClient(ApiClientInterface): try: url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["media_setup_url"]) url = url.replace("%%api_key%%", self.config["api_key"]) - logger.debug(url) response = urllib.urlopen(url) response = json.loads(response.read()) - logger.debug("Json Media Setup %s", response) - + logger.info("Connected to Airtime Server. Json Media Storage Dir: %s", response) + except IOError: + #this should be a common exception when media-monitor daemon + #has started before apache on bootup and apache isn't accepting + #connections yet. + response = None except Exception, e: response = None logger.error("Exception: %s", e)