Fix pylint warnings in MPD frontend
This commit is contained in:
parent
68a671414c
commit
e6294ec869
@ -7,7 +7,7 @@ from pykka.registry import ActorRegistry
|
|||||||
from mopidy import settings
|
from mopidy import settings
|
||||||
from mopidy.backends.base import Backend
|
from mopidy.backends.base import Backend
|
||||||
from mopidy.frontends.mpd.exceptions import (MpdAckError, MpdArgError,
|
from mopidy.frontends.mpd.exceptions import (MpdAckError, MpdArgError,
|
||||||
MpdPermissionError, MpdPasswordError, MpdSystemError, MpdUnknownCommand)
|
MpdPermissionError, MpdSystemError, MpdUnknownCommand)
|
||||||
from mopidy.frontends.mpd.protocol import mpd_commands, request_handlers
|
from mopidy.frontends.mpd.protocol import mpd_commands, request_handlers
|
||||||
# Do not remove the following import. The protocol modules must be imported to
|
# Do not remove the following import. The protocol modules must be imported to
|
||||||
# get them registered as request handlers.
|
# get them registered as request handlers.
|
||||||
@ -74,7 +74,8 @@ class MpdDispatcher(object):
|
|||||||
return self._call_next_filter(request, response, filter_chain)
|
return self._call_next_filter(request, response, filter_chain)
|
||||||
else:
|
else:
|
||||||
command = request.split(' ')[0]
|
command = request.split(' ')[0]
|
||||||
if command in ('close', 'commands', 'notcommands', 'password', 'ping'):
|
if command in (
|
||||||
|
'close', 'commands', 'notcommands', 'password', 'ping'):
|
||||||
return self._call_next_filter(request, response, filter_chain)
|
return self._call_next_filter(request, response, filter_chain)
|
||||||
else:
|
else:
|
||||||
raise MpdPermissionError(command=command)
|
raise MpdPermissionError(command=command)
|
||||||
@ -142,7 +143,7 @@ class MpdDispatcher(object):
|
|||||||
def _format_response(self, response):
|
def _format_response(self, response):
|
||||||
formatted_response = []
|
formatted_response = []
|
||||||
for element in self._listify_result(response):
|
for element in self._listify_result(response):
|
||||||
formatted_response.extend(self._format_lines(element))
|
formatted_response.extend(self._format_lines(element))
|
||||||
return formatted_response
|
return formatted_response
|
||||||
|
|
||||||
def _listify_result(self, result):
|
def _listify_result(self, result):
|
||||||
|
|||||||
@ -36,7 +36,8 @@ def command_list_end(context):
|
|||||||
response = context.dispatcher.handle_request(
|
response = context.dispatcher.handle_request(
|
||||||
command, current_command_list_index=index)
|
command, current_command_list_index=index)
|
||||||
command_list_response.extend(response)
|
command_list_response.extend(response)
|
||||||
if command_list_response and command_list_response[-1].startswith(u'ACK'):
|
if (command_list_response and
|
||||||
|
command_list_response[-1].startswith(u'ACK')):
|
||||||
return command_list_response
|
return command_list_response
|
||||||
if command_list_ok:
|
if command_list_ok:
|
||||||
command_list_response.append(u'list_OK')
|
command_list_response.append(u'list_OK')
|
||||||
|
|||||||
@ -52,7 +52,8 @@ class MpdServer(asyncore.dispatcher):
|
|||||||
self._format_hostname(settings.MPD_SERVER_HOSTNAME),
|
self._format_hostname(settings.MPD_SERVER_HOSTNAME),
|
||||||
settings.MPD_SERVER_PORT)
|
settings.MPD_SERVER_PORT)
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
logger.error(u'MPD server startup failed: %s' % str(e).decode('utf-8'))
|
logger.error(u'MPD server startup failed: %s' %
|
||||||
|
str(e).decode('utf-8'))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def handle_accept(self):
|
def handle_accept(self):
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import asynchat
|
import asynchat
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from mopidy import settings
|
|
||||||
from mopidy.frontends.mpd.dispatcher import MpdDispatcher
|
from mopidy.frontends.mpd.dispatcher import MpdDispatcher
|
||||||
from mopidy.frontends.mpd.protocol import ENCODING, LINE_TERMINATOR, VERSION
|
from mopidy.frontends.mpd.protocol import ENCODING, LINE_TERMINATOR, VERSION
|
||||||
from mopidy.utils.log import indent
|
from mopidy.utils.log import indent
|
||||||
@ -46,7 +45,10 @@ class MpdSession(asynchat.async_chat):
|
|||||||
return self.dispatcher.handle_request(request)
|
return self.dispatcher.handle_request(request)
|
||||||
|
|
||||||
def send_response(self, response):
|
def send_response(self, response):
|
||||||
"""Format a response from the MPD command handlers and send it to the client."""
|
"""
|
||||||
|
Format a response from the MPD command handlers and send it to the
|
||||||
|
client.
|
||||||
|
"""
|
||||||
if response is not None:
|
if response is not None:
|
||||||
response = LINE_TERMINATOR.join(response)
|
response = LINE_TERMINATOR.join(response)
|
||||||
logger.debug(u'Response to [%s]:%s: %s', self.client_address,
|
logger.debug(u'Response to [%s]:%s: %s', self.client_address,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user