AlexArcPy / registrant

Python package used for generating HTML reports about the contents of Esri geodatabases.
MIT License
70 stars 17 forks source link

Parsing XML for replica data fails on certain GDBs #4

Closed tom-montgomery closed 6 years ago

tom-montgomery commented 6 years ago

On a certain enterprise geodatabase registrant report_gdb_as_html fails with the following message:

Traceback (most recent call last): File "C:/Users/140318/Desktop/Python/Scripts/GDB Summary/SummarizeGDB.py", line 23, in registrant.report_gdb_as_html(gdb_origin, summary) File "C:\Python27\ArcGISx6410.3\lib\site-packages\registrant-0.3-py2.7.egg\registrant_reporter.py", line 105, in report_gdb_as_html replicas = gdb.get_replicas() File "C:\Python27\ArcGISx6410.3\lib\site-packages\registrant-0.3-py2.7.egg\registrant_geodatabase.py", line 83, in get_replicas xml = ET.fromstring(data) File "C:\Python27\ArcGISx6410.3\lib\xml\etree\ElementTree.py", line 1301, in XML return parser.close() File "C:\Python27\ArcGISx6410.3\lib\xml\etree\ElementTree.py", line 1654, in close self._raiseerror(v) File "C:\Python27\ArcGISx6410.3\lib\xml\etree\ElementTree.py", line 1506, in _raiseerror raise err xml.etree.ElementTree.ParseError: no element found: line 2, column 0

This only occurs on one geodatabase, the others work as expected. Attached is the xml replica summary with connection data removed. replicaxml.zip

AlexArcPy commented 6 years ago

@tom-montgomery , thanks for reporting this. Interesting. The XML file you've attached is not the file that would be created when ExportReplicaSchema_management runs, right? The reason I say that is because the .xml file created by this GP tool doesn't have any formatting such as new lines whereas yours has.

What I think you could do is to run the code in debugging mode and set a breakpoint on line https://github.com/AlexArcPy/registrant/blob/master/registrant/_geodatabase.py#L77. Check the .xml file created and see what is loaded into the data variable. I think it loads just a few lines instead of the whole .xml file contents. Play with the ET.fromstring(data) and try to identify what's wrong with the .xml file created.

tom-montgomery commented 6 years ago

Yea its the export from ExportReplicaSchema_management... I will try debugging. I used brackets' beatufiy function to add formatting to make it readable. Thanks.

tom-montgomery commented 6 years ago

I think its because these databases are still version 9.3. Not sure if its fixable

AlexArcPy commented 6 years ago

Ah, interesting. If I remember right, the schema of geodatabase (including replica) has changed in 10.x, so I am afraid I won't be able to parse the 9.3 schema's XML. I guess most users are on 10.0+, so I don't think it would be worth trying to support the 9.3 version. @tom-montgomery , are you OK with that?

tom-montgomery commented 6 years ago

Definitely man all good. I just realized why because my replica2mxd was failing on the same databases. We really need to upgrade for a lot of reasons...we are oldschool like that haha. =)

AlexArcPy commented 6 years ago

The failure of parsing of replica's XML schema was caused by having the geodatabase in v 9.3. Only 10.0+ are supported by registrant.