cc-4105: fixed inconsistency regarding handling bad files

This commit is contained in:
Rudi Grinberg 2012-08-07 10:42:10 -04:00
parent 3b9efee8e3
commit 088f655033
2 changed files with 17 additions and 6 deletions

View File

@ -61,6 +61,18 @@ class BaseEvent(Loggable):
def is_dir_event(self):
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
def morph_into(self, evt):
"""

View File

@ -25,25 +25,24 @@ class RequestSync(threading.Thread,Loggable):
return ac.AirtimeApiClient.create_right_config()
def run(self):
# TODO : implement proper request sending
self.logger.info("launching request with %d items." % len(self.requests))
self.logger.info("Attempting request with %d items." % len(self.requests))
# 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
# to recorded shows
# A simplistic request would like:
# TODO : recorded shows aren't flagged right
packed_requests = []
for request_event in self.requests:
try:
for request in request_event.pack():
for request in request_event.safe_pack():
if isinstance(request, BadSongFile):
self.logger.info("Bad song file: '%s'" % request.path)
else: packed_requests.append(request)
except BadSongFile as e:
self.logger.info("This should never occur anymore!!!")
self.logger.info("Bad song file: '%s'" % e.path)
self.logger.info("TODO : put in ignore list")
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() )
def make_req(): self.apiclient.send_media_monitor_requests( packed_requests )
# Is this retry shit even necessary? Consider getting rid of this.