mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 19:12:40 +01:00
Make error handling and logging more detailed
This commit is contained in:
parent
7eb9913391
commit
f5dbb7b0c5
1 changed files with 16 additions and 5 deletions
|
|
@ -28,6 +28,7 @@ from __future__ import division, absolute_import, print_function
|
|||
import requests
|
||||
from beets import config
|
||||
from beets.plugins import BeetsPlugin
|
||||
import six
|
||||
|
||||
|
||||
def update_kodi(host, port, user, password):
|
||||
|
|
@ -72,16 +73,26 @@ class KodiUpdate(BeetsPlugin):
|
|||
def update(self, lib):
|
||||
"""When the client exists try to send refresh request to Kodi server.
|
||||
"""
|
||||
self._log.info(u'Updating Kodi library...')
|
||||
self._log.info(u'Requesting a Kodi library update...')
|
||||
|
||||
# Try to send update request.
|
||||
try:
|
||||
update_kodi(
|
||||
r = update_kodi(
|
||||
config['kodi']['host'].get(),
|
||||
config['kodi']['port'].get(),
|
||||
config['kodi']['user'].get(),
|
||||
config['kodi']['pwd'].get())
|
||||
self._log.info(u'... started.')
|
||||
r.raise_for_status()
|
||||
|
||||
except requests.exceptions.RequestException:
|
||||
self._log.warning(u'Update failed.')
|
||||
except requests.exceptions.RequestException as e:
|
||||
self._log.warning(u'Kodi update failed: {0}',
|
||||
six.text_type(e))
|
||||
return
|
||||
|
||||
json = r.json()
|
||||
if json.get('result') != 'OK':
|
||||
self._log.warning(u'Kodi update failed: JSON response was {0!r}',
|
||||
json)
|
||||
return
|
||||
|
||||
self._log.info(u'Kodi update triggered')
|
||||
|
|
|
|||
Loading…
Reference in a new issue