From 3d31568518c7430b780041027f85981f378046d1 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Sun, 4 Sep 2016 22:33:34 -0500 Subject: [PATCH] Pylint + Fix initial setup for fresh installs --- resources/lib/clientinfo.py | 26 +++++++++++++------------- resources/lib/connectmanager.py | 6 +++--- resources/lib/downloadutils.py | 8 ++++---- resources/lib/entrypoint.py | 6 +++--- resources/lib/initialsetup.py | 12 +++++++----- resources/lib/itemtypes.py | 3 --- resources/lib/kodidb_functions.py | 3 --- resources/lib/kodimonitor.py | 3 --- resources/lib/librarysync.py | 3 +-- resources/lib/player.py | 2 +- resources/lib/playutils.py | 2 +- resources/lib/websocket_client.py | 2 +- service.py | 6 +++--- 13 files changed, 37 insertions(+), 45 deletions(-) diff --git a/resources/lib/clientinfo.py b/resources/lib/clientinfo.py index 2fa74155..15d7a230 100644 --- a/resources/lib/clientinfo.py +++ b/resources/lib/clientinfo.py @@ -26,31 +26,31 @@ class ClientInfo(object): self.addon = xbmcaddon.Addon() - def getAddonName(self): + def get_addon_name(self): # Used for logging return self.addon.getAddonInfo('name').upper() @classmethod - def getAddonId(cls): + def get_addon_id(cls): return "plugin.video.emby" - def getVersion(self): + def get_version(self): return self.addon.getAddonInfo('version') @classmethod - def getDeviceName(cls): + def get_device_name(cls): if settings('deviceNameOpt') == "false": # Use Kodi's deviceName - deviceName = xbmc.getInfoLabel('System.FriendlyName').decode('utf-8') + device_name = xbmc.getInfoLabel('System.FriendlyName').decode('utf-8') else: - deviceName = settings('deviceName') - deviceName = deviceName.replace("\"", "_") - deviceName = deviceName.replace("/", "_") + device_name = settings('deviceName') + device_name = device_name.replace("\"", "_") + device_name = device_name.replace("/", "_") - return deviceName + return device_name - def getPlatform(self): + def get_platform(self): if xbmc.getCondVisibility('system.platform.osx'): return "OSX" @@ -69,14 +69,14 @@ class ClientInfo(object): else: return "Unknown" - def getDeviceId(self, reset=False): + def get_device_id(self, reset=False): client_id = window('emby_deviceId') if client_id: return client_id emby_guid = xbmc.translatePath("special://temp/emby_guid").decode('utf-8') - + ###$ Begin migration $### if not xbmcvfs.exists(emby_guid): addon_path = self.addon.getAddonInfo('path').decode('utf-8') @@ -84,7 +84,7 @@ class ClientInfo(object): path = os.path.join(addon_path, "machine_guid") else: path = os.path.join(addon_path.encode('utf-8'), "machine_guid") - + guid_file = xbmc.translatePath(path).decode('utf-8') if xbmcvfs.exists(guid_file): xbmcvfs.copy(guid_file, emby_guid) diff --git a/resources/lib/connectmanager.py b/resources/lib/connectmanager.py index 22afc2eb..75303d53 100644 --- a/resources/lib/connectmanager.py +++ b/resources/lib/connectmanager.py @@ -35,9 +35,9 @@ class ConnectManager(object): client_info = clientinfo.ClientInfo() self.emby = embyserver.Read_EmbyServer() - version = client_info.getVersion() - device_name = client_info.getDeviceName() - device_id = client_info.getDeviceId() + version = client_info.get_version() + device_name = client_info.get_device_name() + device_id = client_info.get_device_id() self._connect = connectionmanager.ConnectionManager(appName="Kodi", appVersion=version, diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index bdb9ad48..de05fb5a 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -132,7 +132,7 @@ class DownloadUtils(): def startSession(self): - self.deviceId = self.clientInfo.getDeviceId() + self.deviceId = self.clientInfo.get_device_id() # User is identified from this point # Attach authenticated header to the session @@ -163,10 +163,10 @@ class DownloadUtils(): def getHeader(self, authenticate=True): - deviceName = self.clientInfo.getDeviceName() + deviceName = self.clientInfo.get_device_name() deviceName = deviceName.encode('utf-8') - deviceId = self.clientInfo.getDeviceId() - version = self.clientInfo.getVersion() + deviceId = self.clientInfo.get_device_id() + version = self.clientInfo.get_version() if authenticate: auth = ( diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 6074280c..f79af63a 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -143,7 +143,7 @@ def resetDeviceId(): deviceId_old = window('emby_deviceId') try: window('emby_deviceId', clear=True) - deviceId = clientinfo.ClientInfo().getDeviceId(reset=True) + deviceId = clientinfo.ClientInfo().get_device_id(reset=True) except Exception as e: log.error("Failed to generate a new device Id: %s" % e) dialog.ok( @@ -208,8 +208,8 @@ def addUser(): doUtils = downloadutils.DownloadUtils() art = artwork.Artwork() clientInfo = clientinfo.ClientInfo() - deviceId = clientInfo.getDeviceId() - deviceName = clientInfo.getDeviceName() + deviceId = clientInfo.get_device_id() + deviceName = clientInfo.get_device_name() userid = window('emby_currUser') dialog = xbmcgui.Dialog() diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 14209ba3..29cf73a4 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -26,7 +26,7 @@ class InitialSetup(object): def __init__(self): - self.addon_id = clientinfo.ClientInfo().getAddonId() + self.addon_id = clientinfo.ClientInfo().get_addon_id() self.user_client = userclient.UserClient() self.connectmanager = connectmanager.ConnectManager() @@ -43,10 +43,12 @@ class InitialSetup(object): ###$ Begin migration $### if settings('server') == "": current_server = self.user_client.get_server() - server = self.connectmanager.get_server(current_server) - settings('ServerId', value=server['Id']) - self.user_client.get_userid() - self.user_client.get_token() + if current_server is not None: + server = self.connectmanager.get_server(current_server) + log.info(server) + settings('ServerId', value=server['Id']) + self.user_client.get_userid() + self.user_client.get_token() ###$ End migration $### if settings('server'): diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index d83f2777..7ffc09e7 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -13,7 +13,6 @@ import xbmcvfs import api import artwork -import clientinfo import downloadutils import embydb_functions as embydb import kodidb_functions as kodidb @@ -36,8 +35,6 @@ class Items(object): self.embycursor = embycursor self.kodicursor = kodicursor - self.clientInfo = clientinfo.ClientInfo() - self.addonName = self.clientInfo.getAddonName() self.doUtils = downloadutils.DownloadUtils() self.kodiversion = int(xbmc.getInfoLabel('System.BuildVersion')[:2]) diff --git a/resources/lib/kodidb_functions.py b/resources/lib/kodidb_functions.py index 9b7aca14..3e3cc4cc 100644 --- a/resources/lib/kodidb_functions.py +++ b/resources/lib/kodidb_functions.py @@ -8,7 +8,6 @@ import xbmc import api import artwork -import clientinfo ################################################################################################# @@ -25,8 +24,6 @@ class Kodidb_Functions(): self.cursor = cursor - self.clientInfo = clientinfo.ClientInfo() - self.addonName = self.clientInfo.getAddonName() self.artwork = artwork.Artwork() diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 66e0b661..89668b3f 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -8,7 +8,6 @@ import logging import xbmc import xbmcgui -import clientinfo import downloadutils import embydb_functions as embydb import playbackutils as pbutils @@ -26,8 +25,6 @@ class KodiMonitor(xbmc.Monitor): def __init__(self): - self.clientInfo = clientinfo.ClientInfo() - self.addonName = self.clientInfo.getAddonName() self.doUtils = downloadutils.DownloadUtils() log.info("Kodi monitor started.") diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index ad5c6b82..58a5f04e 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -53,7 +53,6 @@ class LibrarySync(threading.Thread): self.monitor = xbmc.Monitor() self.clientInfo = clientinfo.ClientInfo() - self.addonName = self.clientInfo.getAddonName() self.doUtils = downloadutils.DownloadUtils().downloadUrl self.user = userclient.UserClient() self.emby = embyserver.Read_EmbyServer() @@ -313,7 +312,7 @@ class LibrarySync(threading.Thread): embycursor.close() settings('SyncInstallRunDone', value="true") - settings("dbCreatedWithVersion", self.clientInfo.getVersion()) + settings("dbCreatedWithVersion", self.clientInfo.get_version()) self.saveLastSync() xbmc.executebuiltin('UpdateLibrary(video)') elapsedtotal = datetime.now() - starttotal diff --git a/resources/lib/player.py b/resources/lib/player.py index 57114af3..4fa2608d 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -480,7 +480,7 @@ class Player(xbmc.Player): # Stop transcoding if playMethod == "Transcode": log.info("Transcoding for %s terminated." % itemid) - deviceId = self.clientInfo.getDeviceId() + deviceId = self.clientInfo.get_device_id() url = "{server}/emby/Videos/ActiveEncodings?DeviceId=%s" % deviceId self.doUtils(url, action_type="DELETE") diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index 1043a375..a5f2f06e 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -261,7 +261,7 @@ class PlayUtils(): playurl = self.directPlay() else: itemid = self.item['Id'] - deviceId = self.clientInfo.getDeviceId() + deviceId = self.clientInfo.get_device_id() playurl = ( "%s/emby/Videos/%s/master.m3u8?MediaSourceId=%s" % (self.server, itemid, itemid) diff --git a/resources/lib/websocket_client.py b/resources/lib/websocket_client.py index 3681b803..2f5e72bf 100644 --- a/resources/lib/websocket_client.py +++ b/resources/lib/websocket_client.py @@ -39,7 +39,7 @@ class WebSocket_Client(threading.Thread): self.doUtils = downloadutils.DownloadUtils() self.clientInfo = clientinfo.ClientInfo() - self.deviceId = self.clientInfo.getDeviceId() + self.deviceId = self.clientInfo.get_device_id() self.librarySync = librarysync.LibrarySync() threading.Thread.__init__(self) diff --git a/service.py b/service.py index 3c3551c1..dd777f16 100644 --- a/service.py +++ b/service.py @@ -58,7 +58,7 @@ class Service(object): def __init__(self): self.clientInfo = clientinfo.ClientInfo() - self.addonName = self.clientInfo.getAddonName() + self.addonName = self.clientInfo.get_addon_name() logLevel = settings('logLevel') self.monitor = xbmc.Monitor() @@ -68,9 +68,9 @@ class Service(object): # Initial logging log.warn("======== START %s ========" % self.addonName) log.warn("Python Version: %s", sys.version) - log.warn("Platform: %s" % (self.clientInfo.getPlatform())) + log.warn("Platform: %s" % (self.clientInfo.get_platform())) log.warn("KODI Version: %s" % xbmc.getInfoLabel('System.BuildVersion')) - log.warn("%s Version: %s" % (self.addonName, self.clientInfo.getVersion())) + log.warn("%s Version: %s" % (self.addonName, self.clientInfo.get_version())) log.warn("Using plugin paths: %s" % (settings('useDirectPaths') == "0")) log.warn("Log Level: %s" % logLevel)