You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the clone_items method on items that don't have the name property set, the method clone() in arcgis_impl\common_clone.py will try to create a name from the item url. In some cases this can contain Swedish characters (å, ä, ö).
The regex used only replace non word characters, but these swedish characters are word characters, but still invalid in the name of ArcGIS items.
# Code excerpt from line 2929ifnameisNone:
name=os.path.basename(os.path.dirname(original_item["url"]))
# replace non-alphanumeric characters with underscorename=re.sub("\W+", "_", name) # <---- This is the problematic regexname=self._get_unique_name(self.target, name)
service_definition["name"] =name
To Reproduce
Steps to reproduce the behavior:
fromarcgis.gisimportGISsource_gis=GIS(profile="admin@source_gis")
target_gis=GIS(profile="admin@target_gis")
# get an item that doesn't have the .name property set, but has Swedish characters in urlitem_without_name=source_gis.content.get("xxxxxxx")
new_itm=target_gis.content.clone_items([item_without_name])
error:
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\site-packages\arcgis\_impl\common\_clone.pyinclone(self)
3024try:
->3025new_item=self.target.content.create_service(
3026name,
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\site-packages\arcgis\gis\__init__.pyincreate_service(self, name, service_description, has_static_data, max_record_count, supported_query_formats, capabilities, description, copyright_text, wkid, create_params, service_type, owner, folder, item_properties, is_view, tags, snippet, item_id)
7183iflen(re.findall(regex, name)) ==0:
->7184raiseValueError(
7185"The service `name` cannot contain any spaces or special characters except underscores."ValueError: Theservice`name`cannotcontainanyspacesorspecialcharactersexceptunderscores.
Duringhandlingoftheaboveexception, anotherexceptionoccurred:
_ItemCreateExceptionTraceback (mostrecentcalllast)
~\AppData\Local\Temp\ipykernel_26300\2307847236.pyin<cellline: 1>()
---->1target_gis.content.clone_items([itm_bad_name])
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\site-packages\arcgis\gis\__init__.pyinclone_items(self, items, folder, item_extent, use_org_basemap, copy_data, copy_global_ids, search_existing_items, item_mapping, group_mapping, owner, preserve_item_id, **kwargs)
8560wab_code_attach=kwargs.pop("copy_code_attachment", True),
8561 )
->8562returndeep_cloner.clone()
85638564defbulk_update(
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\site-packages\arcgis\_impl\common\_clone.pyinclone(self)
1320else:
1321withconcurrent.futures.ThreadPoolExecutor(max_workers=20) asexecutor:
->1322results=executor.submit(self._clone, executor).result()
1323returnresults1324~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\concurrent\futures\_base.pyinresult(self, timeout)
444raiseCancelledError()
445elifself._state==FINISHED:
-->446returnself.__get_result()
447else:
448raiseTimeoutError()
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\concurrent\futures\_base.pyin__get_result(self)
389ifself._exception:
390try:
-->391raiseself._exception392finally:
393# Break a reference cycle with the exception in self._exception~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\concurrent\futures\thread.pyinrun(self)
5657try:
--->58result=self.fn(*self.args, **self.kwargs)
59exceptBaseExceptionasexc:
60self.future.set_exception(exc)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\site-packages\arcgis\_impl\common\_clone.pyin_clone(self, excecutor)
1294ifitem:
1295item.delete()
->1296raiseex12971298level+=1~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\concurrent\futures\thread.pyinrun(self)
5657try:
--->58result=self.fn(*self.args, **self.kwargs)
59exceptBaseExceptionasexc:
60self.future.set_exception(exc)
~\AppData\Local\ESRI\conda\envs\arcgispro-py3-dev\lib\site-packages\arcgis\_impl\common\_clone.pyinclone(self)
3994returnnew_item3995exceptExceptionasex:
->3996raise_ItemCreateException(
3997"Failed to create {0} {1}: {2}".format(
3998original_item["type"], original_item["title"], str(ex)
_ItemCreateException: ('Failed to create Feature Service Borlänge befolkning 15_80 500x500 2022 x: The service `name` cannot contain any spaces or special characters except underscores.', None)
Expected behavior
That the cloning works
Platform (please complete the following information):
Python API Version: 2.2.0.1
The text was updated successfully, but these errors were encountered:
@sverkerEsriSE how are you creating these items with no name property set? Or is there an example of a publicly available service with swedish characters in the name that I can test?
Describe the bug
When using the clone_items method on items that don't have the name property set, the method clone() in arcgis_impl\common_clone.py will try to create a name from the item url. In some cases this can contain Swedish characters (å, ä, ö).
The regex used only replace non word characters, but these swedish characters are word characters, but still invalid in the name of ArcGIS items.
To Reproduce
Steps to reproduce the behavior:
error:
Expected behavior
That the cloning works
Platform (please complete the following information):
2.2.0.1
The text was updated successfully, but these errors were encountered: