corrected error handling for password()
This commit is contained in:
parent
eb69913b4c
commit
92f51007ef
1 changed files with 9 additions and 5 deletions
14
mcg.py
14
mcg.py
|
@ -219,10 +219,14 @@ class MCGClient(MCGBase, mpd.MPDClient):
|
||||||
try:
|
try:
|
||||||
self._call('connect', host, port)
|
self._call('connect', host, port)
|
||||||
if password:
|
if password:
|
||||||
self._call('password', password)
|
try:
|
||||||
self._set_connection_status(True, None)
|
self._call('password', password)
|
||||||
|
except mpd.CommandError as e:
|
||||||
|
self._disconnect()
|
||||||
|
raise e
|
||||||
|
self._set_connection_status(True)
|
||||||
except mpd.CommandError as e:
|
except mpd.CommandError as e:
|
||||||
self._set_connection_status(False, e)
|
self._callback(MCGClient.SIGNAL_ERROR, e)
|
||||||
except mpd.ConnectionError as e:
|
except mpd.ConnectionError as e:
|
||||||
self._set_connection_status(False, e)
|
self._set_connection_status(False, e)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
@ -233,7 +237,7 @@ class MCGClient(MCGBase, mpd.MPDClient):
|
||||||
try:
|
try:
|
||||||
self._call('noidle')
|
self._call('noidle')
|
||||||
self._call('disconnect')
|
self._call('disconnect')
|
||||||
self._set_connection_status(False, None)
|
self._set_connection_status(False)
|
||||||
except BrokenPipeError:
|
except BrokenPipeError:
|
||||||
pass
|
pass
|
||||||
except ConnectionResetError as e:
|
except ConnectionResetError as e:
|
||||||
|
@ -376,7 +380,7 @@ class MCGClient(MCGBase, mpd.MPDClient):
|
||||||
except mpd.ConnectionError as e:
|
except mpd.ConnectionError as e:
|
||||||
self._set_connection_status(False, e)
|
self._set_connection_status(False, e)
|
||||||
|
|
||||||
def _set_connection_status(self, status, error):
|
def _set_connection_status(self, status, error=None):
|
||||||
self._connected = status
|
self._connected = status
|
||||||
self._callback(MCGClient.SIGNAL_CONNECT, status, error)
|
self._callback(MCGClient.SIGNAL_CONNECT, status, error)
|
||||||
if not status:
|
if not status:
|
||||||
|
|
Loading…
Reference in a new issue