Private GIT

Skip to content
Snippets Groups Projects
Commit e39c0a67 authored by miigotu's avatar miigotu
Browse files

Merge pull request #2556 from SiCKRAGETV/logger-lint

Fix linting errors in logger.py
parents 1393e6e6 c8a0df06
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>. # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=W0703
from __future__ import with_statement from __future__ import with_statement
import os import os
...@@ -65,6 +66,7 @@ class CensoredFormatter(logging.Formatter, object): ...@@ -65,6 +66,7 @@ class CensoredFormatter(logging.Formatter, object):
def format(self, record): def format(self, record):
"""Strips censored items from string""" """Strips censored items from string"""
msg = super(CensoredFormatter, self).format(record) msg = super(CensoredFormatter, self).format(record)
# pylint: disable=W0612
for k, v in censoredItems.iteritems(): for k, v in censoredItems.iteritems():
if v and len(v) > 0 and v in msg: if v and len(v) > 0 and v in msg:
msg = msg.replace(v, len(v) * '*') msg = msg.replace(v, len(v) * '*')
...@@ -131,8 +133,8 @@ class Logger(object): ...@@ -131,8 +133,8 @@ class Logger(object):
for logger in self.loggers: for logger in self.loggers:
logger.addHandler(rfh) logger.addHandler(rfh)
def shutdown(self): @staticmethod
def shutdown():
logging.shutdown() logging.shutdown()
def log(self, msg, level=INFO, *args, **kwargs): def log(self, msg, level=INFO, *args, **kwargs):
...@@ -159,16 +161,17 @@ class Logger(object): ...@@ -159,16 +161,17 @@ class Logger(object):
sys.exit(1) sys.exit(1)
def submit_errors(self): def submit_errors(self):
# pylint: disable=R0912,R0914,R0915
if not (sickbeard.GIT_USERNAME and sickbeard.GIT_PASSWORD and sickbeard.DEBUG and len(classes.ErrorViewer.errors) > 0): if not (sickbeard.GIT_USERNAME and sickbeard.GIT_PASSWORD and sickbeard.DEBUG and len(classes.ErrorViewer.errors) > 0):
self.log('Please set your GitHub username and password in the config and enable debug. Unable to submit issue ticket to GitHub!') self.log('Please set your GitHub username and password in the config and enable debug. Unable to submit issue ticket to GitHub!')
return return
try: try:
from versionChecker import CheckVersion from sickbeard.versionChecker import CheckVersion
checkversion = CheckVersion() checkversion = CheckVersion()
needs_update = checkversion.check_for_new_version() checkversion.check_for_new_version()
commits_behind = checkversion.updater.get_num_commits_behind() commits_behind = checkversion.updater.get_num_commits_behind()
except: except Exception:
self.log('Could not check if your SickRage is updated, unable to submit issue ticket to GitHub!') self.log('Could not check if your SickRage is updated, unable to submit issue ticket to GitHub!')
return return
...@@ -206,7 +209,7 @@ class Logger(object): ...@@ -206,7 +209,7 @@ class Logger(object):
try: try:
title_Error = str(curError.title) title_Error = str(curError.title)
if not len(title_Error) or title_Error == 'None': if not len(title_Error) or title_Error == 'None':
title_Error = re.match("^[A-Z0-9\-\[\] :]+::\s*(.*)$", ss(str(curError.message))).group(1) title_Error = re.match(r"^[A-Z0-9\-\[\] :]+::\s*(.*)$", ss(str(curError.message))).group(1)
# if len(title_Error) > (1024 - len(u"[APP SUBMITTED]: ")): # if len(title_Error) > (1024 - len(u"[APP SUBMITTED]: ")):
# 1000 just looks better than 1007 and adds some buffer # 1000 just looks better than 1007 and adds some buffer
...@@ -216,7 +219,7 @@ class Logger(object): ...@@ -216,7 +219,7 @@ class Logger(object):
self.log("Unable to get error title : " + ex(e), ERROR) self.log("Unable to get error title : " + ex(e), ERROR)
gist = None gist = None
regex = "^(%s)\s+([A-Z]+)\s+([0-9A-Z\-]+)\s*(.*)$" % curError.time regex = r"^(%s)\s+([A-Z]+)\s+([0-9A-Z\-]+)\s*(.*)$" % curError.time
for i, x in enumerate(log_data): for i, x in enumerate(log_data):
x = ss(x) x = ss(x)
match = re.match(regex, x) match = re.match(regex, x)
...@@ -236,7 +239,7 @@ class Logger(object): ...@@ -236,7 +239,7 @@ class Logger(object):
if not 'Windows' in platform.platform(): if not 'Windows' in platform.platform():
try: try:
message += u"Locale: " + locale.getdefaultlocale()[1] + "\n" message += u"Locale: " + locale.getdefaultlocale()[1] + "\n"
except: except Exception:
message += u"Locale: unknown" + "\n" message += u"Locale: unknown" + "\n"
message += u"Branch: **" + sickbeard.BRANCH + "**\n" message += u"Branch: **" + sickbeard.BRANCH + "**\n"
message += u"Commit: SiCKRAGETV/SickRage@" + sickbeard.CUR_COMMIT_HASH + "\n" message += u"Commit: SiCKRAGETV/SickRage@" + sickbeard.CUR_COMMIT_HASH + "\n"
...@@ -282,6 +285,7 @@ class Logger(object): ...@@ -282,6 +285,7 @@ class Logger(object):
self.submitter_running = False self.submitter_running = False
# pylint: disable=R0903
class Wrapper(object): class Wrapper(object):
instance = Logger() instance = Logger()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment