Add more logging to views.py

This commit is contained in:
Odd Stråbø 2019-07-08 02:26:54 +02:00
parent 0549a8b0ea
commit c321b266f0
3 changed files with 19 additions and 13 deletions

View file

@ -76,7 +76,7 @@ class Service(xbmc.Monitor):
try:
Views().get_nodes()
except Exception as error:
LOG.error(error)
LOG.exception(error)
window('jellyfin.connected.bool', True)
settings('groupedSets.bool', objects.utils.get_grouped_set())
@ -87,7 +87,7 @@ class Service(xbmc.Monitor):
''' Keeps the service monitor going.
Exit on Kodi shutdown or profile switch.
if profile switch happens more than once,
if profile switch happens more than once,
Threads depending on abortRequest will not trigger.
'''
self.monitor = monitor.Monitor()
@ -230,7 +230,7 @@ class Service(xbmc.Monitor):
if self.waitForAbort(120):
return
self.start_default()
elif method == 'Unauthorized':
@ -243,13 +243,13 @@ class Service(xbmc.Monitor):
if self.waitForAbort(5):
return
self.start_default()
elif method == 'ServerRestarting':
if data.get('ServerId'):
return
if settings('restartMsg.bool'):
dialog("notification", heading="{jellyfin}", message=_(33006), icon="{jellyfin}")
@ -257,7 +257,7 @@ class Service(xbmc.Monitor):
if self.waitForAbort(15):
return
self.start_default()
elif method == 'ServerConnect':
@ -318,7 +318,7 @@ class Service(xbmc.Monitor):
if not self.library_thread.remove_library(lib):
return
self.library_thread.add_library(data['Id'])
xbmc.executebuiltin("Container.Refresh")
@ -326,14 +326,14 @@ class Service(xbmc.Monitor):
libraries = data['Id'].split(',')
for lib in libraries:
if not self.library_thread.remove_library(lib):
return
xbmc.executebuiltin("Container.Refresh")
elif method == 'System.OnSleep':
LOG.info("-->[ sleep ]")
window('jellyfin_should_stop.bool', True)

View file

@ -109,7 +109,6 @@ class MyFormatter(logging.Formatter):
self._gen_rel_path(record)
# Replace the original format with one customized by logging level
#if record.levelno not in [logging.INFO]:
self._fmt = '%(name)s -> %(levelname)s::%(relpath)s:%(lineno)s %(message)s'
# Call the original formatter class to do the grunt work

View file

@ -118,6 +118,7 @@ def verify_kodi_defaults():
src=xbmc.translatePath("special://xbmc/system/library/video").decode('utf-8'),
dst=xbmc.translatePath("special://profile/library/video").decode('utf-8'))
except Exception as error:
LOG.warning(error)
xbmcvfs.mkdir(node_path)
for index, node in enumerate(['movies', 'tvshows', 'musicvideos']):
@ -169,6 +170,7 @@ class Views(object):
libraries = self.server['api'].get_media_folders()['Items']
views = self.server['api'].get_views()['Items']
except Exception as error:
LOG.exception(error)
raise IndexError("Unable to retrieve libraries: %s" % error)
libraries.extend([x for x in views if x['Id'] not in [y['Id'] for y in libraries]])
@ -188,7 +190,7 @@ class Views(object):
try:
libraries = self.get_libraries()
except IndexError as error:
LOG.error(error)
LOG.exception(error)
return
@ -273,6 +275,7 @@ class Views(object):
try:
xml = etree.parse(file).getroot()
except Exception:
LOG.warning("Unable to parse file '%s'", file)
xml = etree.Element('smartplaylist', {'type': view['Media']})
etree.SubElement(xml, 'name')
etree.SubElement(xml, 'match')
@ -316,6 +319,7 @@ class Views(object):
try:
xml = etree.parse(file).getroot()
except Exception:
LOG.warning("Unable to parse file '%s'", file)
xml = self.node_root('folder' if item_type == 'favorites' and view['Media'] == 'episodes' else 'filter', index)
etree.SubElement(xml, 'label')
etree.SubElement(xml, 'match')
@ -371,7 +375,8 @@ class Views(object):
try:
xml = etree.parse(file).getroot()
xml.set('order', str(index))
except Exception:
except Exception as error:
LOG.exception(error)
xml = self.node_root('main', index)
etree.SubElement(xml, 'label')
@ -410,6 +415,7 @@ class Views(object):
try:
xml = etree.parse(file).getroot()
except Exception:
LOG.warning("Unable to parse file '%s'", file)
xml = self.node_root('filter', index)
etree.SubElement(xml, 'label')
etree.SubElement(xml, 'match')
@ -441,6 +447,7 @@ class Views(object):
try:
xml = etree.parse(file).getroot()
except Exception:
LOG.warning("Unable to parse file '%s'", file)
xml = self.node_root('folder', index)
etree.SubElement(xml, 'label')
etree.SubElement(xml, 'content')
@ -692,7 +699,7 @@ class Views(object):
try:
self.media_folders = self.get_libraries()
except IndexError as error:
LOG.error(error)
LOG.exception(error)
for library in (libraries or []):
view = {'Id': library[0], 'Name': library[1], 'Tag': library[1], 'Media': library[2]}