-found another unicode encoding error

-code cleanup
This commit is contained in:
martin 2011-07-11 14:24:08 -04:00
parent 66115de5ea
commit a8b3745bf4
2 changed files with 11 additions and 9 deletions

View File

@ -122,7 +122,7 @@ class AirtimeNotifier(Notifier):
mode = d['mode'] mode = d['mode']
md = {} md = {}
md['MDATA_KEY_FILEPATH'] = filepath md['MDATA_KEY_FILEPATH'] = filepath.encode("utf_8")
if 'data' in d: if 'data' in d:
file_md = d['data'] file_md = d['data']

View File

@ -25,23 +25,24 @@ class AirtimeProcessEvent(ProcessEvent):
keyworded arguments passed to ProcessEvent.__init__() are then keyworded arguments passed to ProcessEvent.__init__() are then
delegated to my_init(). delegated to my_init().
""" """
self.logger = logging.getLogger() self.logger = logging.getLogger()
self.config = airtime_config self.config = airtime_config
#put the file path into this dict if we want to ignore certain #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 #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 #are going to delete it from the db on the server side, so media-monitor
#need to contact the server and tell it to delete again. #doesn't need to contact the server and tell it to delete again.
self.ignore_event = set() self.ignore_event = set()
self.supported_file_formats = ['mp3', 'ogg'] self.supported_file_formats = ['mp3', 'ogg']
"""
self.temp_files = {} self.temp_files = {}
self.renamed_files = {} self.renamed_files = {}
"""
self.moved_files = {} self.moved_files = {}
self.gui_replaced = {} self.gui_replaced = {}
""" """
self.cookies_IN_MOVED_FROM = {} self.cookies_IN_MOVED_FROM = {}
self.file_events = [] self.file_events = []
self.multi_queue = queue self.multi_queue = queue
@ -61,6 +62,7 @@ class AirtimeProcessEvent(ProcessEvent):
directory = os.path.normpath(directory) directory = os.path.normpath(directory)
return (directory == filepath[0:len(directory)]) return (directory == filepath[0:len(directory)])
"""
def is_temp_file(self, filename): def is_temp_file(self, filename):
info = filename.split(".") info = filename.split(".")
@ -68,6 +70,7 @@ class AirtimeProcessEvent(ProcessEvent):
return True return True
else: else:
return False return False
"""
def is_audio_file(self, filename): def is_audio_file(self, filename):
info = filename.split(".") info = filename.split(".")
@ -98,7 +101,6 @@ class AirtimeProcessEvent(ProcessEvent):
return readable return readable
def set_needed_file_permissions(self, item, is_dir): def set_needed_file_permissions(self, item, is_dir):
try: try:
omask = os.umask(0) omask = os.umask(0)
@ -259,10 +261,10 @@ class AirtimeProcessEvent(ProcessEvent):
if not dir: if not dir:
self.logger.debug("PROCESS_IN_CREATE: %s, name: %s, pathname: %s ", dir, name, pathname) self.logger.debug("PROCESS_IN_CREATE: %s, name: %s, pathname: %s ", dir, name, pathname)
#event is because of a created file #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. #file created is a tmp file which will be modified and then moved back to the original filename.
self.temp_files[pathname] = None #self.temp_files[pathname] = None
elif self.is_audio_file(pathname): if self.is_audio_file(pathname):
if self.is_parent_directory(pathname, self.config.organize_directory): if self.is_parent_directory(pathname, self.config.organize_directory):
#file was created in /srv/airtime/stor/organize. Need to process and move #file was created in /srv/airtime/stor/organize. Need to process and move
#to /srv/airtime/stor/imported #to /srv/airtime/stor/imported