Merge branch 'master' into cpc
This commit is contained in:
commit
d65c76c528
@ -26,6 +26,8 @@ We got an updated :doc:`release roadmap <development/roadmap>`!
|
||||
command error instead of crashing.
|
||||
- ``list`` accepts field argument without quotes and capitalized, to work
|
||||
with GMPC and ncmpc.
|
||||
- ``noidle`` command now returns ``OK`` instead of an error. Should make some
|
||||
clients work a bit better.
|
||||
|
||||
- Backend API:
|
||||
|
||||
|
||||
@ -243,10 +243,6 @@ class BaseCurrentPlaylistController(object):
|
||||
self._cp_tracks = before + shuffled + after
|
||||
self.version += 1
|
||||
|
||||
def destroy(self):
|
||||
"""Cleanup after component."""
|
||||
pass
|
||||
|
||||
def mpd_format(self, *args, **kwargs):
|
||||
# XXX Lazy workaround to make tests pass while refactoring
|
||||
return Playlist(tracks=self.tracks).mpd_format(*args, **kwargs)
|
||||
|
||||
@ -639,8 +639,8 @@ class MpdFrontend(object):
|
||||
|
||||
@handle_pattern(r'^list (?P<field>[Aa]rtist)$')
|
||||
@handle_pattern(r'^list "(?P<field>[Aa]rtist)"$')
|
||||
@handle_pattern(r'^list (?P<field>album)( "(?P<artist>[^"]+)")*$')
|
||||
@handle_pattern(r'^list "(?P<field>album)"( "(?P<artist>[^"]+)")*$')
|
||||
@handle_pattern(r'^list (?P<field>album( artist)?)( "(?P<artist>[^"]+)")*$')
|
||||
@handle_pattern(r'^list "(?P<field>album(" "artist)?)"( "(?P<artist>[^"]+)")*$')
|
||||
def _music_db_list(self, field, artist=None):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
@ -656,6 +656,17 @@ class MpdFrontend(object):
|
||||
*GMPC:*
|
||||
|
||||
- does not add quotes around the field argument.
|
||||
- asks for multiple fields, i.e.::
|
||||
|
||||
list album artist "an artist name"
|
||||
|
||||
returns the albums available for the asked artist::
|
||||
|
||||
list album artist "Tiesto"
|
||||
Album: Radio Trance Vol 4-Promo-CD
|
||||
Album: Ur A Tear in the Open CDR
|
||||
Album: Simple Trance 2004 Step One
|
||||
Album: In Concert 05-10-2003
|
||||
|
||||
*ncmpc:*
|
||||
|
||||
@ -663,7 +674,7 @@ class MpdFrontend(object):
|
||||
- capitalizes the field argument.
|
||||
"""
|
||||
field = field.lower()
|
||||
# TODO
|
||||
pass # TODO
|
||||
|
||||
@handle_pattern(r'^listall "(?P<uri>[^"]+)"')
|
||||
def _music_db_listall(self, uri):
|
||||
@ -1242,7 +1253,7 @@ class MpdFrontend(object):
|
||||
@handle_pattern(r'^noidle$')
|
||||
def _status_noidle(self):
|
||||
"""See :meth:`_status_idle`."""
|
||||
raise MpdNotImplemented # TODO
|
||||
pass # TODO
|
||||
|
||||
@handle_pattern(r'^stats$')
|
||||
def _status_stats(self):
|
||||
|
||||
@ -32,10 +32,15 @@ class MpdServer(asyncore.dispatcher):
|
||||
|
||||
def start(self):
|
||||
try:
|
||||
self.create_socket(socket.AF_INET6, socket.SOCK_STREAM)
|
||||
if socket.has_ipv6:
|
||||
self.create_socket(socket.AF_INET6, socket.SOCK_STREAM)
|
||||
else:
|
||||
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.set_reuse_addr()
|
||||
self.bind((self._format_hostname(settings.SERVER_HOSTNAME),
|
||||
settings.SERVER_PORT))
|
||||
hostname = self._format_hostname(settings.SERVER_HOSTNAME)
|
||||
port = settings.SERVER_PORT
|
||||
logger.debug(u'Binding to [%s]:%s', hostname, port)
|
||||
self.bind((hostname, port))
|
||||
self.listen(1)
|
||||
logger.info(u'MPD server running at [%s]:%s',
|
||||
self._format_hostname(settings.SERVER_HOSTNAME),
|
||||
@ -54,7 +59,8 @@ class MpdServer(asyncore.dispatcher):
|
||||
self.close()
|
||||
|
||||
def _format_hostname(self, hostname):
|
||||
if re.match('\d+.\d+.\d+.\d+', hostname) is not None:
|
||||
if (socket.has_ipv6
|
||||
and re.match('\d+.\d+.\d+.\d+', hostname) is not None):
|
||||
hostname = '::ffff:%s' % hostname
|
||||
return hostname
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ class StatusHandlerTest(unittest.TestCase):
|
||||
|
||||
def test_noidle(self):
|
||||
result = self.h.handle_request(u'noidle')
|
||||
self.assert_(u'ACK [0@0] {} Not implemented' in result)
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_stats_command(self):
|
||||
result = self.h.handle_request(u'stats')
|
||||
@ -1029,6 +1029,10 @@ class MusicDatabaseHandlerTest(unittest.TestCase):
|
||||
def test_list_album_with_artist(self):
|
||||
result = self.h.handle_request(u'list "album" "anartist"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_list_album_artist_with_artist_without_quotes(self):
|
||||
result = self.h.handle_request(u'list album artist "anartist"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_listall(self):
|
||||
result = self.h.handle_request(u'listall "file:///dev/urandom"')
|
||||
|
||||
@ -1,20 +1,25 @@
|
||||
import unittest
|
||||
|
||||
from mopidy.mpd.server import MpdServer, MpdSession
|
||||
from mopidy.mpd import server
|
||||
|
||||
class MpdServerTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.server = MpdServer(None)
|
||||
self.server = server.MpdServer(None)
|
||||
|
||||
def test_format_hostname_prefixes_ipv4_addresses(self):
|
||||
def test_format_hostname_prefixes_ipv4_addresses_when_ipv6_available(self):
|
||||
server.socket.has_ipv6 = True
|
||||
self.assertEqual(self.server._format_hostname('0.0.0.0'),
|
||||
'::ffff:0.0.0.0')
|
||||
self.assertEqual(self.server._format_hostname('127.0.0.1'),
|
||||
'::ffff:127.0.0.1')
|
||||
|
||||
def test_format_hostname_does_nothing_when_only_ipv4_available(self):
|
||||
server.socket.has_ipv6 = False
|
||||
self.assertEquals(self.server._format_hostname('0.0.0.0'), '0.0.0.0')
|
||||
|
||||
class MpdSessionTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.session = MpdSession(None, None, (None, None), None)
|
||||
self.session = server.MpdSession(None, None, (None, None), None)
|
||||
|
||||
def test_found_terminator_catches_decode_error(self):
|
||||
# Pressing Ctrl+C in a telnet session sends a 0xff byte to the server.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user