keywords='MPD',
long_description=DESCRIPTION,
classifiers=classifiers,
- install_requires=['python-musicpd', 'requests'],
+ install_requires=['python-musicpd>=0.4.1', 'requests>= 2.0.2'],
packages=find_packages(exclude=["tests"]),
include_package_data=True,
data_files=data_files,
def monitor(self):
curr = self.current
try:
- self._client.send_idle('database', 'playlist', 'player', 'options')
+ self.send_idle('database', 'playlist', 'player', 'options')
select([self._client], [], [], 60)
- ret = self._client.fetch_idle()
+ ret = self.fetch_idle()
if self.__skipped_track(curr):
ret.append('skipped')
if 'database' in ret:
except (MPDError, IOError) as err:
raise PlayerError("Couldn't init idle: %s" % err)
+ def clean(self):
+ """Clean blocking event (idle) and pending commands
+ """
+ if 'idle' in self._client._pending:
+ self._client.noidle()
+ elif self._client._pending:
+ self.log.warning('pending commands: {}'.format(self._client._pending))
+
def remove(self, position=0):
self._client.delete(position)
def hup_handler(self, signum, frame):
self.log.warning('Caught a sighup!')
- self.player.disconnect()
+ # Cleaning pending command
+ self.player.clean()
self.foreach_plugin('shutdown')
+ self.player.disconnect()
raise SigHup('SIGHUP caught!')
def shutdown(self):
"""General shutdown method
"""
self.log.warning('Starting shutdown.')
+ # Cleaning pending command
+ self.player.clean()
self.foreach_plugin('shutdown')
self.player.disconnect()
"""
raise NotImplementedError
+ def clean(self):
+ """Any cleanup necessary"""
+ pass
+
def remove(self, position=0):
"""Removes the oldest element of the playlist (index 0)
"""