cc-4105: more code duplication removed

This commit is contained in:
Rudi Grinberg 2012-08-14 15:24:57 -04:00
parent 95d33b9248
commit a73d0940bd
1 changed files with 6 additions and 10 deletions

View File

@ -5,7 +5,6 @@ from kombu.connection import BrokerConnection
import json import json
import os import os
import copy import copy
import traceback
from media.monitor.exceptions import BadSongFile from media.monitor.exceptions import BadSongFile
from media.monitor.metadata import Metadata from media.monitor.metadata import Metadata
@ -138,18 +137,15 @@ class AirtimeMessageReceiver(Loggable):
def rescan_watch(self, msg): def rescan_watch(self, msg):
self.logger.info("Trying to rescan watched directory: '%s'" % self.logger.info("Trying to rescan watched directory: '%s'" %
msg['directory']) msg['directory'])
try: try:
# id is always an integer but in the dictionary the key is always a # id is always an integer but in the dictionary the key is always a
# string # string
self.__request_now_bootstrap( unicode(msg['id']) ) self.__request_now_bootstrap( unicode(msg['id']) )
except DirectoryIsNotListed as e: except DirectoryIsNotListed as e:
self.logger.info("Bad rescan request") self.fatal_exception("Bad rescan request", e)
self.logger.info( str(e) )
except Exception as e: except Exception as e:
self.logger.info("Bad rescan request. Unknown error.") self.fatal_exception("Bad rescan request. Unknown error.", e)
self.logger.info( str(e) )
self.logger.info( traceback.format_exc() )
else: else:
self.logger.info("Successfully re-scanned: '%s'" % msg['directory']) self.logger.info("Successfully re-scanned: '%s'" % msg['directory'])
@ -186,9 +182,9 @@ class AirtimeMessageReceiver(Loggable):
self.logger.info("Successfully deleted: '%s'" % self.logger.info("Successfully deleted: '%s'" %
msg['filepath']) msg['filepath'])
except Exception as e: except Exception as e:
self.logger.info("Failed to delete '%s'" % msg['filepath']) self.fatal_exception("Failed to delete '%s'" % msg['filepath'],
self.logger.info("Error: " % str(e)) e)
else: # validation for filepath existence failed else: # validation for filepath existence failed
self.logger.info("Attempting to delete file '%s' that does not \ self.logger.info("Attempting to delete file '%s' that does not \
exist. Full request coming:" % msg['filepath']) exist. Full request:" % msg['filepath'])
self.logger.info(msg) self.logger.info(msg)