Esri / hub-py

Python interface to ArcGIS Hub
https://github.com/esri/hub-py/wiki
Apache License 2.0
42 stars 13 forks source link

Cloning of Initiative Returns NoneType #98

Closed CJuice closed 3 years ago

CJuice commented 4 years ago

Have a script using this repo to clone our Hub initiative as a means of backing up our production Covid site resource. It has been running for many months, twice a day. Occasionally it has hit this issue but it never persisted past a day or two of process runs. Now, the issue is occurring for days on end and hasn't self resolved. Not sure if this is an AGOL issue or this repo, starting here though because the AGOL manual clone still works properly.

The code call of concern:

try: cloned_initiative_arcgishub = my_hub_arcgishub.initiatives.clone(target_initiative_arcgishub, title=f"{new_hub_title}") except TypeError as te: print(f"TypeError raised: \n{te}") print(f"hub connection: {my_hub_arcgishub}") print(f"hub initiative object: {target_initiative_arcgishub}") print(f"cloned initiative object: {cloned_initiative_arcgishub}") # This appears to be the None object

The target_initiative_arcgishub exists and the new_hub_title is a string with the word "Backup" and a datetime stamp. This line has executed successfully for months, minus the intermittent occurrence of this issue.

The error returned is:

Error Message: Traceback (most recent call last): File "D:\Scripts\COVID_19_HubSiteBackupProcess\DoIT_CovidHubSiteBackupProcess\doit_Coronavirus_Hub_Cloning_Main.py", line 141, in main title=f"{new_hub_title}") File "d:\scripts\covid_19_hubsitebackupprocess\src\arcgishub\arcgishub\hub.py", line 551, in clone new_initiative = self._hub.initiatives.add(title=title, site=site) File "d:\scripts\covid_19_hubsitebackupprocess\src\arcgishub\arcgishub\hub.py", line 504, in add site = _initiative.sites.clone(site, pages=True, title=title) File "d:\scripts\covid_19_hubsitebackupprocess\src\arcgishub\arcgishub\sites.py", line 622, in clone new_site.pages.clone(page) File "d:\scripts\covid_19_hubsitebackupprocess\src\arcgishub\arcgishub\sites.py", line 942, in clone _cloned_page = site.pages.add(title) File "d:\scripts\covid_19_hubsitebackupprocess\src\arcgishub\arcgishub\sites.py", line 909, in add status = site.pages.link(page) File "d:\scripts\covid_19_hubsitebackupprocess\src\arcgishub\arcgishub\sites.py", line 1014, in link _site_data['values']['pages'].append(_new_page) TypeError: 'NoneType' object is not subscriptable

We are using Python 3.7 It fails if run locally on laptop or on server. Not sure if this is related to #84 We can clone the initiative/site manually through the web. That method works fine but doing so programmatically now fails. Last note, this is my first time submitting an issue so if there is more I need to do please educate me. Thanks