def start(self): # remove all handlers self.handlers = [] # console log handler if self.consoleLogging: console = logging.StreamHandler() console.setFormatter( logging.Formatter('%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%H:%M:%S')) console.setLevel(self.logLevels['INFO'] if not self.debugLogging else self.logLevels['DEBUG']) self.addHandler(console) # rotating log file handlers if self.logFile and makeDir(os.path.dirname(self.logFile)): rfh = RotatingFileHandler( filename=self.logFile, maxBytes=self.logSize, backupCount=self.logNr ) rfh_errors = RotatingFileHandler( filename=self.logFile.replace('.log', '.error.log'), maxBytes=self.logSize, backupCount=self.logNr ) rfh.setFormatter( logging.Formatter('%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%Y-%m-%d %H:%M:%S')) rfh.setLevel(self.logLevels['INFO'] if not self.debugLogging else self.logLevels['DEBUG']) self.addHandler(rfh) rfh_errors.setFormatter( logging.Formatter('%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%Y-%m-%d %H:%M:%S')) rfh_errors.setLevel(self.logLevels['ERROR']) self.addHandler(rfh_errors)
def get_subtitles_path(video_path): if os.path.isabs(sickrage.app.config.subtitles_dir): new_subtitles_path = sickrage.app.config.subtitles_dir elif sickrage.app.config.subtitles_dir: new_subtitles_path = os.path.join(os.path.dirname(video_path), sickrage.app.config.subtitles_dir) dir_exists = makeDir(new_subtitles_path) if not dir_exists: sickrage.app.log.error( 'Unable to create subtitles folder {}'.format( new_subtitles_path)) else: chmodAsParent(new_subtitles_path) else: new_subtitles_path = os.path.dirname(video_path) try: # Encode path to UTF-8 to ensure subliminal support. new_subtitles_path = new_subtitles_path.encode('utf-8') except UnicodeEncodeError: # Fallback to system encoding. This should never happen. new_subtitles_path = new_subtitles_path.encode( sickrage.app.sys_encoding) return new_subtitles_path
def get_subtitles_path(video_path): if os.path.isabs(sickrage.srCore.srConfig.SUBTITLES_DIR): new_subtitles_path = sickrage.srCore.srConfig.SUBTITLES_DIR elif sickrage.srCore.srConfig.SUBTITLES_DIR: new_subtitles_path = os.path.join( os.path.dirname(video_path), sickrage.srCore.srConfig.SUBTITLES_DIR) dir_exists = makeDir(new_subtitles_path) if not dir_exists: sickrage.srCore.srLogger.error( 'Unable to create subtitles folder {}'.format( new_subtitles_path)) else: chmodAsParent(new_subtitles_path) else: new_subtitles_path = os.path.dirname(video_path) try: # Encode path to UTF-8 to ensure subliminal support. new_subtitles_path = new_subtitles_path.encode('utf-8') except UnicodeEncodeError: # Fallback to system encoding. This should never happen. new_subtitles_path = new_subtitles_path.encode(sickrage.SYS_ENCODING) return new_subtitles_path
def start(self): # remove all handlers self.handlers = [] # sentry log handler sentry_client = raven.Client('https://*****:*****@sentry.sickrage.ca/4?verify_ssl=0', release=sickrage.version(), repos={'sickrage': {'name': 'sickrage/sickrage'}}) sentry_handler = SentryHandler(client=sentry_client, tags={'platform': platform.platform()}) sentry_handler.setLevel(self.logLevels['ERROR']) sentry_handler.set_name('sentry') self.addHandler(sentry_handler) # console log handler if self.consoleLogging: console_handler = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%H:%M:%S') console_handler.setFormatter(formatter) console_handler.setLevel(self.logLevels['INFO'] if not self.debugLogging else self.logLevels['DEBUG']) self.addHandler(console_handler) # file log handlers if self.logFile: # make logs folder if it doesn't exist if not os.path.exists(os.path.dirname(self.logFile)): if not makeDir(os.path.dirname(self.logFile)): return if sickrage.app.developer: rfh = FileHandler( filename=self.logFile, ) else: rfh = RotatingFileHandler( filename=self.logFile, maxBytes=self.logSize, backupCount=self.logNr ) rfh_errors = RotatingFileHandler( filename=self.logFile.replace('.log', '.error.log'), maxBytes=self.logSize, backupCount=self.logNr ) formatter = logging.Formatter('%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%Y-%m-%d %H:%M:%S') rfh.setFormatter(formatter) rfh.setLevel(self.logLevels['INFO'] if not self.debugLogging else self.logLevels['DEBUG']) self.addHandler(rfh) rfh_errors.setFormatter(formatter) rfh_errors.setLevel(self.logLevels['ERROR']) self.addHandler(rfh_errors)
def get_subtitles_path(video_path): if os.path.isabs(sickrage.app.config.subtitles_dir): new_subtitles_path = sickrage.app.config.subtitles_dir elif sickrage.app.config.subtitles_dir: new_subtitles_path = os.path.join(os.path.dirname(video_path), sickrage.app.config.subtitles_dir) dir_exists = makeDir(new_subtitles_path) if not dir_exists: sickrage.app.log.warning('Unable to create subtitles folder {}'.format(new_subtitles_path)) else: chmod_as_parent(new_subtitles_path) else: new_subtitles_path = os.path.dirname(video_path) return new_subtitles_path
def get_subtitles_path(video_path): if os.path.isabs(sickrage.app.config.subtitles_dir): new_subtitles_path = sickrage.app.config.subtitles_dir elif sickrage.app.config.subtitles_dir: new_subtitles_path = os.path.join(os.path.dirname(video_path), sickrage.app.config.subtitles_dir) dir_exists = makeDir(new_subtitles_path) if not dir_exists: sickrage.app.log.error('Unable to create subtitles folder {}'.format(new_subtitles_path)) else: chmodAsParent(new_subtitles_path) else: new_subtitles_path = os.path.dirname(video_path) return new_subtitles_path
def start(self): # remove all handlers self.handlers = [] # console log handler if self.consoleLogging: console = logging.StreamHandler() formatter = logging.Formatter( '%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%H:%M:%S') console.setFormatter(formatter) console.setLevel(self.logLevels['INFO'] if not self.debugLogging else self.logLevels['DEBUG']) self.addHandler(console) # file log handlers if self.logFile: # make logs folder if it doesn't exist if not os.path.exists(os.path.dirname(self.logFile)): if not makeDir(os.path.dirname(self.logFile)): return if sickrage.app.developer: rfh = FileHandler(filename=self.logFile, ) else: rfh = RotatingFileHandler(filename=self.logFile, maxBytes=self.logSize, backupCount=self.logNr) rfh_errors = RotatingFileHandler(filename=self.logFile.replace( '.log', '.error.log'), maxBytes=self.logSize, backupCount=self.logNr) formatter = logging.Formatter( '%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%Y-%m-%d %H:%M:%S') rfh.setFormatter(formatter) rfh.setLevel(self.logLevels['INFO'] if not self.debugLogging else self.logLevels['DEBUG']) self.addHandler(rfh) rfh_errors.setFormatter(formatter) rfh_errors.setLevel(self.logLevels['ERROR']) self.addHandler(rfh_errors)
def get_subtitles_path(video_path): if os.path.isabs(sickrage.app.config.subtitles_dir): new_subtitles_path = sickrage.app.config.subtitles_dir elif sickrage.app.config.subtitles_dir: new_subtitles_path = os.path.join(os.path.dirname(video_path), sickrage.app.config.subtitles_dir) dir_exists = makeDir(new_subtitles_path) if not dir_exists: sickrage.app.log.error('Unable to create subtitles folder {}'.format(new_subtitles_path)) else: chmodAsParent(new_subtitles_path) else: new_subtitles_path = os.path.dirname(video_path) try: # Encode path to UTF-8 to ensure subliminal support. new_subtitles_path = new_subtitles_path.encode('utf-8') except UnicodeEncodeError: # Fallback to system encoding. This should never happen. new_subtitles_path = new_subtitles_path.encode(sickrage.app.sys_encoding) return new_subtitles_path
def start(self): # remove all handlers self.handlers = [] # sentry log handler sentry_client = raven.Client( 'https://*****:*****@sentry.sickrage.ca/4?verify_ssl=0', release=sickrage.version(), repos={'sickrage': { 'name': 'sickrage/sickrage' }}) sentry_handler = SentryHandler(client=sentry_client, tags={'platform': platform.platform()}) sentry_handler.setLevel(self.logLevels['ERROR']) sentry_handler.set_name('sentry') self.addHandler(sentry_handler) # console log handler if self.consoleLogging: console_handler = logging.StreamHandler() formatter = logging.Formatter( '%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%H:%M:%S') console_handler.setFormatter(formatter) console_handler.setLevel(self.logLevels['INFO'] if not self. debugLogging else self.logLevels['DEBUG']) self.addHandler(console_handler) # file log handlers if self.logFile: # make logs folder if it doesn't exist if not os.path.exists(os.path.dirname(self.logFile)): if not makeDir(os.path.dirname(self.logFile)): return if sickrage.app.developer: rfh = FileHandler(filename=self.logFile, ) else: rfh = RotatingFileHandler(filename=self.logFile, maxBytes=self.logSize, backupCount=self.logNr) rfh_errors = RotatingFileHandler(filename=self.logFile.replace( '.log', '.error.log'), maxBytes=self.logSize, backupCount=self.logNr) formatter = logging.Formatter( '%(asctime)s %(levelname)s::%(threadName)s::%(message)s', '%Y-%m-%d %H:%M:%S') rfh.setFormatter(formatter) rfh.setLevel(self.logLevels['INFO'] if not self.debugLogging else self.logLevels['DEBUG']) self.addHandler(rfh) rfh_errors.setFormatter(formatter) rfh_errors.setLevel(self.logLevels['ERROR']) self.addHandler(rfh_errors)