from . import core, info
from .lib.logger import set_logger
from .lib.simadb import SimaDB
+from .mpdclient import PlayerError
from .utils.config import ConfMan
from .utils.startopt import StartOpt
from .utils.utils import exception_log, SigHup, MPDSimaException
start(sopt, restart)
except SigHup: # SigHup inherit from Exception
run(sopt, True)
- except MPDSimaException as err:
+ except (MPDSimaException, PlayerError) as err:
logger.error(err)
sys.exit(2)
except Exception: # Unhandled exception
from select import select
# external module
-from musicpd import MPDClient, MPDError
+from musicpd import MPDClient, MPDError as PlayerError
# local import
from .lib.track import Track
from .lib.simastr import SimaStr
from .utils.leven import levenshtein_ratio
-from .utils.utils import MPDSimaException
-
-
-class PlayerError(MPDSimaException):
- """Fatal error in the player."""
# Some decorators
return super().__getattr__(cmd)
except OSError as err: # socket errors
raise PlayerError(err) from err
- except MPDError as err: # hight level MPD client errors
- raise PlayerError(err) from err
def disconnect(self):
"""Overriding explicitly MPDClient.disconnect()"""
if password:
try:
self.password(password)
- except (MPDError, OSError) as err:
+ except OSError as err:
raise PlayerError(f"Could not connect to '{host}': {err}") from err
# Controls we have sufficient rights
available_cmd = self.commands()
self.noidle()
except OSError as err:
raise PlayerError(err) from err
- except MPDError as err: # hight level MPD client errors
- raise PlayerError(err) from err
def clean(self):
"""Clean blocking event (idle) and pending commands
import sys
# local import
-from ..mpdclient import MPD, PlayerError, Artist, Album
+from ..mpdclient import MPD, Artist, Album
from ..lib.simadb import SimaDB
cmd = options.get('command', None)
if not cmd or not cmd.startswith('bl-'):
return
- try:
- getattr(self, cmd.replace('-', '_'))()
- except PlayerError as err:
- self.log.error(err)
- sys.exit(1)
+ getattr(self, cmd.replace('-', '_'))()
def bl_view(self):
blocklist = self.sdb.view_bl()