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

This commit is contained in:
james 2011-07-11 15:45:26 -04:00
commit 5095cae0f3
3 changed files with 17 additions and 12 deletions

View File

@ -365,12 +365,15 @@ class AirTimeApiClient(ApiClientInterface):
try: 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 = "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"]) url = url.replace("%%api_key%%", self.config["api_key"])
logger.debug(url)
response = urllib.urlopen(url) response = urllib.urlopen(url)
response = json.loads(response.read()) 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: except Exception, e:
response = None response = None
logger.error("Exception: %s", e) logger.error("Exception: %s", e)

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