mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 10:36:57 -07:00
Cleanup unused modules and imports
* Ran code through PyFlakes
This commit is contained in:
parent
325fa19e46
commit
cb8a5504f6
290 changed files with 45 additions and 78157 deletions
|
@ -32,6 +32,8 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|||
from apscheduler.triggers.interval import IntervalTrigger
|
||||
|
||||
import activity_pinger
|
||||
import config
|
||||
import database
|
||||
import logger
|
||||
import plextv
|
||||
import pmsconnect
|
||||
|
@ -132,7 +134,7 @@ def initialize(config_file):
|
|||
try:
|
||||
os.makedirs(CONFIG.BACKUP_DIR)
|
||||
except OSError as e:
|
||||
logger.error("Could not create backup dir '%s': %s" % (BACKUP_DIR, e))
|
||||
logger.error("Could not create backup dir '%s': %s" % (CONFIG.BACKUP_DIR, e))
|
||||
|
||||
if not CONFIG.CACHE_DIR:
|
||||
CONFIG.CACHE_DIR = os.path.join(DATA_DIR, 'cache')
|
||||
|
@ -140,7 +142,7 @@ def initialize(config_file):
|
|||
try:
|
||||
os.makedirs(CONFIG.CACHE_DIR)
|
||||
except OSError as e:
|
||||
logger.error("Could not create cache dir '%s': %s" % (CACHE_DIR, e))
|
||||
logger.error("Could not create cache dir '%s': %s" % (CONFIG.CACHE_DIR, e))
|
||||
|
||||
# Initialize the database
|
||||
logger.info('Checking to see if the database has all tables....')
|
||||
|
|
|
@ -24,7 +24,6 @@ import libraries
|
|||
import logger
|
||||
import notification_handler
|
||||
import notifiers
|
||||
import plextv
|
||||
import pmsconnect
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import cherrypy
|
|||
import xmltodict
|
||||
|
||||
import plexpy
|
||||
import database
|
||||
import datafactory
|
||||
import graphs
|
||||
import logger
|
||||
|
@ -161,8 +162,8 @@ class Api(object):
|
|||
|
||||
def _dic_from_query(self, query):
|
||||
|
||||
myDB = database.DBConnection()
|
||||
rows = myDB.select(query)
|
||||
db = database.MonitorDatabase()
|
||||
rows = db.select(query)
|
||||
|
||||
rows_as_dic = []
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import json
|
|||
import os
|
||||
import random
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ class MonitorDatabase(object):
|
|||
# Our transaction was successful, leave the loop
|
||||
break
|
||||
|
||||
except sqlite3.OperationalError, e:
|
||||
except sqlite3.OperationalError as e:
|
||||
if "unable to open database file" in e.message or "database is locked" in e.message:
|
||||
logger.warn(u"PlexPy Database :: Database Error: %s", e)
|
||||
attempts += 1
|
||||
|
@ -154,7 +154,7 @@ class MonitorDatabase(object):
|
|||
logger.error(u"PlexPy Database :: Database error: %s", e)
|
||||
raise
|
||||
|
||||
except sqlite3.DatabaseError, e:
|
||||
except sqlite3.DatabaseError as e:
|
||||
logger.error(u"PlexPy Database :: Fatal Error executing %s :: %s", query, e)
|
||||
raise
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
|
||||
import plexpy
|
||||
import common
|
||||
import database
|
||||
|
@ -1215,7 +1213,7 @@ class DataFactory(object):
|
|||
'grandparent_thumb = ?, art = ?, media_type = ?, year = ?, originally_available_at = ?, ' \
|
||||
'added_at = ?, updated_at = ?, last_viewed_at = ?, content_rating = ?, summary = ?, ' \
|
||||
'tagline = ?, rating = ?, duration = ?, guid = ?, directors = ?, writers = ?, actors = ?, ' \
|
||||
'genres = ?, studio = ? ' \
|
||||
'genres = ?, studio = ?, labels = ? ' \
|
||||
'WHERE rating_key = ?'
|
||||
|
||||
args = [metadata['rating_key'], metadata['parent_rating_key'], metadata['grandparent_rating_key'],
|
||||
|
@ -1225,7 +1223,7 @@ class DataFactory(object):
|
|||
metadata['year'], metadata['originally_available_at'], metadata['added_at'], metadata['updated_at'],
|
||||
metadata['last_viewed_at'], metadata['content_rating'], metadata['summary'], metadata['tagline'],
|
||||
metadata['rating'], metadata['duration'], metadata['guid'], directors, writers, actors, genres,
|
||||
metadata['studio'],
|
||||
metadata['studio'], labels,
|
||||
old_rating_key]
|
||||
|
||||
monitor_db.action(query=query, args=args)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
import re
|
||||
|
||||
import plexpy
|
||||
import database
|
||||
import helpers
|
||||
import logger
|
||||
|
|
|
@ -18,7 +18,6 @@ import datetime
|
|||
import plexpy
|
||||
import common
|
||||
import database
|
||||
import helpers
|
||||
import logger
|
||||
import session
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
import base64
|
||||
import datetime
|
||||
import fnmatch
|
||||
from functools import wraps
|
||||
import hashlib
|
||||
import imghdr
|
||||
|
@ -25,7 +24,6 @@ import math
|
|||
from operator import itemgetter
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
|
@ -35,7 +33,6 @@ from xml.dom import minidom
|
|||
import xmltodict
|
||||
|
||||
import plexpy
|
||||
import common
|
||||
import logger
|
||||
from plexpy.api2 import API2
|
||||
|
||||
|
@ -457,7 +454,7 @@ def parse_xml(unparsed=None):
|
|||
try:
|
||||
xml_parse = minidom.parseString(unparsed)
|
||||
return xml_parse
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.warn("Error parsing XML. %s" % e)
|
||||
return []
|
||||
except:
|
||||
|
|
|
@ -70,7 +70,6 @@ class HTTPHandler(object):
|
|||
else:
|
||||
handler = HTTPConnection(host=self.host, port=self.port, timeout=timeout)
|
||||
|
||||
token_string = ''
|
||||
if not no_token:
|
||||
if headers:
|
||||
headers.update({'X-Plex-Token': self.token})
|
||||
|
@ -86,10 +85,10 @@ class HTTPHandler(object):
|
|||
request_status = response.status
|
||||
request_content = response.read()
|
||||
content_type = response.getheader('content-type')
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
logger.warn(u"Failed to access uri endpoint %s with error %s" % (uri, e))
|
||||
return None
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.warn(u"Failed to access uri endpoint %s. Is your server maybe accepting SSL connections only? %s" % (uri, e))
|
||||
return None
|
||||
except:
|
||||
|
|
|
@ -17,7 +17,6 @@ import json
|
|||
import os
|
||||
|
||||
import plexpy
|
||||
import activity_pinger
|
||||
import common
|
||||
import database
|
||||
import datatables
|
||||
|
@ -140,7 +139,7 @@ def update_labels():
|
|||
|
||||
if library_children:
|
||||
children_list = library_children['childern_list']
|
||||
rating_key_list = [child['rating_key'] for child in children_list]
|
||||
# rating_key_list = [child['rating_key'] for child in children_list]
|
||||
|
||||
for rating_key in [child['rating_key'] for child in children_list]:
|
||||
if key_mappings.get(rating_key):
|
||||
|
@ -606,7 +605,7 @@ class Libraries(object):
|
|||
'keep_history': keep_history}
|
||||
try:
|
||||
monitor_db.upsert('library_sections', value_dict, key_dict)
|
||||
except:
|
||||
except Exception as e:
|
||||
logger.warn(u"PlexPy Libraries :: Unable to execute database query for set_config: %s." % e)
|
||||
|
||||
def get_details(self, section_id=None):
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
import plexpy
|
||||
import helpers
|
||||
|
@ -33,7 +32,7 @@ def get_log_tail(window=20, parsed=True, log_type="server"):
|
|||
|
||||
try:
|
||||
logfile = open(log_file, "r")
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
logger.error('Unable to open Plex Log file. %s' % e)
|
||||
return []
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import threading
|
|||
import time
|
||||
|
||||
import plexpy
|
||||
import config
|
||||
import database
|
||||
import datafactory
|
||||
import libraries
|
||||
|
@ -777,14 +776,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
|||
if on_start_subject and on_start_body:
|
||||
try:
|
||||
subject_text = unicode(on_start_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_start_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -801,14 +800,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
|||
if on_stop_subject and on_stop_body:
|
||||
try:
|
||||
subject_text = unicode(on_stop_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_stop_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -825,14 +824,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
|||
if on_pause_subject and on_pause_body:
|
||||
try:
|
||||
subject_text = unicode(on_pause_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_pause_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -849,14 +848,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
|||
if on_resume_subject and on_resume_body:
|
||||
try:
|
||||
subject_text = unicode(on_resume_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_resume_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -873,14 +872,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
|||
if on_buffer_subject and on_buffer_body:
|
||||
try:
|
||||
subject_text = unicode(on_buffer_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_buffer_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -897,14 +896,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
|||
if on_watched_subject and on_watched_body:
|
||||
try:
|
||||
subject_text = unicode(on_watched_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_watched_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -919,14 +918,14 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
|||
if on_created_subject and on_created_body:
|
||||
try:
|
||||
subject_text = unicode(on_created_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_created_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -1009,14 +1008,14 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
|||
if on_extdown_subject and on_extdown_body:
|
||||
try:
|
||||
subject_text = unicode(on_extdown_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_extdown_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -1032,14 +1031,14 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
|||
if on_intdown_subject and on_intdown_body:
|
||||
try:
|
||||
subject_text = unicode(on_intdown_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_intdown_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -1054,14 +1053,14 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
|||
if on_extup_subject and on_extup_body:
|
||||
try:
|
||||
subject_text = unicode(on_extup_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_extup_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -1076,14 +1075,14 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
|||
if on_intup_subject and on_intup_body:
|
||||
try:
|
||||
subject_text = unicode(on_intup_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_intup_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
@ -1099,14 +1098,14 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
|||
if on_pmsupdate_subject and on_pmsupdate_body:
|
||||
try:
|
||||
subject_text = unicode(on_pmsupdate_subject).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification subject. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification subject. Using fallback.")
|
||||
|
||||
try:
|
||||
body_text = unicode(on_pmsupdate_body).format(**available_params)
|
||||
except LookupError, e:
|
||||
except LookupError as e:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse field %s in notification body. Using fallback." % e)
|
||||
except:
|
||||
logger.error(u"PlexPy NotificationHandler :: Unable to parse custom notification body. Using fallback.")
|
||||
|
|
|
@ -22,7 +22,6 @@ from email.mime.text import MIMEText
|
|||
import email.utils
|
||||
from httplib import HTTPSConnection
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
import shlex
|
||||
import smtplib
|
||||
|
@ -31,7 +30,7 @@ import time
|
|||
import urllib
|
||||
from urllib import urlencode
|
||||
import urllib2
|
||||
from urlparse import parse_qsl, urlparse
|
||||
from urlparse import urlparse
|
||||
|
||||
import gntp.notifier
|
||||
import facebook
|
||||
|
@ -933,7 +932,7 @@ class NMA(object):
|
|||
|
||||
response = p.push(title, event, message, priority=self.priority, batch_mode=batch)
|
||||
|
||||
if not response[api][u'code'] == u'200':
|
||||
if not response[self.apikey][u'code'] == u'200':
|
||||
logger.warn(u"PlexPy Notifiers :: NotifyMyAndroid notification failed.")
|
||||
return False
|
||||
else:
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import base64
|
||||
import json
|
||||
import xmltodict
|
||||
from xml.dom import minidom
|
||||
|
||||
import plexpy
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
import cherrypy
|
||||
|
||||
import plexpy
|
||||
import common
|
||||
import users
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ def run():
|
|||
reconnects = 0
|
||||
ws_connected = True
|
||||
logger.info(u"PlexPy WebSocket :: Ready")
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
logger.error(u"PlexPy WebSocket :: %s." % e)
|
||||
reconnects += 1
|
||||
time.sleep(5)
|
||||
|
@ -97,7 +97,7 @@ def run():
|
|||
logger.warn(u"PlexPy WebSocket :: Connection has closed, reconnecting...")
|
||||
try:
|
||||
ws = create_connection(uri, header=header)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
logger.info(u"PlexPy WebSocket :: %s." % e)
|
||||
|
||||
else:
|
||||
|
|
|
@ -31,7 +31,6 @@ import plextv
|
|||
from plexpy.database import MonitorDatabase
|
||||
from plexpy.users import Users
|
||||
from plexpy.plextv import PlexTV
|
||||
from plexpy.pmsconnect import PmsConnect
|
||||
|
||||
|
||||
SESSION_KEY = '_cp_username'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue