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

View file

@ -109,7 +109,6 @@ class MyFormatter(logging.Formatter):
self._gen_rel_path(record) self._gen_rel_path(record)
# Replace the original format with one customized by logging level # 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' self._fmt = '%(name)s -> %(levelname)s::%(relpath)s:%(lineno)s %(message)s'
# Call the original formatter class to do the grunt work # 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'), src=xbmc.translatePath("special://xbmc/system/library/video").decode('utf-8'),
dst=xbmc.translatePath("special://profile/library/video").decode('utf-8')) dst=xbmc.translatePath("special://profile/library/video").decode('utf-8'))
except Exception as error: except Exception as error:
LOG.warning(error)
xbmcvfs.mkdir(node_path) xbmcvfs.mkdir(node_path)
for index, node in enumerate(['movies', 'tvshows', 'musicvideos']): for index, node in enumerate(['movies', 'tvshows', 'musicvideos']):
@ -169,6 +170,7 @@ class Views(object):
libraries = self.server['api'].get_media_folders()['Items'] libraries = self.server['api'].get_media_folders()['Items']
views = self.server['api'].get_views()['Items'] views = self.server['api'].get_views()['Items']
except Exception as error: except Exception as error:
LOG.exception(error)
raise IndexError("Unable to retrieve libraries: %s" % 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]]) 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: try:
libraries = self.get_libraries() libraries = self.get_libraries()
except IndexError as error: except IndexError as error:
LOG.error(error) LOG.exception(error)
return return
@ -273,6 +275,7 @@ class Views(object):
try: try:
xml = etree.parse(file).getroot() xml = etree.parse(file).getroot()
except Exception: except Exception:
LOG.warning("Unable to parse file '%s'", file)
xml = etree.Element('smartplaylist', {'type': view['Media']}) xml = etree.Element('smartplaylist', {'type': view['Media']})
etree.SubElement(xml, 'name') etree.SubElement(xml, 'name')
etree.SubElement(xml, 'match') etree.SubElement(xml, 'match')
@ -316,6 +319,7 @@ class Views(object):
try: try:
xml = etree.parse(file).getroot() xml = etree.parse(file).getroot()
except Exception: 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) xml = self.node_root('folder' if item_type == 'favorites' and view['Media'] == 'episodes' else 'filter', index)
etree.SubElement(xml, 'label') etree.SubElement(xml, 'label')
etree.SubElement(xml, 'match') etree.SubElement(xml, 'match')
@ -371,7 +375,8 @@ class Views(object):
try: try:
xml = etree.parse(file).getroot() xml = etree.parse(file).getroot()
xml.set('order', str(index)) xml.set('order', str(index))
except Exception: except Exception as error:
LOG.exception(error)
xml = self.node_root('main', index) xml = self.node_root('main', index)
etree.SubElement(xml, 'label') etree.SubElement(xml, 'label')
@ -410,6 +415,7 @@ class Views(object):
try: try:
xml = etree.parse(file).getroot() xml = etree.parse(file).getroot()
except Exception: except Exception:
LOG.warning("Unable to parse file '%s'", file)
xml = self.node_root('filter', index) xml = self.node_root('filter', index)
etree.SubElement(xml, 'label') etree.SubElement(xml, 'label')
etree.SubElement(xml, 'match') etree.SubElement(xml, 'match')
@ -441,6 +447,7 @@ class Views(object):
try: try:
xml = etree.parse(file).getroot() xml = etree.parse(file).getroot()
except Exception: except Exception:
LOG.warning("Unable to parse file '%s'", file)
xml = self.node_root('folder', index) xml = self.node_root('folder', index)
etree.SubElement(xml, 'label') etree.SubElement(xml, 'label')
etree.SubElement(xml, 'content') etree.SubElement(xml, 'content')
@ -692,7 +699,7 @@ class Views(object):
try: try:
self.media_folders = self.get_libraries() self.media_folders = self.get_libraries()
except IndexError as error: except IndexError as error:
LOG.error(error) LOG.exception(error)
for library in (libraries or []): for library in (libraries or []):
view = {'Id': library[0], 'Name': library[1], 'Tag': library[1], 'Media': library[2]} view = {'Id': library[0], 'Name': library[1], 'Tag': library[1], 'Media': library[2]}