Skip to content

Commit e556377

Browse files
Improved Pro project open failure scenarios
1 parent 59357a4 commit e556377

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

arcpyext/mapping/_cim/pro_project.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,28 @@ def maps(self):
6363
@property
6464
def _cimgisproject(self):
6565
if not "GISProject" in self._cims:
66+
# check what format support we have on ArcGIS Pro
67+
supports_json_proj = hasattr(CIMGISProject, "FromJson")
68+
supports_xml_proj = hasattr(CIMGISProject, "FromXml")
69+
6670
# check what type of GISProject file we have
6771
zp = zipfile.Path(self._proj_zip)
6872
if (zp / "GISProject.xml").exists():
69-
self._cims["GISProject"] = CIMGISProject.FromXml(read_file_in_zip(self._proj_zip, "GISProject.xml"))
73+
if supports_xml_proj:
74+
self._cims["GISProject"] = CIMGISProject.FromXml(read_file_in_zip(self._proj_zip, "GISProject.xml"))
75+
else:
76+
raise NotImplementedError(
77+
"This version of ArcGIS Pro does not support XML-based Projects, project file must be opened in ArcGIS Pro and saved to convert to internal JSON structure."
78+
)
7079
elif (zp / "GISProject.json").exists():
71-
# probably running on ArcGIS Pro 3/ArcGIS Server 11, where the CIM on-disk format has moved to JSON, do that instead
72-
self._cims["GISProject"] = CIMGISProject.FromJson(read_file_in_zip(self._proj_zip, "GISProject.json"))
80+
if supports_json_proj:
81+
self._cims["GISProject"] = CIMGISProject.FromJson(
82+
read_file_in_zip(self._proj_zip, "GISProject.json")
83+
)
84+
else:
85+
raise NotImplementedError(
86+
"This version of ArcGIS Pro does not support JSON-based Projects, please upgrade your ArcGIS Pro install to open this project."
87+
)
7388
else:
7489
raise NotImplementedError("This is an unknown type of ArcGIS Pro project.")
7590

0 commit comments

Comments
 (0)