diff --git a/PlexPy.py b/PlexPy.py
index b601fcee..e57cc8f7 100755
--- a/PlexPy.py
+++ b/PlexPy.py
@@ -27,13 +27,14 @@ import sys
# Ensure lib added to path, before any other imports
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib/'))
-from plexpy import webstart, logger, web_socket
-
-import locale
-import time
-import signal
import argparse
+import locale
+import signal
+import time
+
import plexpy
+from plexpy import logger, web_socket, webstart
+
# Register signals, such as CTRL + C
signal.signal(signal.SIGINT, plexpy.sig_handler)
diff --git a/data/interfaces/default/base.html b/data/interfaces/default/base.html
index 9b1c027d..79599e72 100644
--- a/data/interfaces/default/base.html
+++ b/data/interfaces/default/base.html
@@ -1,7 +1,7 @@
<%
-import plexpy
-from plexpy import version
-from plexpy.helpers import anon_url
+ import plexpy
+ from plexpy import version
+ from plexpy.helpers import anon_url
%>
diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html
index 139b1915..1829e246 100644
--- a/data/interfaces/default/info.html
+++ b/data/interfaces/default/info.html
@@ -36,9 +36,10 @@ DOCUMENTATION :: END
%doc>
<%!
- from plexpy import common
import re
+ from plexpy import common
+
# Get audio codec file
def af(codec):
for pattern, file in common.MEDIA_FLAGS_AUDIO.iteritems():
diff --git a/data/interfaces/default/logs.html b/data/interfaces/default/logs.html
index d9304bbf..4b8e6084 100644
--- a/data/interfaces/default/logs.html
+++ b/data/interfaces/default/logs.html
@@ -1,6 +1,6 @@
<%inherit file="base.html"/>
<%!
-from plexpy import helpers
+ from plexpy import helpers
%>
<%def name="headIncludes()">
diff --git a/data/interfaces/default/notification_config.html b/data/interfaces/default/notification_config.html
index 361d2848..c1950d76 100644
--- a/data/interfaces/default/notification_config.html
+++ b/data/interfaces/default/notification_config.html
@@ -1,5 +1,5 @@
<%!
-from plexpy import helpers
+ from plexpy import helpers
%>
% if data:
diff --git a/data/interfaces/default/notification_triggers_modal.html b/data/interfaces/default/notification_triggers_modal.html
index 2ca564fc..5de454a7 100644
--- a/data/interfaces/default/notification_triggers_modal.html
+++ b/data/interfaces/default/notification_triggers_modal.html
@@ -1,5 +1,5 @@
<%!
-from plexpy import helpers
+ from plexpy import helpers
%>
% if data:
diff --git a/data/interfaces/default/scheduler_table.html b/data/interfaces/default/scheduler_table.html
index d1e4d7e0..29aff91b 100644
--- a/data/interfaces/default/scheduler_table.html
+++ b/data/interfaces/default/scheduler_table.html
@@ -10,11 +10,11 @@ DOCUMENTATION :: END
%doc>
<%!
-import arrow
-import plexpy
-from plexpy import common
+ import arrow
+ import plexpy
+ from plexpy import common
-scheduled_jobs = [j.id for j in plexpy.SCHED.get_jobs()]
+ scheduled_jobs = [j.id for j in plexpy.SCHED.get_jobs()]
%>
diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html
index e75c31b1..f2de5776 100644
--- a/data/interfaces/default/settings.html
+++ b/data/interfaces/default/settings.html
@@ -1,12 +1,13 @@
<%inherit file="base.html"/>
<%!
-import os
-import sys
-import plexpy
-from plexpy import notifiers, common, versioncheck
-from plexpy.helpers import anon_url
+ import os
+ import sys
-available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['name'])
+ import plexpy
+ from plexpy import common, notifiers, versioncheck
+ from plexpy.helpers import anon_url
+
+ available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['name'])
%>
<%def name="headIncludes()">
%def>
diff --git a/data/interfaces/default/user.html b/data/interfaces/default/user.html
index 2773863c..bbb34cfb 100644
--- a/data/interfaces/default/user.html
+++ b/data/interfaces/default/user.html
@@ -26,7 +26,7 @@ DOCUMENTATION :: END
<%inherit file="base.html"/>
<%!
-from plexpy import helpers
+ from plexpy import helpers
%>
<%def name="headIncludes()">
diff --git a/data/interfaces/default/welcome.html b/data/interfaces/default/welcome.html
index ab2e87b2..c728ded5 100644
--- a/data/interfaces/default/welcome.html
+++ b/data/interfaces/default/welcome.html
@@ -1,6 +1,6 @@
<%
-import plexpy
-from plexpy import common
+ import plexpy
+ from plexpy import common
%>
diff --git a/plexpy/__init__.py b/plexpy/__init__.py
index b3c8bd5d..5995f259 100644
--- a/plexpy/__init__.py
+++ b/plexpy/__init__.py
@@ -14,11 +14,10 @@
# along with PlexPy. If not, see .
import os
+import sqlite3
import sys
import subprocess
import threading
-import sqlite3
-import cherrypy
import datetime
import uuid
# Some cut down versions of Python may not include this module and it's not critical for us
@@ -28,10 +27,15 @@ try:
except ImportError:
no_browser = True
+import cherrypy
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger
-from plexpy import versioncheck, logger, activity_pinger, plextv, pmsconnect
+import activity_pinger
+import logger
+import plextv
+import pmsconnect
+import versioncheck
import plexpy.config
PROG_DIR = None
diff --git a/plexpy/activity_handler.py b/plexpy/activity_handler.py
index c5bca198..e20463b1 100644
--- a/plexpy/activity_handler.py
+++ b/plexpy/activity_handler.py
@@ -13,10 +13,16 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
+import threading
import time
-import plexpy
-from plexpy import logger, pmsconnect, activity_processor, threading, notification_handler, helpers, notifiers
+import plexpy
+import activity_processor
+import helpers
+import logger
+import notification_handler
+import notifiers
+import pmsconnect
class ActivityHandler(object):
diff --git a/plexpy/activity_pinger.py b/plexpy/activity_pinger.py
index b5bfc05a..3206dd76 100644
--- a/plexpy/activity_pinger.py
+++ b/plexpy/activity_pinger.py
@@ -13,12 +13,21 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import logger, pmsconnect, plextv, notification_handler, database, helpers, activity_processor, libraries, notifiers
-
import threading
-import plexpy
import time
+import plexpy
+import activity_processor
+import database
+import helpers
+import libraries
+import logger
+import notification_handler
+import notifiers
+import plextv
+import pmsconnect
+
+
monitor_lock = threading.Lock()
ext_ping_count = 0
int_ping_count = 0
diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py
index 8691762b..2484cf61 100644
--- a/plexpy/activity_processor.py
+++ b/plexpy/activity_processor.py
@@ -13,12 +13,19 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import logger, pmsconnect, notification_handler, log_reader, database, notifiers
-
import threading
-import plexpy
-import re
import time
+import re
+
+import plexpy
+import database
+import libraries
+import log_reader
+import logger
+import notification_handler
+import notifiers
+import pmsconnect
+import users
class ActivityProcessor(object):
@@ -102,8 +109,6 @@ class ActivityProcessor(object):
return True
def write_session_history(self, session=None, import_metadata=None, is_import=False, import_ignore_interval=0):
- from plexpy import users, libraries
-
section_id = session['section_id'] if not is_import else import_metadata['section_id']
if not is_import:
diff --git a/plexpy/api.py b/plexpy/api.py
index 6f5c2882..5d1d3b58 100644
--- a/plexpy/api.py
+++ b/plexpy/api.py
@@ -16,17 +16,26 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import versioncheck, logger, plextv, pmsconnect, datafactory, graphs, users
-import os
-import plexpy
import json
-import traceback
-import cherrypy
-import re
import hashlib
+import os
import random
+import re
+import traceback
+
+import cherrypy
import xmltodict
+import plexpy
+import datafactory
+import graphs
+import logger
+import plextv
+import pmsconnect
+import users
+import versioncheck
+
+
cmd_list = ['getLogs', 'getVersion', 'checkGithub', 'shutdown',
'getSettings', 'restart', 'update', 'getApikey', 'getHistory',
'getMetadata', 'getUserips', 'getPlayby', 'getSync']
diff --git a/plexpy/api2.py b/plexpy/api2.py
index 27a09787..d120eb7b 100644
--- a/plexpy/api2.py
+++ b/plexpy/api2.py
@@ -23,15 +23,17 @@ import json
import os
import random
import re
+import threading
import time
import traceback
import cherrypy
import xmltodict
+import plexpy
import database
import logger
-import plexpy
+import pmsconnect
class API2:
@@ -301,6 +303,10 @@ class API2:
self.msg = 'Updating plexpy'
self.result_type = 'success'
+ def refresh_libraries_list(self, **kwargs):
+ threading.Thread(target=pmsconnect.refresh_libraries).start()
+ self.result_type = 'success'
+
def _api_make_md(self):
""" Tries to make a API.md to simplify the api docs """
diff --git a/plexpy/common.py b/plexpy/common.py
index 440c4728..31797826 100644
--- a/plexpy/common.py
+++ b/plexpy/common.py
@@ -20,7 +20,7 @@ Created on Aug 1, 2011
'''
import platform
-from plexpy import version
+import version
# Identify Our Application
USER_AGENT = 'PlexPy/-' + version.PLEXPY_VERSION + ' v' + version.PLEXPY_RELEASE_VERSION + ' (' + platform.system() + \
diff --git a/plexpy/config.py b/plexpy/config.py
index 2e3fd575..19230bed 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -1,7 +1,24 @@
-import plexpy.logger
+# This file is part of PlexPy.
+#
+# PlexPy is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PlexPy is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with PlexPy. If not, see .
+
import re
+
from configobj import ConfigObj
+import logger
+
def bool_int(value):
"""
@@ -484,7 +501,7 @@ class Config(object):
subkey.upper() not in _WHITELIST_KEYS and any(bk in subkey.upper() for bk in _BLACKLIST_KEYS):
blacklist.append(value.strip())
- plexpy.logger._BLACKLIST_WORDS = blacklist
+ logger._BLACKLIST_WORDS = blacklist
def _define(self, name):
key = name.upper()
@@ -537,12 +554,12 @@ class Config(object):
new_config[section][ini_key] = self._config[section][ini_key]
# Write it to file
- plexpy.logger.info("Writing configuration to file")
+ logger.info("Writing configuration to file")
try:
new_config.write()
except IOError as e:
- plexpy.logger.error("Error writing configuration file: %s", e)
+ logger.error("Error writing configuration file: %s", e)
self._blacklist()
diff --git a/plexpy/database.py b/plexpy/database.py
index 6dca1ac2..2331d6ca 100644
--- a/plexpy/database.py
+++ b/plexpy/database.py
@@ -20,9 +20,8 @@ import shutil
import threading
import time
-import logger
import plexpy
-
+import logger
db_lock = threading.Lock()
diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py
index 58558bda..f601bcc2 100644
--- a/plexpy/datafactory.py
+++ b/plexpy/datafactory.py
@@ -15,7 +15,14 @@
import datetime
-from plexpy import logger, datatables, common, database, helpers, session
+import plexpy
+import common
+import database
+import datatables
+import helpers
+import logger
+import pmsconnect
+import session
class DataFactory(object):
@@ -1126,7 +1133,6 @@ class DataFactory(object):
return 'Unable to delete rows. Input row not valid.'
def update_metadata(self, old_key_list='', new_key_list='', media_type=''):
- from plexpy import pmsconnect
pms_connect = pmsconnect.PmsConnect()
monitor_db = database.MonitorDatabase()
diff --git a/plexpy/datatables.py b/plexpy/datatables.py
index 293c3b59..8b068c3b 100644
--- a/plexpy/datatables.py
+++ b/plexpy/datatables.py
@@ -13,10 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import logger, helpers, database
-
import re
+import plexpy
+import database
+import helpers
+import logger
+
class DataTables(object):
"""
diff --git a/plexpy/graphs.py b/plexpy/graphs.py
index a6fe81df..04e4a3d2 100644
--- a/plexpy/graphs.py
+++ b/plexpy/graphs.py
@@ -13,11 +13,15 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import logger, database, helpers, common, session
-import plexpy
-
import datetime
+import plexpy
+import common
+import database
+import helpers
+import logger
+import session
+
class Graphs(object):
diff --git a/plexpy/helpers.py b/plexpy/helpers.py
index 94a5ff3c..9227da68 100644
--- a/plexpy/helpers.py
+++ b/plexpy/helpers.py
@@ -35,7 +35,8 @@ from xml.dom import minidom
import xmltodict
import plexpy
-from plexpy import common
+import common
+import logger
from plexpy.api2 import API2
@@ -388,9 +389,6 @@ def create_https_certificates(ssl_cert, ssl_key):
This code is stolen from SickBeard (http://github.com/midgetspy/Sick-Beard).
"""
-
- from plexpy import logger
-
from OpenSSL import crypto
from certgen import createKeyPair, createSelfSignedCertificate, TYPE_RSA
@@ -455,8 +453,6 @@ def get_percent(value1, value2):
return math.trunc(percent)
def parse_xml(unparsed=None):
- from plexpy import logger
-
if unparsed:
try:
xml_parse = minidom.parseString(unparsed)
@@ -508,7 +504,6 @@ def is_ip_public(host):
return False
def get_ip(host):
- from plexpy import logger
ip_address = ''
try:
socket.inet_aton(host)
@@ -530,8 +525,6 @@ def anon_url(*url):
return '' if None in url else '%s%s' % (plexpy.CONFIG.ANON_REDIRECT, ''.join(str(s) for s in url))
def uploadToImgur(imgPath, imgTitle=''):
- from plexpy import logger
-
client_id = '743b1a443ccd2b0'
img_url = ''
@@ -572,8 +565,6 @@ def cache_image(url, image=None):
Saves an image to the cache directory.
If no image is provided, tries to return the image from the cache directory.
"""
- from plexpy import logger
-
# Create image directory if it doesn't exist
imgdir = os.path.join(plexpy.CONFIG.CACHE_DIR, 'images/')
if not os.path.exists(imgdir):
diff --git a/plexpy/http_handler.py b/plexpy/http_handler.py
index 2c6561e7..89606362 100644
--- a/plexpy/http_handler.py
+++ b/plexpy/http_handler.py
@@ -19,7 +19,10 @@
from httplib import HTTPSConnection
from httplib import HTTPConnection
import ssl
-from plexpy import logger, helpers
+
+import plexpy
+import helpers
+import logger
class HTTPHandler(object):
diff --git a/plexpy/libraries.py b/plexpy/libraries.py
index f7228c92..d671b601 100644
--- a/plexpy/libraries.py
+++ b/plexpy/libraries.py
@@ -13,12 +13,22 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
+import json
+import os
+
import plexpy
-from plexpy import logger, datatables, common, database, helpers, session
+import activity_pinger
+import common
+import database
+import datatables
+import helpers
+import logger
+import plextv
+import pmsconnect
+import session
+
def update_section_ids():
- from plexpy import pmsconnect, activity_pinger
-
plexpy.CONFIG.UPDATE_SECTION_IDS = -1
monitor_db = database.MonitorDatabase()
@@ -88,8 +98,6 @@ def update_section_ids():
return True
def update_labels():
- from plexpy import pmsconnect
-
plexpy.CONFIG.UPDATE_LABELS = -1
monitor_db = database.MonitorDatabase()
@@ -291,9 +299,6 @@ class Libraries(object):
return dict
def get_datatables_media_info(self, section_id=None, section_type=None, rating_key=None, refresh=False, kwargs=None):
- from plexpy import pmsconnect
- import json, os
-
default_return = {'recordsFiltered': 0,
'recordsTotal': 0,
'draw': 0,
@@ -505,9 +510,6 @@ class Libraries(object):
return dict
def get_media_info_file_sizes(self, section_id=None, rating_key=None):
- from plexpy import pmsconnect
- import json, os
-
if not session.allow_session_library(section_id):
return False
@@ -605,8 +607,6 @@ class Libraries(object):
logger.warn(u"PlexPy Libraries :: Unable to execute database query for set_config: %s." % e)
def get_details(self, section_id=None):
- from plexpy import pmsconnect
-
default_return = {'section_id': 0,
'section_name': 'Local',
'section_type': '',
@@ -950,8 +950,6 @@ class Libraries(object):
logger.warn(u"PlexPy Libraries :: Unable to delete media info table cache: %s." % e)
def delete_duplicate_libraries(self):
- from plexpy import plextv
-
monitor_db = database.MonitorDatabase()
# Refresh the PMS_URL to make sure the server_id is updated
diff --git a/plexpy/log_reader.py b/plexpy/log_reader.py
index c251e210..f493a757 100644
--- a/plexpy/log_reader.py
+++ b/plexpy/log_reader.py
@@ -13,10 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import helpers, logger
-import re
import os
+import re
+
import plexpy
+import helpers
+import logger
def get_log_tail(window=20, parsed=True, log_type="server"):
diff --git a/plexpy/logger.py b/plexpy/logger.py
index 75e84c67..0ab56bf1 100644
--- a/plexpy/logger.py
+++ b/plexpy/logger.py
@@ -13,21 +13,21 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import helpers
-
from logutils.queue import QueueHandler, QueueListener
from logging import handlers
-import multiprocessing
import contextlib
-import plexpy
-import threading
-import traceback
-import logging
import errno
-import sys
+import logging
+import multiprocessing
import os
import re
+import sys
+import threading
+import traceback
+
+import plexpy
+import helpers
# These settings are for file logging only
FILENAME = "plexpy.log"
diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py
index 690bc575..eb64d20e 100644
--- a/plexpy/notification_handler.py
+++ b/plexpy/notification_handler.py
@@ -22,13 +22,19 @@ import threading
import time
import urllib
-from plexpy import logger, config, notifiers, database, helpers, plextv, pmsconnect, datafactory
import plexpy
-
+import config
+import database
+import datafactory
+import libraries
+import logger
+import helpers
+import notifiers
+import plextv
+import pmsconnect
+import users
def notify(stream_data=None, notify_action=None):
- from plexpy import users, libraries
-
if stream_data and notify_action:
# Check if notifications enabled for user and library
user_data = users.Users()
diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py
index efb9bf07..00a48534 100644
--- a/plexpy/notifiers.py
+++ b/plexpy/notifiers.py
@@ -42,7 +42,10 @@ import pythontwitter as twitter
import pythonfacebook as facebook
import plexpy
-from plexpy import logger, helpers, request, database
+import database
+import helpers
+import logger
+import request
from plexpy.helpers import checked
AGENT_IDS = {"Growl": 0,
diff --git a/plexpy/plextv.py b/plexpy/plextv.py
index 74e21881..0ff2d989 100644
--- a/plexpy/plextv.py
+++ b/plexpy/plextv.py
@@ -22,7 +22,13 @@ import xmltodict
from xml.dom import minidom
import plexpy
-from plexpy import logger, helpers, http_handler, database, users, session, pmsconnect
+import database
+import helpers
+import http_handler
+import logger
+import users
+import pmsconnect
+import session
def refresh_users():
diff --git a/plexpy/plexwatch_import.py b/plexpy/plexwatch_import.py
index 2ddbe673..0ece4a27 100644
--- a/plexpy/plexwatch_import.py
+++ b/plexpy/plexwatch_import.py
@@ -14,11 +14,17 @@
# along with PlexPy. If not, see .
import sqlite3
-
-from plexpy import logger, helpers, activity_pinger, activity_processor, users, plextv
from xml.dom import minidom
import plexpy
+import activity_pinger
+import activity_processor
+import database
+import helpers
+import logger
+import plextv
+import users
+
def extract_plexwatch_xml(xml=None):
output = {}
@@ -408,8 +414,6 @@ def import_from_plexwatch(database=None, table_name=None, import_ignore_interval
plexpy.initialize_scheduler()
def import_users():
- from plexpy import database
-
logger.debug(u"PlexPy Importer :: Importing PlexWatch Users...")
monitor_db = database.MonitorDatabase()
diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py
index 5d42c15f..4cd1e23e 100644
--- a/plexpy/pmsconnect.py
+++ b/plexpy/pmsconnect.py
@@ -13,11 +13,19 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
+import threading
import urllib2
from urlparse import urlparse
import plexpy
-from plexpy import logger, helpers, users, http_handler, common, database, session
+import common
+import database
+import helpers
+import http_handler
+import libraries
+import logger
+import session
+import users
def get_server_friendly_name():
@@ -78,16 +86,10 @@ def refresh_libraries():
plexpy.CONFIG.write()
if plexpy.CONFIG.UPDATE_SECTION_IDS == 1 or plexpy.CONFIG.UPDATE_SECTION_IDS == -1:
- from plexpy import libraries
- import threading
-
# Start library section_id update on it's own thread
threading.Thread(target=libraries.update_section_ids).start()
if plexpy.CONFIG.UPDATE_LABELS == 1 or plexpy.CONFIG.UPDATE_LABELS == -1:
- from plexpy import libraries
- import threading
-
# Start library labels update on it's own thread
threading.Thread(target=libraries.update_labels).start()
diff --git a/plexpy/request.py b/plexpy/request.py
index c61b1f6a..33b15e97 100644
--- a/plexpy/request.py
+++ b/plexpy/request.py
@@ -13,16 +13,17 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import logger
-
-from xml.dom import minidom
from bs4 import BeautifulSoup
+from xml.dom import minidom
-import requests
import feedparser
+import collections
+import requests
+
import plexpy
import plexpy.lock
-import collections
+import logger
+
# Dictionary with last request times, for rate limiting.
last_requests = collections.defaultdict(int)
diff --git a/plexpy/session.py b/plexpy/session.py
index 7daf4803..9ab9a313 100644
--- a/plexpy/session.py
+++ b/plexpy/session.py
@@ -15,7 +15,9 @@
import cherrypy
-from plexpy import common
+import plexpy
+import common
+import users
def get_session_info():
@@ -51,7 +53,6 @@ def get_session_shared_libraries():
"""
Returns a tuple of section_id for the current logged in session
"""
- from plexpy import users
user_details = users.Users().get_details(user_id=get_session_user_id())
return tuple(str(s) for s in user_details['shared_libraries'])
@@ -63,7 +64,6 @@ def get_session_library_filters():
'labels': ('label1', label2')},
"""
- from plexpy import users
filters = users.Users().get_filters(user_id=get_session_user_id())
return filters
diff --git a/plexpy/users.py b/plexpy/users.py
index 60c29f26..6c063ed4 100644
--- a/plexpy/users.py
+++ b/plexpy/users.py
@@ -14,7 +14,14 @@
# along with PlexPy. If not, see .
import plexpy
-from plexpy import logger, datatables, common, database, helpers, session
+import common
+import database
+import datatables
+import helpers
+import logger
+import plextv
+import session
+
class Users(object):
@@ -254,8 +261,6 @@ class Users(object):
logger.warn(u"PlexPy Users :: Unable to execute database query for set_config: %s." % e)
def get_details(self, user_id=None, user=None, email=None):
- from plexpy import plextv
-
default_return = {'user_id': 0,
'username': 'Local',
'friendly_name': 'Local',
diff --git a/plexpy/versioncheck.py b/plexpy/versioncheck.py
index 23bc9566..a2106c4c 100644
--- a/plexpy/versioncheck.py
+++ b/plexpy/versioncheck.py
@@ -13,14 +13,16 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-import re
import os
-import tarfile
import platform
-import plexpy
+import re
import subprocess
+import tarfile
-from plexpy import logger, version, request
+import plexpy
+import logger
+import request
+import version
def runGit(args):
diff --git a/plexpy/web_socket.py b/plexpy/web_socket.py
index 9112a0dc..57b202ac 100644
--- a/plexpy/web_socket.py
+++ b/plexpy/web_socket.py
@@ -15,14 +15,17 @@
# Mostly borrowed from https://github.com/trakt/Plex-Trakt-Scrobbler
-from plexpy import logger, activity_pinger
-
-import threading
-import plexpy
import json
+import threading
import time
+
import websocket
+import plexpy
+import activity_handler
+import activity_pinger
+import logger
+
name = 'websocket'
opcode_data = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY)
ws_reconnect = False
@@ -132,8 +135,6 @@ def receive(ws):
def process(opcode, data):
- from plexpy import activity_handler
-
if opcode not in opcode_data:
return False
diff --git a/plexpy/webauth.py b/plexpy/webauth.py
index cd1981a4..57937638 100644
--- a/plexpy/webauth.py
+++ b/plexpy/webauth.py
@@ -19,13 +19,15 @@
# Session tool to be loaded.
from cgi import escape
-import cherrypy
from datetime import datetime, timedelta
-from hashing_passwords import check_hash
import re
+import cherrypy
+from hashing_passwords import check_hash
+
import plexpy
-from plexpy import logger, plextv
+import logger
+import plextv
from plexpy.database import MonitorDatabase
from plexpy.users import Users
from plexpy.plextv import PlexTV
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index 5a546750..ab67394e 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -13,24 +13,38 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-import cherrypy
import hashlib
import json
import os
import random
import threading
+import cherrypy
from hashing_passwords import make_hash
from mako.lookup import TemplateLookup
from mako import exceptions
import plexpy
-from plexpy import logger, notifiers, plextv, pmsconnect, common, log_reader, \
- datafactory, graphs, users, libraries, database, web_socket
+import common
+import database
+import datafactory
+import graphs
+import http_handler
+import libraries
+import log_reader
+import logger
+import notifiers
+import plextv
+import plexwatch_import
+import pmsconnect
+import users
+import versioncheck
+import web_socket
+from plexpy.api import Api
from plexpy.api2 import API2
from plexpy.helpers import checked, addtoapi, get_ip, create_https_certificates
from plexpy.session import get_session_info, get_session_user_id, allow_session_user, allow_session_library
-from plexpy.webauth import AuthController, requireAuth, member_of, name_is, SESSION_KEY
+from plexpy.webauth import AuthController, requireAuth, member_of, name_is
def serve_template(templatename, **kwargs):
diff --git a/plexpy/webstart.py b/plexpy/webstart.py
index 07d85c0f..0ffc6a8a 100644
--- a/plexpy/webstart.py
+++ b/plexpy/webstart.py
@@ -16,14 +16,14 @@
import os
import sys
-import cherrypy
-from plexpy import logger, webauth
import plexpy
+import cherrypy
+import logger
+import webauth
from plexpy.helpers import create_https_certificates
from plexpy.webserve import WebInterface
-
def initialize(options):
# HTTPS stuff stolen from sickbeard