Merge branch '1.9.1' into devel
Conflicts: airtime_mvc/application/controllers/ApiController.php airtime_mvc/application/models/MusicDir.php python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py
This commit is contained in:
commit
5190a0c24c
7 changed files with 46 additions and 9 deletions
|
@ -40,10 +40,13 @@ def to_unicode(obj, encoding='utf-8'):
|
|||
return obj
|
||||
|
||||
def encode_to(obj, encoding='utf-8'):
|
||||
if isinstance(obj, basestring):
|
||||
if not isinstance(obj, str):
|
||||
obj = obj.encode(encoding)
|
||||
if isinstance(obj, unicode):
|
||||
obj = obj.encode(encoding)
|
||||
return obj
|
||||
|
||||
def convert_dict_value_to_utf8(md):
|
||||
#list comprehension to convert all values of md to utf-8
|
||||
return dict([(item[0], encode_to(item[1], "utf-8")) for item in md.items()])
|
||||
|
||||
class ApiClientInterface:
|
||||
|
||||
|
@ -411,7 +414,9 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_media_url"])
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
url = url.replace("%%mode%%", mode)
|
||||
|
||||
|
||||
md = convert_dict_value_to_utf8(md)
|
||||
|
||||
data = urllib.urlencode(md)
|
||||
req = urllib2.Request(url, data)
|
||||
|
||||
|
@ -437,7 +442,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
|
||||
except Exception, e:
|
||||
response = None
|
||||
logger.error("Exception with filepath %s: %s", md['MDATA_KEY_FILEPATH'], e)
|
||||
logger.error("Exception with file %s: %s", md, e)
|
||||
|
||||
return response
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
self.api_client = api_client
|
||||
self.create_dict = {}
|
||||
|
||||
|
||||
def add_filepath_to_ignore(self, filepath):
|
||||
self.ignore_event.add(filepath)
|
||||
|
||||
|
@ -96,7 +97,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
# record the timestamp of the time on IN_CREATE event
|
||||
self.create_dict[event.pathname] = time.time()
|
||||
|
||||
|
||||
#event.dir: True if the event was raised against a directory.
|
||||
#event.name: filename
|
||||
#event.pathname: pathname (str): Concatenation of 'path' and 'name'.
|
||||
|
@ -110,6 +110,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
# detele corresponding entry from create_dict
|
||||
self.create_dict.pop(event.pathname)
|
||||
self.handle_created_file(event.dir, event.pathname, event.name)
|
||||
|
||||
|
||||
def handle_created_file(self, dir, pathname, name):
|
||||
if not dir:
|
||||
|
|
|
@ -258,7 +258,8 @@ class CommandListener(Thread):
|
|||
|
||||
#remove show from shows to record.
|
||||
del self.shows_to_record[start_time]
|
||||
self.time_till_next_show = 3600
|
||||
time_till_next_show = self.get_time_till_next_show()
|
||||
self.time_till_next_show = time_till_next_show
|
||||
except Exception,e :
|
||||
self.logger.error(e)
|
||||
else:
|
||||
|
@ -297,6 +298,7 @@ class CommandListener(Thread):
|
|||
# start recording
|
||||
self.start_record()
|
||||
except Exception, e:
|
||||
self.logger.info(e)
|
||||
time.sleep(3)
|
||||
|
||||
loops += 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue