Warn user if a xml cannot be parsed
This commit is contained in:
parent
66fe13786f
commit
179e97b200
2 changed files with 38 additions and 4 deletions
|
@ -1919,3 +1919,8 @@ msgstr ""
|
||||||
msgctxt "#39715"
|
msgctxt "#39715"
|
||||||
msgid "items"
|
msgid "items"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
# Error message if an xml, e.g. advancedsettings.xml cannot be parsed (xml is screwed up; formated the wrong way). Do NOT replace {0} and {1}!
|
||||||
|
msgctxt "#39716"
|
||||||
|
msgid "Kodi cannot parse {0}. PKC will not function correctly. Please visit {1} and correct your file!"
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -536,9 +536,16 @@ def guisettingsXML():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xmlparse = etree.parse(xmlpath)
|
xmlparse = etree.parse(xmlpath)
|
||||||
except:
|
except IOError:
|
||||||
# Document is blank or missing
|
# Document is blank or missing
|
||||||
root = etree.Element('settings')
|
root = etree.Element('settings')
|
||||||
|
except etree.ParseError:
|
||||||
|
log.error('Error parsing %s' % xmlpath)
|
||||||
|
# "Kodi cannot parse {0}. PKC will not function correctly. Please visit
|
||||||
|
# {1} and correct your file!"
|
||||||
|
dialog('ok', language(29999), language(39716).format(
|
||||||
|
'guisettings.xml', 'http://kodi.wiki/view/userdata'))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
root = xmlparse.getroot()
|
root = xmlparse.getroot()
|
||||||
return root
|
return root
|
||||||
|
@ -620,6 +627,14 @@ def advancedsettings_xml(node_list, new_value=None, attrib=None,
|
||||||
return None, None
|
return None, None
|
||||||
# Create topmost xml entry
|
# Create topmost xml entry
|
||||||
tree = etree.ElementTree(element=etree.Element('advancedsettings'))
|
tree = etree.ElementTree(element=etree.Element('advancedsettings'))
|
||||||
|
except etree.ParseError:
|
||||||
|
log.error('Error parsing %s' % path)
|
||||||
|
# "Kodi cannot parse {0}. PKC will not function correctly. Please visit
|
||||||
|
# {1} and correct your file!"
|
||||||
|
dialog('ok', language(29999), language(39716).format(
|
||||||
|
'advancedsettings.xml',
|
||||||
|
'http://kodi.wiki/view/Advancedsettings.xml'))
|
||||||
|
return None, None
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
element = root
|
element = root
|
||||||
|
|
||||||
|
@ -653,8 +668,15 @@ def sourcesXML():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xmlparse = etree.parse(xmlpath)
|
xmlparse = etree.parse(xmlpath)
|
||||||
except: # Document is blank or missing
|
except IOError: # Document is blank or missing
|
||||||
root = etree.Element('sources')
|
root = etree.Element('sources')
|
||||||
|
except etree.ParseError:
|
||||||
|
log.error('Error parsing %s' % xmlpath)
|
||||||
|
# "Kodi cannot parse {0}. PKC will not function correctly. Please visit
|
||||||
|
# {1} and correct your file!"
|
||||||
|
dialog('ok', language(29999), language(39716).format(
|
||||||
|
'sources.xml', 'http://kodi.wiki/view/sources.xml'))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
root = xmlparse.getroot()
|
root = xmlparse.getroot()
|
||||||
|
|
||||||
|
@ -690,18 +712,25 @@ def passwordsXML():
|
||||||
# To add network credentials
|
# To add network credentials
|
||||||
path = tryDecode(xbmc.translatePath("special://userdata/"))
|
path = tryDecode(xbmc.translatePath("special://userdata/"))
|
||||||
xmlpath = "%spasswords.xml" % path
|
xmlpath = "%spasswords.xml" % path
|
||||||
|
dialog = xbmcgui.Dialog()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
xmlparse = etree.parse(xmlpath)
|
xmlparse = etree.parse(xmlpath)
|
||||||
except:
|
except IOError:
|
||||||
# Document is blank or missing
|
# Document is blank or missing
|
||||||
root = etree.Element('passwords')
|
root = etree.Element('passwords')
|
||||||
skipFind = True
|
skipFind = True
|
||||||
|
except etree.ParseError:
|
||||||
|
log.error('Error parsing %s' % xmlpath)
|
||||||
|
# "Kodi cannot parse {0}. PKC will not function correctly. Please visit
|
||||||
|
# {1} and correct your file!"
|
||||||
|
dialog.ok(language(29999), language(39716).format(
|
||||||
|
'passwords.xml', 'http://forum.kodi.tv/'))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
root = xmlparse.getroot()
|
root = xmlparse.getroot()
|
||||||
skipFind = False
|
skipFind = False
|
||||||
|
|
||||||
dialog = xbmcgui.Dialog()
|
|
||||||
credentials = settings('networkCreds')
|
credentials = settings('networkCreds')
|
||||||
if credentials:
|
if credentials:
|
||||||
# Present user with options
|
# Present user with options
|
||||||
|
|
Loading…
Reference in a new issue