Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
denise 2012-07-04 18:58:37 -04:00
commit ae08c54689
4 changed files with 12 additions and 15 deletions

View File

@ -221,11 +221,14 @@ class AirtimeMetadata:
md['MDATA_KEY_COPYRIGHT'] = self.truncate_to_length(md['MDATA_KEY_COPYRIGHT'], 512)
#end of db truncation checks.
md['MDATA_KEY_BITRATE'] = getattr(file_info.info, "bitrate", None)
md['MDATA_KEY_SAMPLERATE'] = getattr(file_info.info, "sample_rate", None)
self.logger.info( "Bitrate: %s , Samplerate: %s", md['MDATA_KEY_BITRATE'], md['MDATA_KEY_SAMPLERATE'] )
try: md['MDATA_KEY_DURATION'] = self.format_length(file_info.info.length)
except Exception as e: self.logger.warn("File: '%s' raises: %s", filepath, str(e))
md['MDATA_KEY_BITRATE'] = file_info.info.bitrate
md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate
md['MDATA_KEY_DURATION'] = self.format_length(file_info.info.length)
md['MDATA_KEY_MIME'] = file_info.mime[0]
try: md['MDATA_KEY_MIME'] = file_info.mime[0]
except Exception as e: self.logger.warn("File: '%s' has no mime type", filepath, str(e))
if "mp3" in md['MDATA_KEY_MIME']:
md['MDATA_KEY_FTYPE'] = "audioclip"

View File

@ -191,6 +191,7 @@ class AirtimeNotifier(Notifier):
except Exception, e:
self.logger.error("failed updating filepath: %s ", event['filepath'])
self.logger.error('Exception: %s', e)
self.logger.error('Traceback: %s', traceback.format_exc())
#define which directories the pyinotify WatchManager should watch.
def watch_directory(self, directory):

View File

@ -35,20 +35,13 @@ class MediaMonitorCommon:
# if file doesn't have any extension, info[-2] throws exception
# Hence, checking length of info before we do anything
if(len(info) >= 2):
if(info[-2].lower() in self.supported_file_formats):
return True
else:
return False
return info[-2].lower() in self.supported_file_formats
else:
return False
def is_audio_file(self, filename):
info = filename.split(".")
if(info[-1].lower() in self.supported_file_formats):
return True
else:
return False
return info[-1].lower() in self.supported_file_formats
#check if file is readable by "nobody"
def is_user_readable(self, filepath, euid='nobody', egid='nogroup'):

View File

@ -117,9 +117,9 @@ try:
notifier = AirtimeNotifier(wm, pe, read_freq=0, timeout=0, airtime_config=config, api_client=api_client, bootstrap=bootstrap, mmc=mmc)
notifier.coalesce_events()
#create 5 worker threads
wp = MediaMonitorWorkerProcess(config, mmc)
wp = MediaMonitorWorkerProcess(config, mmc)
for i in range(5):
threadName = "Thread #%d" % i
t = Thread(target=wp.process_file_events, name=threadName, args=(multi_queue, notifier))