Most flake8 warnings corrected

This commit is contained in:
Odd Stråbø 2019-10-03 04:14:54 +02:00
commit 00765c0a12
58 changed files with 1144 additions and 1262 deletions

View file

@ -1 +0,0 @@

View file

@ -225,15 +225,15 @@ class API(object):
def get_themes(self, item_id):
return self.items("/%s/ThemeMedia" % item_id, params={
'UserId': "{UserId}",
'InheritFromParent': True
})
'UserId': "{UserId}",
'InheritFromParent': True
})
def get_items_theme_song(self, parent_id):
return self.users("/Items", params={
'HasThemeSong': True,
'ParentId': parent_id
})
'HasThemeSong': True,
'ParentId': parent_id
})
def get_plugins(self):
return self._get("Plugins")

View file

@ -12,7 +12,7 @@ import logging
DEFAULT_HTTP_MAX_RETRIES = 3
DEFAULT_HTTP_TIMEOUT = 30
LOG = logging.getLogger('JELLYFIN.'+__name__)
LOG = logging.getLogger('JELLYFIN.' + __name__)
#################################################################################################

View file

@ -16,7 +16,7 @@ from http import HTTP
#################################################################################################
LOG = logging.getLogger('JELLYFIN.'+__name__)
LOG = logging.getLogger('JELLYFIN.' + __name__)
CONNECTION_STATE = {
'Unavailable': 0,
'ServerSelection': 1,
@ -31,6 +31,7 @@ CONNECTION_MODE = {
#################################################################################################
def get_server_address(server, mode):
modes = {
@ -86,7 +87,7 @@ class ConnectionManager(object):
credentials = self.credentials.get_credentials()
found_servers = self._find_servers(self._server_discovery())
if not found_servers and not credentials['Servers']: # back out right away, no point in continuing
if not found_servers and not credentials['Servers']: # back out right away, no point in continuing
LOG.info("Found no servers")
return list()
@ -178,7 +179,7 @@ class ConnectionManager(object):
LOG.info("beginning connection tests")
return self._test_next_connection_mode(tests, 0, server, options)
def get_server_address(self, server, mode): #TODO: De-duplicated (Duplicated from above when getting rid of shortcuts)
def get_server_address(self, server, mode): # TODO: De-duplicated (Duplicated from above when getting rid of shortcuts)
modes = {
CONNECTION_MODE['Local']: server.get('LocalAddress'),
@ -239,8 +240,10 @@ class ConnectionManager(object):
request.pop('dataType')
headers['X-Application'] = self._add_app_info()
headers['Content-type'] = request.get('contentType',
'application/x-www-form-urlencoded; charset=UTF-8')
headers['Content-type'] = request.get(
'contentType',
'application/x-www-form-urlencoded; charset=UTF-8'
)
def _connect_to_servers(self, servers, options):
@ -379,7 +382,7 @@ class ConnectionManager(object):
MESSAGE = "who is JellyfinServer?"
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(1.0) # This controls the socket.timeout exception
sock.settimeout(1.0) # This controls the socket.timeout exception
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 20)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
@ -399,7 +402,7 @@ class ConnectionManager(object):
while True:
try:
data, addr = sock.recvfrom(1024) # buffer size
data, addr = sock.recvfrom(1024) # buffer size
servers.append(json.loads(data))
except socket.timeout:
@ -446,7 +449,7 @@ class ConnectionManager(object):
'Id': found_server['Id'],
'LocalAddress': server or found_server['Address'],
'Name': found_server['Name']
} #TODO
} # TODO
info['LastConnectionMode'] = CONNECTION_MODE['Manual'] if info.get('ManualAddress') else CONNECTION_MODE['Local']
servers.append(info)
@ -461,7 +464,7 @@ class ConnectionManager(object):
# Determine the port, if any
parts = info['Address'].split(':')
if len(parts) > 1:
port_string = parts[len(parts)-1]
port_string = parts[len(parts) - 1]
try:
address += ":%s" % int(port_string)
@ -496,7 +499,7 @@ class ConnectionManager(object):
def _after_connect_validated(self, server, credentials, system_info, connection_mode, verify_authentication, options):
if options.get('enableAutoLogin') == False:
if not options.get('enableAutoLogin'):
self.config.data['auth.user_id'] = server.pop('UserId', None)
self.config.data['auth.token'] = server.pop('AccessToken', None)
@ -581,7 +584,8 @@ class ConnectionManager(object):
if server['Id'] == result['ServerId']:
found_server = server
break
else: return # No server found
else:
return # No server found
if options.get('updateDateLastAccessed') is not False:
found_server['DateLastAccessed'] = datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')

View file

@ -10,10 +10,11 @@ from datetime import datetime
#################################################################################################
LOG = logging.getLogger('JELLYFIN.'+__name__)
LOG = logging.getLogger('JELLYFIN.' + __name__)
#################################################################################################
class Credentials(object):
credentials = None

View file

@ -2,10 +2,9 @@
#################################################################################################
class HTTPException(Exception):
# Jellyfin HTTP exception
def __init__(self, status, message):
self.status = status
self.message = message

View file

@ -11,7 +11,7 @@ from exceptions import HTTPException
#################################################################################################
LOG = logging.getLogger('Jellyfin.'+__name__)
LOG = logging.getLogger('Jellyfin.' + __name__)
#################################################################################################
@ -127,7 +127,7 @@ class HTTP(object):
raise HTTPException("AccessRestricted", error)
else:
self.client.callback("Unauthorized", {'ServerId': self.config.data['auth.server-id']})
self.client.auth.revoke_token()
self.client.auth.revoke_token()
raise HTTPException("Unauthorized", error)

View file

@ -13,7 +13,7 @@ from ..resources import websocket
##################################################################################################
LOG = logging.getLogger('JELLYFIN.'+__name__)
LOG = logging.getLogger('JELLYFIN.' + __name__)
##################################################################################################