Fix TypeError, but for real now

- Fixes #290
This commit is contained in:
tomkat83 2017-05-07 14:05:25 +02:00
parent d93850228a
commit 722c3c1821
4 changed files with 19 additions and 18 deletions

View File

@ -401,9 +401,8 @@ class InitialSetup():
dialog = self.dialog
# Get current Kodi video cache setting
try:
cache, _ = advancedsettings_xml(['cache', 'memorysize'])
except TypeError:
cache, _ = advancedsettings_xml(['cache', 'memorysize'])
if cache is None:
# Kodi default cache
cache = '20971520'
else:

View File

@ -297,15 +297,6 @@ class LibrarySync(Thread):
}
if self.enableMusic:
process['music'] = self.PlexMusic
if self.direct_paths is True:
if music.set_excludefromscan_music_folders() is True:
log.info('Detected new Music library - restarting now')
# 'New Plex music library detected. Sorry, but we need to
# restart Kodi now due to the changes made.'
dialog('ok', lang(29999), lang(39711))
from xbmc import executebuiltin
executebuiltin('RestartApp')
return False
# Do the processing
for itemtype in process:
@ -483,6 +474,16 @@ class LibrarySync(Thread):
"""
Compare the views to Plex
"""
if self.direct_paths is True:
if music.set_excludefromscan_music_folders() is True:
log.info('Detected new Music library - restarting now')
# 'New Plex music library detected. Sorry, but we need to
# restart Kodi now due to the changes made.'
dialog('ok', lang(29999), lang(39711))
from xbmc import executebuiltin
executebuiltin('RestartApp')
return False
self.views = []
vnodes = self.vnodes

View File

@ -21,9 +21,8 @@ def get_current_music_folders():
excludefromscan music folders in the advancedsettings.xml
"""
paths = []
try:
root, _ = advancedsettings_xml(['audio', 'excludefromscan'])
except TypeError:
root, _ = advancedsettings_xml(['audio', 'excludefromscan'])
if root is None:
return paths
for element in root:

View File

@ -542,8 +542,10 @@ def __setSubElement(element, subelement):
def advancedsettings_xml(node_list, new_value=None, attrib=None,
force_create=False):
"""
Returns the etree element for nodelist (if it exists) and the tree. None if
not set
Returns
etree element, tree
or
None, None
node_list is a list of node names starting from the outside, ignoring the
outter advancedsettings. Example nodelist=['video', 'busydialogdelayms']
@ -576,7 +578,7 @@ def advancedsettings_xml(node_list, new_value=None, attrib=None,
# Document is blank or missing
if new_value is None and attrib is None and force_create is False:
log.debug('Could not parse advancedsettings.xml, returning None')
return
return None, None
# Create topmost xml entry
tree = etree.ElementTree(element=etree.Element('advancedsettings'))
root = tree.getroot()