More rename, more -python2
This commit is contained in:
@@ -15,13 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Tautulli. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from future.builtins import str
|
||||
|
||||
from logutils.queue import QueueHandler, QueueListener
|
||||
from logging import handlers
|
||||
|
||||
import cherrypy
|
||||
import contextlib
|
||||
import errno
|
||||
import logging
|
||||
@@ -31,15 +25,15 @@ import re
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
from logging import handlers
|
||||
|
||||
import cherrypy
|
||||
from logutils.queue import QueueHandler, QueueListener
|
||||
|
||||
import jellypy
|
||||
if jellypy.PYTHON2:
|
||||
import helpers
|
||||
from config import _BLACKLIST_KEYS, _WHITELIST_KEYS
|
||||
else:
|
||||
from jellypy import helpers
|
||||
from jellypy.config import _BLACKLIST_KEYS, _WHITELIST_KEYS
|
||||
|
||||
from jellypy import helpers
|
||||
from jellypy.config import _BLACKLIST_KEYS, _WHITELIST_KEYS
|
||||
|
||||
# These settings are for file logging only
|
||||
FILENAME = "tautulli.log"
|
||||
@@ -67,8 +61,8 @@ def blacklist_config(config):
|
||||
|
||||
for key, value in config.items():
|
||||
if isinstance(value, str) and len(value.strip()) > 5 and \
|
||||
key.upper() not in _WHITELIST_KEYS and (key.upper() in blacklist_keys or
|
||||
any(bk in key.upper() for bk in _BLACKLIST_KEYS)):
|
||||
key.upper() not in _WHITELIST_KEYS and (key.upper() in blacklist_keys or
|
||||
any(bk in key.upper() for bk in _BLACKLIST_KEYS)):
|
||||
blacklist.add(value.strip())
|
||||
|
||||
_BLACKLIST_WORDS.update(blacklist)
|
||||
@@ -78,9 +72,10 @@ class NoThreadFilter(logging.Filter):
|
||||
"""
|
||||
Log filter for the current thread
|
||||
"""
|
||||
|
||||
def __init__(self, threadName):
|
||||
super(NoThreadFilter, self).__init__()
|
||||
|
||||
|
||||
self.threadName = threadName
|
||||
|
||||
def filter(self, record):
|
||||
@@ -92,6 +87,7 @@ class BlacklistFilter(logging.Filter):
|
||||
"""
|
||||
Log filter for blacklisted tokens and passwords
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(BlacklistFilter, self).__init__()
|
||||
|
||||
@@ -125,6 +121,7 @@ class RegexFilter(logging.Filter):
|
||||
"""
|
||||
Base class for regex log filter
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(RegexFilter, self).__init__()
|
||||
|
||||
@@ -165,6 +162,7 @@ class PublicIPFilter(RegexFilter):
|
||||
"""
|
||||
Log filter for public IP addresses
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(PublicIPFilter, self).__init__()
|
||||
|
||||
@@ -182,6 +180,7 @@ class EmailFilter(RegexFilter):
|
||||
"""
|
||||
Log filter for email addresses
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(EmailFilter, self).__init__()
|
||||
|
||||
@@ -198,6 +197,7 @@ class PlexTokenFilter(RegexFilter):
|
||||
"""
|
||||
Log filter for X-Plex-Token
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(PlexTokenFilter, self).__init__()
|
||||
|
||||
@@ -309,11 +309,13 @@ def initLogger(console=False, log_dir=False, verbose=False):
|
||||
|
||||
# Setup file logger
|
||||
if log_dir:
|
||||
file_formatter = logging.Formatter('%(asctime)s - %(levelname)-7s :: %(threadName)s : %(message)s', '%Y-%m-%d %H:%M:%S')
|
||||
file_formatter = logging.Formatter('%(asctime)s - %(levelname)-7s :: %(threadName)s : %(message)s',
|
||||
'%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# Main Tautulli logger
|
||||
filename = os.path.join(log_dir, FILENAME)
|
||||
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES, encoding='utf-8')
|
||||
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES,
|
||||
encoding='utf-8')
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(file_formatter)
|
||||
|
||||
@@ -322,7 +324,8 @@ def initLogger(console=False, log_dir=False, verbose=False):
|
||||
|
||||
# Tautulli API logger
|
||||
filename = os.path.join(log_dir, FILENAME_API)
|
||||
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES, encoding='utf-8')
|
||||
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES,
|
||||
encoding='utf-8')
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(file_formatter)
|
||||
|
||||
@@ -330,7 +333,8 @@ def initLogger(console=False, log_dir=False, verbose=False):
|
||||
|
||||
# Tautulli websocket logger
|
||||
filename = os.path.join(log_dir, FILENAME_PLEX_WEBSOCKET)
|
||||
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES, encoding='utf-8')
|
||||
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES,
|
||||
encoding='utf-8')
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(file_formatter)
|
||||
|
||||
@@ -338,7 +342,8 @@ def initLogger(console=False, log_dir=False, verbose=False):
|
||||
|
||||
# Setup console logger
|
||||
if console:
|
||||
console_formatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(threadName)s : %(message)s', '%Y-%m-%d %H:%M:%S')
|
||||
console_formatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(threadName)s : %(message)s',
|
||||
'%Y-%m-%d %H:%M:%S')
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setFormatter(console_formatter)
|
||||
console_handler.setLevel(logging.DEBUG)
|
||||
@@ -407,6 +412,7 @@ def initHooks(global_exceptions=True, thread_exceptions=True, pass_original=True
|
||||
raise
|
||||
except:
|
||||
excepthook(*sys.exc_info())
|
||||
|
||||
self.run = new_run
|
||||
|
||||
# Monkey patch the run() by monkey patching the __init__ method
|
||||
|
Reference in New Issue
Block a user