Optimize some imports

This commit is contained in:
tomkat83 2017-12-09 14:35:08 +01:00
parent 73c7f866e6
commit cdd38c6ef7
23 changed files with 61 additions and 65 deletions

View File

@ -30,7 +30,7 @@ http://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-pyt
(and others...)
"""
import logging
from logging import getLogger
from time import time
import urllib2
import socket
@ -57,7 +57,7 @@ import state
###############################################################################
log = logging.getLogger("PLEX." + __name__)
log = getLogger("PLEX." + __name__)
REGEX_IMDB = re_compile(r'''/(tt\d+)''')
REGEX_TVDB = re_compile(r'''thetvdb:\/\/(.+?)\?''')

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import logging
from logging import getLogger
from threading import Thread
import Queue
from Queue import Queue, Empty
from socket import SHUT_RDWR
from urllib import urlencode
@ -19,7 +19,7 @@ import state
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################
@ -39,7 +39,7 @@ class PlexCompanion(Thread):
log.debug("Registration string is:\n%s"
% self.client.getClientDetails())
# kodi player instance
self.player = player.Player()
self.player = player.PKC_Player()
Thread.__init__(self)
@ -199,7 +199,7 @@ class PlexCompanion(Thread):
subscriptionManager = subscribers.SubscriptionManager(
requestMgr, self.player, self.mgr)
queue = Queue.Queue(maxsize=100)
queue = Queue(maxsize=100)
self.queue = queue
if settings('plexCompanion') == 'true':
@ -276,7 +276,7 @@ class PlexCompanion(Thread):
# See if there's anything we need to process
try:
task = queue.get(block=False)
except Queue.Empty:
except Empty:
pass
else:
# Got instructions, process them

View File

@ -2,11 +2,11 @@
###############################################################################
from logging import getLogger
import requests
from Queue import Queue, Empty
from shutil import rmtree
from urllib import quote_plus, unquote
from threading import Thread
from Queue import Queue, Empty
import requests
import json_rpc as js
from xbmc import sleep, translatePath

View File

@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from utils import window, settings
import variables as v
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
import xbmc

View File

@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
import requests
from logging import getLogger
import xml.etree.ElementTree as etree
import requests
from utils import settings, window, language as lang, dialog
import clientinfo as client
@ -17,7 +16,7 @@ import state
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from shutil import copyfile
from os import walk, makedirs
from os.path import basename, join
@ -22,7 +22,7 @@ import json_rpc as js
import variables as v
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
try:
HANDLE = int(argv[1])

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
###############################################################################
from logging import getLogger
import logging
import xbmc
import xbmcgui
@ -18,7 +18,7 @@ from migration import check_migration
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from urllib import urlencode
from ntpath import dirname
from datetime import datetime
@ -20,7 +19,7 @@ import state
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -2,10 +2,13 @@
Collection of functions using the Kodi JSON RPC interface.
See http://kodi.wiki/view/JSON-RPC_API
"""
from logging import getLogger
from json import loads, dumps
from utils import millis_to_kodi_time
from xbmc import executeJSONRPC
log = getLogger("PLEX."+__name__)
class jsonrpc(object):
"""

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from ntpath import dirname
import artwork
@ -11,7 +10,7 @@ import variables as v
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
###############################################################################
from logging import getLogger
from json import loads

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from threading import Thread
from urlparse import parse_qsl
@ -21,7 +21,7 @@ from context_entry import ContextMenu
import state
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from urllib import urlencode
from threading import Thread
@ -26,7 +25,7 @@ import state
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
import json
from logging import getLogger
from json import loads
import xbmc
from xbmc import Player, sleep
from utils import window, DateToKodi, getUnixTimestamp, tryDecode, tryEncode
import downloadutils
@ -16,12 +16,12 @@ import state
###############################################################################
LOG = logging.getLogger("PLEX." + __name__)
LOG = getLogger("PLEX." + __name__)
###############################################################################
class Player(xbmc.Player):
class PKC_Player(Player):
played_info = state.PLAYED_INFO
playStats = state.PLAYER_STATES
@ -29,7 +29,7 @@ class Player(xbmc.Player):
def __init__(self):
self.doUtils = downloadutils.DownloadUtils
xbmc.Player.__init__(self)
Player.__init__(self)
LOG.info("Started playback monitor.")
def onPlayBackStarted(self):
@ -42,12 +42,12 @@ class Player(xbmc.Player):
# Get current file (in utf-8!)
try:
currentFile = tryDecode(self.getPlayingFile())
xbmc.sleep(300)
sleep(300)
except:
currentFile = ""
count = 0
while not currentFile:
xbmc.sleep(100)
sleep(100)
try:
currentFile = tryDecode(self.getPlayingFile())
except:
@ -67,7 +67,7 @@ class Player(xbmc.Player):
itemId = window("plex_%s.itemid" % tryEncode(currentFile))
count = 0
while not itemId:
xbmc.sleep(200)
sleep(200)
itemId = window("plex_%s.itemid" % tryEncode(currentFile))
if count == 5:
LOG.warn("Could not find itemId, cancelling playback report!")
@ -142,17 +142,17 @@ class Player(xbmc.Player):
postdata['AudioStreamIndex'] = indexAudio + 1
# Postdata for the subtitles
if subsEnabled and len(xbmc.Player().getAvailableSubtitleStreams()) > 0:
if subsEnabled and len(Player().getAvailableSubtitleStreams()) > 0:
# Number of audiotracks to help get plex Index
audioTracks = len(xbmc.Player().getAvailableAudioStreams())
audioTracks = len(Player().getAvailableAudioStreams())
mapping = window("%s.indexMapping" % plexitem)
if mapping: # Set in playbackutils.py
LOG.debug("Mapping for external subtitles index: %s"
% mapping)
externalIndex = json.loads(mapping)
externalIndex = loads(mapping)
if externalIndex.get(str(indexSubs)):
# If the current subtitle is in the mapping

View File

@ -1,7 +1,7 @@
"""
Collection of functions associated with Kodi and Plex playlists and playqueues
"""
import logging
from logging import getLogger
from urllib import quote
from urlparse import parse_qsl, urlsplit
from re import compile as re_compile
@ -15,7 +15,7 @@ import json_rpc as js
###############################################################################
LOG = logging.getLogger("PLEX." + __name__)
LOG = getLogger("PLEX." + __name__)
REGEX = re_compile(r'''metadata%2F(\d+)''')
###############################################################################

View File

@ -1,7 +1,7 @@
"""
Monitors the Kodi playqueue and adjusts the Plex playqueue accordingly
"""
import logging
from logging import getLogger
from threading import RLock, Thread
from xbmc import sleep, Player, PlayList, PLAYLIST_MUSIC, PLAYLIST_VIDEO
@ -15,7 +15,7 @@ import json_rpc as js
import variables as v
###############################################################################
LOG = logging.getLogger("PLEX." + __name__)
LOG = getLogger("PLEX." + __name__)
# lock used for playqueue manipulations
LOCK = RLock()

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from downloadutils import DownloadUtils
from utils import window, settings, tryEncode, language as lang, dialog
@ -10,7 +10,7 @@ import PlexAPI
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
###############################################################################
from logging import getLogger
from utils import kodiSQL
import logging
import variables as v
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
import threading
from logging import getLogger
from threading import Thread
import xbmc
import xbmcgui
@ -19,13 +19,13 @@ import state
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################
@thread_methods(add_suspends=['SUSPEND_USER_CLIENT'])
class UserClient(threading.Thread):
class UserClient(Thread):
# Borg - multiple instances, shared state
__shared_state = {}
@ -49,7 +49,7 @@ class UserClient(threading.Thread):
self.addon = xbmcaddon.Addon()
self.doUtils = downloadutils.DownloadUtils()
threading.Thread.__init__(self)
Thread.__init__(self)
def getUsername(self):
"""

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from cProfile import Profile
from pstats import Stats
from sqlite3 import connect, OperationalError
@ -28,7 +28,7 @@ import state
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
WINDOW = xbmcgui.Window(10000)
ADDON = xbmcaddon.Addon(id='plugin.video.plexkodiconnect')

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
from shutil import copytree
import xml.etree.ElementTree as etree
from os import makedirs
@ -14,7 +14,7 @@ import variables as v
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################
# Paths are strings, NOT unicode!

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
###############################################################################
import logging
from logging import getLogger
import websocket
from json import loads
import xml.etree.ElementTree as etree
@ -17,7 +17,7 @@ import state
###############################################################################
log = logging.getLogger("PLEX."+__name__)
log = getLogger("PLEX."+__name__)
###############################################################################