Implement Codacy suggestions
This commit is contained in:
parent
f24266fb54
commit
e6cd80a7dd
11 changed files with 50 additions and 26 deletions
|
@ -92,7 +92,7 @@ class Connection(object):
|
||||||
LOG.debug('Clearing connection settings')
|
LOG.debug('Clearing connection settings')
|
||||||
self.machine_identifier = None
|
self.machine_identifier = None
|
||||||
self.server_name = None
|
self.server_name = None
|
||||||
self.http = None
|
self.https = None
|
||||||
self.host = None
|
self.host = None
|
||||||
self.port = None
|
self.port = None
|
||||||
self.server = None
|
self.server = None
|
||||||
|
|
|
@ -37,7 +37,8 @@ class ImageCachingThread(backgroundthread.KillableThread):
|
||||||
def isSuspended(self):
|
def isSuspended(self):
|
||||||
return any(self.suspend_points)
|
return any(self.suspend_points)
|
||||||
|
|
||||||
def _url_generator(self, kind, kodi_type):
|
@staticmethod
|
||||||
|
def _url_generator(kind, kodi_type):
|
||||||
"""
|
"""
|
||||||
Main goal is to close DB connection between calls
|
Main goal is to close DB connection between calls
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -225,7 +225,8 @@ class BackgroundWorker(object):
|
||||||
self._abort = False
|
self._abort = False
|
||||||
self._task = None
|
self._task = None
|
||||||
|
|
||||||
def _runTask(self, task):
|
@staticmethod
|
||||||
|
def _runTask(task):
|
||||||
if task._canceled:
|
if task._canceled:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -69,7 +69,8 @@ class InitialSetup(object):
|
||||||
utils.settings('plex_allows_mediaDeletion', value=value)
|
utils.settings('plex_allows_mediaDeletion', value=value)
|
||||||
utils.window('plex_allows_mediaDeletion', value=value)
|
utils.window('plex_allows_mediaDeletion', value=value)
|
||||||
|
|
||||||
def enter_new_pms_address(self):
|
@staticmethod
|
||||||
|
def enter_new_pms_address():
|
||||||
LOG.info('Start getting manual PMS address and port')
|
LOG.info('Start getting manual PMS address and port')
|
||||||
# "Enter your Plex Media Server's IP or URL. Examples are:"
|
# "Enter your Plex Media Server's IP or URL. Examples are:"
|
||||||
utils.messageDialog(utils.lang(29999),
|
utils.messageDialog(utils.lang(29999),
|
||||||
|
@ -196,12 +197,12 @@ class InitialSetup(object):
|
||||||
LOG.error('Failed to update Plex info from plex.tv')
|
LOG.error('Failed to update Plex info from plex.tv')
|
||||||
else:
|
else:
|
||||||
utils.settings('plexLogin', value=self.plex_login)
|
utils.settings('plexLogin', value=self.plex_login)
|
||||||
home = 'true' if xml.attrib.get('home') == '1' else 'false'
|
|
||||||
utils.settings('plexAvatar', value=xml.attrib.get('thumb'))
|
utils.settings('plexAvatar', value=xml.attrib.get('thumb'))
|
||||||
LOG.info('Updated Plex info from plex.tv')
|
LOG.info('Updated Plex info from plex.tv')
|
||||||
return answer
|
return answer
|
||||||
|
|
||||||
def check_existing_pms(self):
|
@staticmethod
|
||||||
|
def check_existing_pms():
|
||||||
"""
|
"""
|
||||||
Check the PMS that was set in file settings.
|
Check the PMS that was set in file settings.
|
||||||
Will return False if we need to reconnect, because:
|
Will return False if we need to reconnect, because:
|
||||||
|
|
|
@ -207,7 +207,8 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _playlist_onclear(self, data):
|
@staticmethod
|
||||||
|
def _playlist_onclear(data):
|
||||||
"""
|
"""
|
||||||
Called if a Kodi playlist is cleared. Example data dict:
|
Called if a Kodi playlist is cleared. Example data dict:
|
||||||
{
|
{
|
||||||
|
@ -221,7 +222,8 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
else:
|
else:
|
||||||
LOG.debug('Detected PKC clear - ignoring')
|
LOG.debug('Detected PKC clear - ignoring')
|
||||||
|
|
||||||
def _get_ids(self, kodi_id, kodi_type, path):
|
@staticmethod
|
||||||
|
def _get_ids(kodi_id, kodi_type, path):
|
||||||
"""
|
"""
|
||||||
Returns the tuple (plex_id, plex_type) or (None, None)
|
Returns the tuple (plex_id, plex_type) or (None, None)
|
||||||
"""
|
"""
|
||||||
|
@ -315,7 +317,7 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
return
|
return
|
||||||
playerid = js.get_playlist_id(playlist_type)
|
playerid = js.get_playlist_id(playlist_type)
|
||||||
if not playerid:
|
if not playerid:
|
||||||
LOG.error('Coud not get playerid for data', data)
|
LOG.error('Coud not get playerid for data %s', data)
|
||||||
return
|
return
|
||||||
playqueue = PQ.PLAYQUEUES[playerid]
|
playqueue = PQ.PLAYQUEUES[playerid]
|
||||||
info = js.get_player_props(playerid)
|
info = js.get_player_props(playerid)
|
||||||
|
|
|
@ -476,7 +476,7 @@ class VideoNodes(object):
|
||||||
"unwatched.content","unwatched.path",
|
"unwatched.content","unwatched.path",
|
||||||
"recent.title","recent.content","recent.path",
|
"recent.title","recent.content","recent.path",
|
||||||
"recentepisodes.title","recentepisodes.content",
|
"recentepisodes.title","recentepisodes.content",
|
||||||
"recentepisodes.path","inprogressepisodes.title",
|
"recentepisodes.path", "inprogressepisodes.title",
|
||||||
"inprogressepisodes.content","inprogressepisodes.path"
|
"inprogressepisodes.content","inprogressepisodes.path"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,8 @@ class PlayUtils():
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_max_bitrate(self):
|
@staticmethod
|
||||||
|
def get_max_bitrate():
|
||||||
# get the addon video quality
|
# get the addon video quality
|
||||||
videoQuality = utils.settings('maxVideoQualities')
|
videoQuality = utils.settings('maxVideoQualities')
|
||||||
bitrate = {
|
bitrate = {
|
||||||
|
@ -167,7 +168,8 @@ class PlayUtils():
|
||||||
# max bit rate supported by server (max signed 32bit integer)
|
# max bit rate supported by server (max signed 32bit integer)
|
||||||
return bitrate.get(videoQuality, 2147483)
|
return bitrate.get(videoQuality, 2147483)
|
||||||
|
|
||||||
def getH265(self):
|
@staticmethod
|
||||||
|
def getH265():
|
||||||
"""
|
"""
|
||||||
Returns the user settings for transcoding h265: boundary resolutions
|
Returns the user settings for transcoding h265: boundary resolutions
|
||||||
of 480, 720 or 1080 as an int
|
of 480, 720 or 1080 as an int
|
||||||
|
@ -182,7 +184,8 @@ class PlayUtils():
|
||||||
}
|
}
|
||||||
return H265[utils.settings('transcodeH265')]
|
return H265[utils.settings('transcodeH265')]
|
||||||
|
|
||||||
def get_bitrate(self):
|
@staticmethod
|
||||||
|
def get_bitrate():
|
||||||
"""
|
"""
|
||||||
Get the desired transcoding bitrate from the settings
|
Get the desired transcoding bitrate from the settings
|
||||||
"""
|
"""
|
||||||
|
@ -203,7 +206,8 @@ class PlayUtils():
|
||||||
# max bit rate supported by server (max signed 32bit integer)
|
# max bit rate supported by server (max signed 32bit integer)
|
||||||
return bitrate.get(videoQuality, 2147483)
|
return bitrate.get(videoQuality, 2147483)
|
||||||
|
|
||||||
def get_resolution(self):
|
@staticmethod
|
||||||
|
def get_resolution():
|
||||||
"""
|
"""
|
||||||
Get the desired transcoding resolutions from the settings
|
Get the desired transcoding resolutions from the settings
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -80,7 +80,8 @@ class PlexCompanion(backgroundthread.KillableThread):
|
||||||
self.subscription_manager = None
|
self.subscription_manager = None
|
||||||
super(PlexCompanion, self).__init__()
|
super(PlexCompanion, self).__init__()
|
||||||
|
|
||||||
def _process_alexa(self, data):
|
@staticmethod
|
||||||
|
def _process_alexa(data):
|
||||||
xml = PF.GetPlexMetadata(data['key'])
|
xml = PF.GetPlexMetadata(data['key'])
|
||||||
try:
|
try:
|
||||||
xml[0].attrib
|
xml[0].attrib
|
||||||
|
@ -135,7 +136,8 @@ class PlexCompanion(backgroundthread.KillableThread):
|
||||||
executebuiltin('RunPlugin(plugin://%s?%s)'
|
executebuiltin('RunPlugin(plugin://%s?%s)'
|
||||||
% (v.ADDON_ID, urlencode(params)))
|
% (v.ADDON_ID, urlencode(params)))
|
||||||
|
|
||||||
def _process_playlist(self, data):
|
@staticmethod
|
||||||
|
def _process_playlist(data):
|
||||||
# Get the playqueue ID
|
# Get the playqueue ID
|
||||||
_, container_key, query = PF.ParseContainerKey(data['containerKey'])
|
_, container_key, query = PF.ParseContainerKey(data['containerKey'])
|
||||||
try:
|
try:
|
||||||
|
@ -159,7 +161,8 @@ class PlexCompanion(backgroundthread.KillableThread):
|
||||||
offset=data.get('offset'),
|
offset=data.get('offset'),
|
||||||
transient_token=data.get('token'))
|
transient_token=data.get('token'))
|
||||||
|
|
||||||
def _process_streams(self, data):
|
@staticmethod
|
||||||
|
def _process_streams(data):
|
||||||
"""
|
"""
|
||||||
Plex Companion client adjusted audio or subtitle stream
|
Plex Companion client adjusted audio or subtitle stream
|
||||||
"""
|
"""
|
||||||
|
@ -180,7 +183,8 @@ class PlexCompanion(backgroundthread.KillableThread):
|
||||||
else:
|
else:
|
||||||
LOG.error('Unknown setStreams command: %s', data)
|
LOG.error('Unknown setStreams command: %s', data)
|
||||||
|
|
||||||
def _process_refresh(self, data):
|
@staticmethod
|
||||||
|
def _process_refresh(data):
|
||||||
"""
|
"""
|
||||||
example data: {'playQueueID': '8475', 'commandID': '11'}
|
example data: {'playQueueID': '8475', 'commandID': '11'}
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -45,6 +45,9 @@ class plexgdm:
|
||||||
self.discover_message = 'M-SEARCH * HTTP/1.0'
|
self.discover_message = 'M-SEARCH * HTTP/1.0'
|
||||||
self.client_header = '* HTTP/1.0'
|
self.client_header = '* HTTP/1.0'
|
||||||
self.client_data = None
|
self.client_data = None
|
||||||
|
self.update_sock = None
|
||||||
|
self.discover_t = None
|
||||||
|
self.register_t = None
|
||||||
|
|
||||||
self._multicast_address = '239.0.0.250'
|
self._multicast_address = '239.0.0.250'
|
||||||
self.discover_group = (self._multicast_address, 32414)
|
self.discover_group = (self._multicast_address, 32414)
|
||||||
|
|
|
@ -107,12 +107,16 @@ class Service():
|
||||||
self.server_has_been_online = True
|
self.server_has_been_online = True
|
||||||
self.welcome_msg = True
|
self.welcome_msg = True
|
||||||
self.connection_check_counter = 0
|
self.connection_check_counter = 0
|
||||||
|
self.setup = None
|
||||||
|
self.alexa = None
|
||||||
|
self.playqueue = None
|
||||||
# Flags for other threads
|
# Flags for other threads
|
||||||
self.connection_check_running = False
|
self.connection_check_running = False
|
||||||
self.auth_running = False
|
self.auth_running = False
|
||||||
self._init_done = True
|
self._init_done = True
|
||||||
|
|
||||||
def isCanceled(self):
|
@staticmethod
|
||||||
|
def isCanceled():
|
||||||
return xbmc.abortRequested or app.APP.stop_pkc
|
return xbmc.abortRequested or app.APP.stop_pkc
|
||||||
|
|
||||||
def on_connection_check(self, result):
|
def on_connection_check(self, result):
|
||||||
|
@ -170,7 +174,8 @@ class Service():
|
||||||
finally:
|
finally:
|
||||||
self.connection_check_running = False
|
self.connection_check_running = False
|
||||||
|
|
||||||
def log_out(self):
|
@staticmethod
|
||||||
|
def log_out():
|
||||||
"""
|
"""
|
||||||
Ensures that lib sync threads are suspended; signs out user
|
Ensures that lib sync threads are suspended; signs out user
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -206,7 +206,7 @@ class ControlledWindow(ControlledBase, BaseWindow):
|
||||||
if action in (xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK):
|
if action in (xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK):
|
||||||
self.doClose()
|
self.doClose()
|
||||||
return
|
return
|
||||||
except:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
BaseWindow.onAction(self, action)
|
BaseWindow.onAction(self, action)
|
||||||
|
@ -218,7 +218,7 @@ class ControlledDialog(ControlledBase, BaseDialog):
|
||||||
if action in (xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK):
|
if action in (xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK):
|
||||||
self.doClose()
|
self.doClose()
|
||||||
return
|
return
|
||||||
except:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
BaseDialog.onAction(self, action)
|
BaseDialog.onAction(self, action)
|
||||||
|
@ -228,7 +228,8 @@ DUMMY_LIST_ITEM = xbmcgui.ListItem()
|
||||||
|
|
||||||
|
|
||||||
class ManagedListItem(object):
|
class ManagedListItem(object):
|
||||||
def __init__(self, label='', label2='', iconImage='', thumbnailImage='', path='', data_source=None, properties=None):
|
def __init__(self, label='', label2='', iconImage='', thumbnailImage='',
|
||||||
|
path='', data_source=None, properties=None):
|
||||||
self._listItem = xbmcgui.ListItem(label, label2, iconImage, thumbnailImage, path)
|
self._listItem = xbmcgui.ListItem(label, label2, iconImage, thumbnailImage, path)
|
||||||
self.dataSource = data_source
|
self.dataSource = data_source
|
||||||
self.properties = {}
|
self.properties = {}
|
||||||
|
@ -608,13 +609,15 @@ class ManagedControlList(object):
|
||||||
def getViewPosition(self):
|
def getViewPosition(self):
|
||||||
try:
|
try:
|
||||||
return int(xbmc.getInfoLabel('Container({0}).Position'.format(self.controlID)))
|
return int(xbmc.getInfoLabel('Container({0}).Position'.format(self.controlID)))
|
||||||
except:
|
except Exception:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def getViewRange(self):
|
def getViewRange(self):
|
||||||
viewPosition = self.getViewPosition()
|
viewPosition = self.getViewPosition()
|
||||||
selected = self.getSelectedPosition()
|
selected = self.getSelectedPosition()
|
||||||
return range(max(selected - viewPosition, 0), min(selected + (self._maxViewIndex - viewPosition) + 1, self.size() - 1))
|
return range(max(selected - viewPosition, 0),
|
||||||
|
min(selected + (self._maxViewIndex - viewPosition) + 1,
|
||||||
|
self.size() - 1))
|
||||||
|
|
||||||
def positionIsValid(self, pos):
|
def positionIsValid(self, pos):
|
||||||
return 0 <= pos < self.size()
|
return 0 <= pos < self.size()
|
||||||
|
@ -809,7 +812,7 @@ class SafeControlEdit(object):
|
||||||
if self.processOffControlAction(action.getButtonCode()):
|
if self.processOffControlAction(action.getButtonCode()):
|
||||||
self._win.setFocusId(self.controlID)
|
self._win.setFocusId(self.controlID)
|
||||||
return
|
return
|
||||||
except:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
self._winOnAction(action)
|
self._winOnAction(action)
|
||||||
|
|
Loading…
Reference in a new issue