diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-20 15:09:09 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-20 15:09:09 -0400 |
commit | 40d3802f31ffbc1f48689a7bbb3087bda1c52f35 (patch) | |
tree | 40f9d6885e2cae2d21fe9041e98d47774306dea6 /tools/upgrade | |
parent | c25b2ba21fbf5a349a49173bdfd82e208b9f74bd (diff) | |
download | bcfg2-40d3802f31ffbc1f48689a7bbb3087bda1c52f35.tar.gz bcfg2-40d3802f31ffbc1f48689a7bbb3087bda1c52f35.tar.bz2 bcfg2-40d3802f31ffbc1f48689a7bbb3087bda1c52f35.zip |
migrate_perms_to_mode.py: gracefully handle unparseable XML files
Diffstat (limited to 'tools/upgrade')
-rwxr-xr-x | tools/upgrade/1.3/migrate_perms_to_mode.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/upgrade/1.3/migrate_perms_to_mode.py b/tools/upgrade/1.3/migrate_perms_to_mode.py index ff3fe91c0..a5e045750 100755 --- a/tools/upgrade/1.3/migrate_perms_to_mode.py +++ b/tools/upgrade/1.3/migrate_perms_to_mode.py @@ -24,7 +24,12 @@ def writefile(f, xdata): def convertinfo(ifile): """Do perms -> mode conversion for info.xml files.""" - xdata = lxml.etree.parse(ifile) + try: + xdata = lxml.etree.parse(ifile) + except lxml.etree.XMLSyntaxError: + err = sys.exc_info()[1] + print("Could not parse %s, skipping: %s" % (ifile, err)) + return found = False for i in xdata.findall('//Info'): found = setmodeattr(i) @@ -34,7 +39,12 @@ def convertinfo(ifile): def convertstructure(structfile): """Do perms -> mode conversion for structure files.""" - xdata = lxml.etree.parse(structfile) + try: + xdata = lxml.etree.parse(structfile) + except lxml.etree.XMLSyntaxError: + err = sys.exc_info()[1] + print("Could not parse %s, skipping: %s" % (structfile, err)) + return found = False for path in xdata.xpath('//BoundPath|//Path'): found = setmodeattr(path) |