Added logging decorator
This commit is contained in:
parent
aa849f7457
commit
0d4c8ae53e
23 changed files with 54 additions and 214 deletions
|
@ -60,17 +60,8 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
|
|
||||||
# from Version import __VERSION__
|
|
||||||
# from Debug import * # dprint(), prettyXML()
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
storage for PMS addresses and additional information - now per aTV! (replaces global PMS_list)
|
|
||||||
syntax: PMS[<ATV_UDID>][PMS_UUID][<data>]
|
|
||||||
data: name, ip, ...type (local, myplex)
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class PlexAPI():
|
class PlexAPI():
|
||||||
# CONSTANTS
|
# CONSTANTS
|
||||||
# Timeout for POST/GET commands, I guess in seconds
|
# Timeout for POST/GET commands, I guess in seconds
|
||||||
|
@ -81,7 +72,6 @@ class PlexAPI():
|
||||||
self.__language__ = xbmcaddon.Addon().getLocalizedString
|
self.__language__ = xbmcaddon.Addon().getLocalizedString
|
||||||
self.g_PMS = {}
|
self.g_PMS = {}
|
||||||
client = clientinfo.ClientInfo()
|
client = clientinfo.ClientInfo()
|
||||||
self.addonName = client.getAddonName()
|
|
||||||
self.addonId = client.getAddonId()
|
self.addonId = client.getAddonId()
|
||||||
self.clientId = client.getDeviceId()
|
self.clientId = client.getDeviceId()
|
||||||
self.deviceName = client.getDeviceName()
|
self.deviceName = client.getDeviceName()
|
||||||
|
@ -93,10 +83,6 @@ class PlexAPI():
|
||||||
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
def GetPlexLoginFromSettings(self):
|
def GetPlexLoginFromSettings(self):
|
||||||
"""
|
"""
|
||||||
Returns empty strings if not found.
|
Returns empty strings if not found.
|
||||||
|
@ -1521,6 +1507,7 @@ class PlexAPI():
|
||||||
return xml
|
return xml
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class API():
|
class API():
|
||||||
"""
|
"""
|
||||||
API(item)
|
API(item)
|
||||||
|
@ -1537,7 +1524,6 @@ class API():
|
||||||
# which media part in the XML response shall we look at?
|
# which media part in the XML response shall we look at?
|
||||||
self.part = 0
|
self.part = 0
|
||||||
self.clientinfo = clientinfo.ClientInfo()
|
self.clientinfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientinfo.getAddonName()
|
|
||||||
self.clientId = self.clientinfo.getDeviceId()
|
self.clientId = self.clientinfo.getDeviceId()
|
||||||
self.userId = utils.window('emby_currUser')
|
self.userId = utils.window('emby_currUser')
|
||||||
self.server = utils.window('emby_server%s' % self.userId)
|
self.server = utils.window('emby_server%s' % self.userId)
|
||||||
|
@ -1545,10 +1531,6 @@ class API():
|
||||||
|
|
||||||
self.jumpback = int(utils.settings('resumeJumpBack'))
|
self.jumpback = int(utils.settings('resumeJumpBack'))
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
def setChildNumber(self, number=0):
|
def setChildNumber(self, number=0):
|
||||||
"""
|
"""
|
||||||
Which child in the XML response shall we look at and work with?
|
Which child in the XML response shall we look at and work with?
|
||||||
|
|
|
@ -12,12 +12,12 @@ from plexbmchelper import listener, plexgdm, subscribers
|
||||||
from plexbmchelper.settings import settings
|
from plexbmchelper.settings import settings
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
@utils.ThreadMethods
|
@utils.ThreadMethods
|
||||||
class PlexCompanion(threading.Thread):
|
class PlexCompanion(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.port = int(utils.settings('companionPort'))
|
self.port = int(utils.settings('companionPort'))
|
||||||
ci = clientinfo.ClientInfo()
|
ci = clientinfo.ClientInfo()
|
||||||
self.addonName = ci.getAddonName()
|
|
||||||
self.clientId = ci.getDeviceId()
|
self.clientId = ci.getDeviceId()
|
||||||
self.deviceName = ci.getDeviceName()
|
self.deviceName = ci.getDeviceName()
|
||||||
self.logMsg("----===## Starting PlexBMC Helper ##===----", 1)
|
self.logMsg("----===## Starting PlexBMC Helper ##===----", 1)
|
||||||
|
@ -34,10 +34,6 @@ class PlexCompanion(threading.Thread):
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
start_count = 0
|
start_count = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -12,12 +12,12 @@ import xbmcgui
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
|
||||||
import image_cache_thread
|
import image_cache_thread
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Artwork():
|
class Artwork():
|
||||||
|
|
||||||
xbmc_host = 'localhost'
|
xbmc_host = 'localhost'
|
||||||
|
@ -29,8 +29,6 @@ class Artwork():
|
||||||
imageCacheLimitThreads = 0
|
imageCacheLimitThreads = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.clientinfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientinfo.getAddonName()
|
|
||||||
|
|
||||||
self.enableTextureCache = utils.settings('enableTextureCache') == "true"
|
self.enableTextureCache = utils.settings('enableTextureCache') == "true"
|
||||||
self.imageCacheLimitThreads = int(utils.settings("imageCacheLimit"))
|
self.imageCacheLimitThreads = int(utils.settings("imageCacheLimit"))
|
||||||
|
@ -43,11 +41,6 @@ class Artwork():
|
||||||
self.userId = utils.window('emby_currUser')
|
self.userId = utils.window('emby_currUser')
|
||||||
self.server = utils.window('emby_server%s' % self.userId)
|
self.server = utils.window('emby_server%s' % self.userId)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def double_urlencode(self, text):
|
def double_urlencode(self, text):
|
||||||
text = self.single_urlencode(text)
|
text = self.single_urlencode(text)
|
||||||
text = self.single_urlencode(text)
|
text = self.single_urlencode(text)
|
||||||
|
@ -503,6 +496,7 @@ class Artwork():
|
||||||
% (self.server, itemid, itemtype))
|
% (self.server, itemid, itemtype))
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
def getAllArtwork(self, item, parentInfo=False):
|
def getAllArtwork(self, item, parentInfo=False):
|
||||||
|
|
||||||
server = self.server
|
server = self.server
|
||||||
|
|
|
@ -14,19 +14,13 @@ import utils
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class ClientInfo():
|
class ClientInfo():
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.addon = xbmcaddon.Addon()
|
self.addon = xbmcaddon.Addon()
|
||||||
self.addonName = self.getAddonName()
|
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def getAddonName(self):
|
def getAddonName(self):
|
||||||
# Used for logging
|
# Used for logging
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
import json
|
# import json
|
||||||
import requests
|
import requests
|
||||||
import logging
|
# import logging
|
||||||
|
|
||||||
import xbmc
|
# import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
@ -28,28 +28,21 @@ requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class DownloadUtils():
|
class DownloadUtils():
|
||||||
|
|
||||||
# Borg - multiple instances, shared state
|
# Borg - multiple instances, shared state
|
||||||
_shared_state = {}
|
_shared_state = {}
|
||||||
clientInfo = clientinfo.ClientInfo()
|
clientInfo = clientinfo.ClientInfo()
|
||||||
addonName = clientInfo.getAddonName()
|
|
||||||
|
|
||||||
# Requests session
|
# Requests session
|
||||||
s = None
|
s = None
|
||||||
timeout = 30
|
timeout = 30
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def setUsername(self, username):
|
def setUsername(self, username):
|
||||||
# Reserved for userclient only
|
# Reserved for userclient only
|
||||||
self.username = username
|
self.username = username
|
||||||
|
|
|
@ -3,26 +3,17 @@
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Embydb_Functions():
|
class Embydb_Functions():
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, embycursor):
|
def __init__(self, embycursor):
|
||||||
|
|
||||||
self.embycursor = embycursor
|
self.embycursor = embycursor
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
def getViews(self):
|
def getViews(self):
|
||||||
|
|
||||||
embycursor = self.embycursor
|
embycursor = self.embycursor
|
||||||
|
|
|
@ -21,7 +21,6 @@ import downloadutils
|
||||||
import librarysync
|
import librarysync
|
||||||
import read_embyserver as embyserver
|
import read_embyserver as embyserver
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
import playlist
|
|
||||||
import playbackutils as pbutils
|
import playbackutils as pbutils
|
||||||
import playutils
|
import playutils
|
||||||
import api
|
import api
|
||||||
|
|
|
@ -3,6 +3,8 @@ import utils
|
||||||
import xbmc
|
import xbmc
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class image_cache_thread(threading.Thread):
|
class image_cache_thread(threading.Thread):
|
||||||
|
|
||||||
urlToProcess = None
|
urlToProcess = None
|
||||||
|
@ -16,11 +18,7 @@ class image_cache_thread(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.monitor = xbmc.Monitor()
|
self.monitor = xbmc.Monitor()
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s" % className, msg, lvl)
|
|
||||||
|
|
||||||
def setUrl(self, url):
|
def setUrl(self, url):
|
||||||
self.urlToProcess = url
|
self.urlToProcess = url
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import PlexAPI
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class InitialSetup():
|
class InitialSetup():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -24,16 +25,10 @@ class InitialSetup():
|
||||||
self.__language__ = self.addon.getLocalizedString
|
self.__language__ = self.addon.getLocalizedString
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.addonId = self.clientInfo.getAddonId()
|
self.addonId = self.clientInfo.getAddonId()
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
self.userClient = userclient.UserClient()
|
self.userClient = userclient.UserClient()
|
||||||
self.plx = PlexAPI.PlexAPI()
|
self.plx = PlexAPI.PlexAPI()
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -12,7 +12,6 @@ import xbmcvfs
|
||||||
|
|
||||||
import api
|
import api
|
||||||
import artwork
|
import artwork
|
||||||
import clientinfo
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import utils
|
import utils
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
|
@ -20,11 +19,11 @@ import kodidb_functions as kodidb
|
||||||
import read_embyserver as embyserver
|
import read_embyserver as embyserver
|
||||||
import musicutils as musicutils
|
import musicutils as musicutils
|
||||||
import PlexAPI
|
import PlexAPI
|
||||||
import sys
|
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Items(object):
|
class Items(object):
|
||||||
"""
|
"""
|
||||||
Items to be called with "with Items as xxx:" to ensure that __enter__
|
Items to be called with "with Items as xxx:" to ensure that __enter__
|
||||||
|
@ -32,8 +31,6 @@ class Items(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
self.kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
self.kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
||||||
|
@ -66,12 +63,6 @@ class Items(object):
|
||||||
self.kodiconn.close()
|
self.kodiconn.close()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def itemsbyId(self, items, process, pdialog=None):
|
def itemsbyId(self, items, process, pdialog=None):
|
||||||
# Process items by itemid. Process can be added, update, userdata, remove
|
# Process items by itemid. Process can be added, update, userdata, remove
|
||||||
emby = self.emby
|
emby = self.emby
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
|
|
||||||
import api
|
|
||||||
import artwork
|
import artwork
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import utils
|
import utils
|
||||||
|
@ -12,25 +11,18 @@ import utils
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Kodidb_Functions():
|
class Kodidb_Functions():
|
||||||
|
|
||||||
kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, cursor):
|
def __init__(self, cursor):
|
||||||
|
|
||||||
self.cursor = cursor
|
self.cursor = cursor
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.artwork = artwork.Artwork()
|
self.artwork = artwork.Artwork()
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def addPath(self, path):
|
def addPath(self, path):
|
||||||
|
|
||||||
cursor = self.cursor
|
cursor = self.cursor
|
||||||
|
|
|
@ -7,7 +7,6 @@ import json
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
|
||||||
import clientinfo
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
import playbackutils as pbutils
|
import playbackutils as pbutils
|
||||||
|
@ -18,23 +17,16 @@ from urllib import urlencode
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class KodiMonitor(xbmc.Monitor):
|
class KodiMonitor(xbmc.Monitor):
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
self.logMsg("Kodi monitor started.", 1)
|
self.logMsg("Kodi monitor started.", 1)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
self.className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def onScanStarted(self, library):
|
def onScanStarted(self, library):
|
||||||
self.logMsg("Kodi library scan %s running." % library, 2)
|
self.logMsg("Kodi library scan %s running." % library, 2)
|
||||||
if library == "video":
|
if library == "video":
|
||||||
|
|
|
@ -177,6 +177,7 @@ class ThreadedShowSyncInfo(threading.Thread):
|
||||||
self.dialog.close()
|
self.dialog.close()
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
@utils.ThreadMethodsStopsync
|
@utils.ThreadMethodsStopsync
|
||||||
@utils.ThreadMethods
|
@utils.ThreadMethods
|
||||||
class LibrarySync(threading.Thread):
|
class LibrarySync(threading.Thread):
|
||||||
|
@ -196,7 +197,6 @@ class LibrarySync(threading.Thread):
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
self.user = userclient.UserClient()
|
self.user = userclient.UserClient()
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
|
@ -206,12 +206,6 @@ class LibrarySync(threading.Thread):
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def progressDialog(self, title, forced=False):
|
def progressDialog(self, title, forced=False):
|
||||||
|
|
||||||
dialog = None
|
dialog = None
|
||||||
|
|
|
@ -10,7 +10,6 @@ import xbmcgui
|
||||||
import xbmcplugin
|
import xbmcplugin
|
||||||
|
|
||||||
import artwork
|
import artwork
|
||||||
import clientinfo
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import playutils as putils
|
import playutils as putils
|
||||||
import playlist
|
import playlist
|
||||||
|
@ -22,6 +21,7 @@ import PlexAPI
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class PlaybackUtils():
|
class PlaybackUtils():
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ class PlaybackUtils():
|
||||||
self.item = item
|
self.item = item
|
||||||
self.API = PlexAPI.API(self.item)
|
self.API = PlexAPI.API(self.item)
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
self.userid = utils.window('emby_currUser')
|
self.userid = utils.window('emby_currUser')
|
||||||
|
@ -42,11 +40,6 @@ class PlaybackUtils():
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
self.pl = playlist.Playlist()
|
self.pl = playlist.Playlist()
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
self.className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
|
||||||
|
|
||||||
def play(self, itemid, dbid=None, seektime=None):
|
def play(self, itemid, dbid=None, seektime=None):
|
||||||
|
|
||||||
self.logMsg("Play called.", 1)
|
self.logMsg("Play called.", 1)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import xbmcgui
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import kodidb_functions as kodidb
|
|
||||||
import websocket_client as wsc
|
import websocket_client as wsc
|
||||||
|
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
@ -18,6 +17,7 @@ from urllib import urlencode
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Player(xbmc.Player):
|
class Player(xbmc.Player):
|
||||||
|
|
||||||
# Borg - multiple instances, shared state
|
# Borg - multiple instances, shared state
|
||||||
|
@ -27,25 +27,17 @@ class Player(xbmc.Player):
|
||||||
playStats = {}
|
playStats = {}
|
||||||
currentFile = None
|
currentFile = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
self.ws = wsc.WebSocket_Client()
|
self.ws = wsc.WebSocket_Client()
|
||||||
self.xbmcplayer = xbmc.Player()
|
self.xbmcplayer = xbmc.Player()
|
||||||
|
|
||||||
self.logMsg("Starting playback monitor.", 2)
|
self.logMsg("Starting playback monitor.", 2)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
self.className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def GetPlayStats(self):
|
def GetPlayStats(self):
|
||||||
return self.playStats
|
return self.playStats
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@ import json
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcplugin
|
|
||||||
|
|
||||||
import clientinfo
|
|
||||||
import playutils
|
import playutils
|
||||||
import playbackutils
|
import playbackutils
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
|
@ -18,25 +16,15 @@ import utils
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Playlist():
|
class Playlist():
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
|
|
||||||
self.userid = utils.window('emby_currUser')
|
self.userid = utils.window('emby_currUser')
|
||||||
self.server = utils.window('emby_server%s' % self.userid)
|
self.server = utils.window('emby_server%s' % self.userid)
|
||||||
|
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
self.className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def playAll(self, itemids, startat):
|
def playAll(self, itemids, startat):
|
||||||
|
|
||||||
embyconn = utils.kodiSQL('emby')
|
embyconn = utils.kodiSQL('emby')
|
||||||
|
|
|
@ -14,6 +14,7 @@ import PlexAPI
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class PlayUtils():
|
class PlayUtils():
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +23,6 @@ class PlayUtils():
|
||||||
self.item = item
|
self.item = item
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
|
|
||||||
self.userid = utils.window('emby_currUser')
|
self.userid = utils.window('emby_currUser')
|
||||||
self.server = utils.window('emby_server%s' % self.userid)
|
self.server = utils.window('emby_server%s' % self.userid)
|
||||||
|
@ -30,12 +30,6 @@ class PlayUtils():
|
||||||
|
|
||||||
self.API = PlexAPI.API(item)
|
self.API = PlexAPI.API(item)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
self.className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def getPlayUrl(self, child=0, partIndex=None):
|
def getPlayUrl(self, child=0, partIndex=None):
|
||||||
item = self.item
|
item = self.item
|
||||||
# NO, I am not very fond of this construct!
|
# NO, I am not very fond of this construct!
|
||||||
|
|
|
@ -3,32 +3,23 @@
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Read_EmbyServer():
|
class Read_EmbyServer():
|
||||||
|
|
||||||
limitIndex = int(utils.settings('limitindex'))
|
limitIndex = int(utils.settings('limitindex'))
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
self.userId = utils.window('emby_currUser')
|
self.userId = utils.window('emby_currUser')
|
||||||
self.server = utils.window('emby_server%s' % self.userId)
|
self.server = utils.window('emby_server%s' % self.userId)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def split_list(self, itemlist, size):
|
def split_list(self, itemlist, size):
|
||||||
# Split up list in pieces of size. Will generate a list of lists
|
# Split up list in pieces of size. Will generate a list of lists
|
||||||
return [itemlist[i:i+size] for i in range(0, len(itemlist), size)]
|
return [itemlist[i:i+size] for i in range(0, len(itemlist), size)]
|
||||||
|
|
|
@ -10,7 +10,6 @@ import xbmcaddon
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
|
|
||||||
import PlexAPI
|
import PlexAPI
|
||||||
|
@ -19,6 +18,7 @@ import librarysync
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
@utils.ThreadMethods
|
@utils.ThreadMethods
|
||||||
class UserClient(threading.Thread):
|
class UserClient(threading.Thread):
|
||||||
|
|
||||||
|
@ -37,23 +37,15 @@ class UserClient(threading.Thread):
|
||||||
|
|
||||||
userSettings = None
|
userSettings = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.__dict__ = self.__shared_state
|
self.__dict__ = self.__shared_state
|
||||||
self.addon = xbmcaddon.Addon()
|
self.addon = xbmcaddon.Addon()
|
||||||
|
|
||||||
self.addonName = clientinfo.ClientInfo().getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def getAdditionalUsers(self):
|
def getAdditionalUsers(self):
|
||||||
|
|
||||||
additionalUsers = utils.settings('additionalUsers')
|
additionalUsers = utils.settings('additionalUsers')
|
||||||
|
|
|
@ -9,16 +9,18 @@ import sqlite3
|
||||||
import time
|
import time
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
|
from functools import wraps, update_wrapper
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
import clientinfo
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
addonName = xbmcaddon.Addon().getAddonInfo('name')
|
||||||
|
|
||||||
|
|
||||||
def ThreadMethodsStopsync(cls):
|
def ThreadMethodsStopsync(cls):
|
||||||
"""
|
"""
|
||||||
|
@ -82,32 +84,29 @@ def ThreadMethods(cls):
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
||||||
class logDecor(object):
|
def logging(cls):
|
||||||
"""
|
"""
|
||||||
A decorator adding logging capabilities.
|
A decorator adding logging capabilities to classes. Also adds
|
||||||
|
self.addonName to the class
|
||||||
|
|
||||||
Syntax: self.logMsg(message, loglevel)
|
Syntax: self.logMsg(message, loglevel)
|
||||||
|
|
||||||
Loglevel: -2 (Error) to 2 (DB debug)
|
Loglevel: -2 (Error) to 2 (DB debug)
|
||||||
"""
|
"""
|
||||||
def __init__(self, f):
|
# Attach new attributes to class
|
||||||
"""
|
cls.addonName = addonName
|
||||||
If there are no decorator arguments, the function to be decorated is
|
|
||||||
passed to the constructor.
|
|
||||||
"""
|
|
||||||
self.f = f
|
|
||||||
self.addonName = clientinfo.ClientInfo().getAddonName()
|
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
# Define new class methods and attach them to class
|
||||||
"""
|
def newFunction(self, msg, lvl=0):
|
||||||
The __call__ method is not called until the
|
title = "%s %s" % (self.addonName, cls.__name__)
|
||||||
decorated function is called.
|
logMsg(title, msg, lvl)
|
||||||
"""
|
cls.logMsg = newFunction
|
||||||
def decorLog(self, msg, lvl=1):
|
|
||||||
className = self.__class__.__name__
|
# Override the name, we don't want the decorators name showing up
|
||||||
logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
__name__ = cls.__name__
|
||||||
# The function itself:
|
|
||||||
self.f(*args, **kwargs)
|
# Return class to render this a decorator
|
||||||
|
return cls
|
||||||
|
|
||||||
|
|
||||||
def logMsg(title, msg, level=1):
|
def logMsg(title, msg, level=1):
|
||||||
|
@ -120,17 +119,21 @@ def logMsg(title, msg, level=1):
|
||||||
|
|
||||||
if logLevel >= level:
|
if logLevel >= level:
|
||||||
|
|
||||||
if logLevel == 2: # inspect.stack() is expensive
|
if logLevel == 2: # inspect is expensive
|
||||||
|
func = inspect.currentframe().f_back.f_back.f_code
|
||||||
try:
|
try:
|
||||||
xbmc.log("%s -> %s : %s" % (title, inspect.stack()[1][3], msg))
|
xbmc.log("%s -> %s : %s" % (
|
||||||
|
title, func.co_name, msg))
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
xbmc.log("%s -> %s : %s" % (title, inspect.stack()[1][3], msg.encode('utf-8')))
|
xbmc.log("%s -> %s : %s" % (
|
||||||
|
title, func.co_name, msg.encode('utf-8')))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
xbmc.log("%s -> %s" % (title, msg))
|
xbmc.log("%s -> %s" % (title, msg))
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
xbmc.log("%s -> %s" % (title, msg.encode('utf-8')))
|
xbmc.log("%s -> %s" % (title, msg.encode('utf-8')))
|
||||||
|
|
||||||
|
|
||||||
def window(property, value=None, clear=False, windowid=10000):
|
def window(property, value=None, clear=False, windowid=10000):
|
||||||
# Get or set window property
|
# Get or set window property
|
||||||
WINDOW = xbmcgui.Window(windowid)
|
WINDOW = xbmcgui.Window(windowid)
|
||||||
|
|
|
@ -6,31 +6,19 @@ import shutil
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcaddon
|
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
import clientinfo
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class VideoNodes(object):
|
class VideoNodes(object):
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = clientInfo.getAddonName()
|
|
||||||
|
|
||||||
self.kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
self.kodiversion = int(xbmc.getInfoLabel("System.BuildVersion")[:2])
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def commonRoot(self, order, label, tagname, roottype=1):
|
def commonRoot(self, order, label, tagname, roottype=1):
|
||||||
|
|
||||||
if roottype == 0:
|
if roottype == 0:
|
||||||
|
|
|
@ -22,6 +22,7 @@ logging.basicConfig()
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class WebSocket_Client(threading.Thread):
|
class WebSocket_Client(threading.Thread):
|
||||||
|
|
||||||
_shared_state = {}
|
_shared_state = {}
|
||||||
|
@ -37,18 +38,11 @@ class WebSocket_Client(threading.Thread):
|
||||||
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.deviceId = self.clientInfo.getDeviceId()
|
self.deviceId = self.clientInfo.getDeviceId()
|
||||||
self.librarySync = librarysync.LibrarySync()
|
self.librarySync = librarysync.LibrarySync()
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
self.className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, self.className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def sendProgressUpdate(self, data):
|
def sendProgressUpdate(self, data):
|
||||||
self.logMsg("sendProgressUpdate", 2)
|
self.logMsg("sendProgressUpdate", 2)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -37,6 +37,7 @@ import PlexCompanion
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@utils.logging
|
||||||
class Service():
|
class Service():
|
||||||
|
|
||||||
welcome_msg = True
|
welcome_msg = True
|
||||||
|
@ -53,7 +54,6 @@ class Service():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
logLevel = userclient.UserClient().getLogLevel()
|
logLevel = userclient.UserClient().getLogLevel()
|
||||||
self.monitor = xbmc.Monitor()
|
self.monitor = xbmc.Monitor()
|
||||||
|
|
||||||
|
@ -89,12 +89,6 @@ class Service():
|
||||||
# Set the minimum database version
|
# Set the minimum database version
|
||||||
utils.window('emby_minDBVersion', value="1.1.63")
|
utils.window('emby_minDBVersion', value="1.1.63")
|
||||||
|
|
||||||
def logMsg(self, msg, lvl=1):
|
|
||||||
|
|
||||||
className = self.__class__.__name__
|
|
||||||
utils.logMsg("%s %s" % (self.addonName, className), msg, lvl)
|
|
||||||
|
|
||||||
|
|
||||||
def ServiceEntryPoint(self):
|
def ServiceEntryPoint(self):
|
||||||
# Important: Threads depending on abortRequest will not trigger
|
# Important: Threads depending on abortRequest will not trigger
|
||||||
# if profile switch happens more than once.
|
# if profile switch happens more than once.
|
||||||
|
|
Loading…
Add table
Reference in a new issue