cc-4105: fixed inconsistency regarding handling bad files
This commit is contained in:
parent
3b9efee8e3
commit
088f655033
2 changed files with 17 additions and 6 deletions
|
@ -61,6 +61,18 @@ class BaseEvent(Loggable):
|
||||||
def is_dir_event(self):
|
def is_dir_event(self):
|
||||||
return self._raw_event.dir
|
return self._raw_event.dir
|
||||||
|
|
||||||
|
# As opposed to unsafe_pack...
|
||||||
|
def safe_pack(self):
|
||||||
|
"""
|
||||||
|
returns exceptions instead of throwing them to be consistent with
|
||||||
|
events that must catch their own BadSongFile exceptions since generate
|
||||||
|
a set of exceptions instead of a single one
|
||||||
|
"""
|
||||||
|
# pack will only throw an exception if it processes one file but this
|
||||||
|
# is a little bit hacky
|
||||||
|
try: return self.pack()
|
||||||
|
except BadSongFile as e: return [e]
|
||||||
|
|
||||||
# nothing to see here, please move along
|
# nothing to see here, please move along
|
||||||
def morph_into(self, evt):
|
def morph_into(self, evt):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -25,25 +25,24 @@ class RequestSync(threading.Thread,Loggable):
|
||||||
return ac.AirtimeApiClient.create_right_config()
|
return ac.AirtimeApiClient.create_right_config()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# TODO : implement proper request sending
|
self.logger.info("Attempting request with %d items." % len(self.requests))
|
||||||
self.logger.info("launching request with %d items." % len(self.requests))
|
|
||||||
# Note that we must attach the appropriate mode to every response. Also
|
# Note that we must attach the appropriate mode to every response. Also
|
||||||
# Not forget to attach the 'is_record' to any requests that are related
|
# Not forget to attach the 'is_record' to any requests that are related
|
||||||
# to recorded shows
|
# to recorded shows
|
||||||
# A simplistic request would like:
|
|
||||||
# TODO : recorded shows aren't flagged right
|
# TODO : recorded shows aren't flagged right
|
||||||
packed_requests = []
|
packed_requests = []
|
||||||
for request_event in self.requests:
|
for request_event in self.requests:
|
||||||
try:
|
try:
|
||||||
for request in request_event.pack():
|
for request in request_event.safe_pack():
|
||||||
if isinstance(request, BadSongFile):
|
if isinstance(request, BadSongFile):
|
||||||
self.logger.info("Bad song file: '%s'" % request.path)
|
self.logger.info("Bad song file: '%s'" % request.path)
|
||||||
else: packed_requests.append(request)
|
else: packed_requests.append(request)
|
||||||
except BadSongFile as e:
|
except BadSongFile as e:
|
||||||
|
self.logger.info("This should never occur anymore!!!")
|
||||||
self.logger.info("Bad song file: '%s'" % e.path)
|
self.logger.info("Bad song file: '%s'" % e.path)
|
||||||
self.logger.info("TODO : put in ignore list")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.info("An evil exception occured to packing '%s'" % request.path)
|
self.logger.info("An evil exception occured")
|
||||||
|
import ipdb; ipdb.set_trace()
|
||||||
self.logger.error( traceback.format_exc() )
|
self.logger.error( traceback.format_exc() )
|
||||||
def make_req(): self.apiclient.send_media_monitor_requests( packed_requests )
|
def make_req(): self.apiclient.send_media_monitor_requests( packed_requests )
|
||||||
# Is this retry shit even necessary? Consider getting rid of this.
|
# Is this retry shit even necessary? Consider getting rid of this.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue