I'm writing a script to export some feature services in AGOL to FGDB and then download them.
The export process takes a while but my code doesn't pause execution despite using wait='True'. This results in a corrupted zip file as my code downloads it before the export has finished.
Since gis.item.export returns a jobid I would think I could poll the job status until it is success however I don't see a rest endpoint to do this. I've tried things like https://services1.arcgis.com/myorg/ArcGIS/rest/services/myFS/jobs/<jobid> but I don't see any status messages.
As of right now I am putting in an arbitrary 3 minute wait timer but I would like something a little less hacky.
mygis = GIS(username="myuser",password="*****")
service = mygis.content.get(itemID)
itemDes = service.export(title="DamageReports", export_format= 'File Geodatabase', parameters=None, wait='True')
fgdb = mygis.content.get(itemDes['exportItemId'])
<wait time goes here>
Hey Drew Dowling,
Have you seen this support article for downloading services as a FDGB? It was initially written to loop through items located services through gis.content.search(). However, if you have a list of specific items you could use gis.content.get() to loop through the item IDs instead.
I'm not certain about the checking on the status of an export job and will have to look into it, but I know the following should work without any corruption issues:
itemDes = service.export(service.title + "_" + version, "File Geodatabase")
itemDes.download(file path for backup_location)
I believe the problem is that the code above will run once itemDes has finished being created, while fgdb = mygis.content.get(itemDes['exportItemId']) instead creates a new variable and exports it regardless of whether the FGDB for itemDes has been fully created.
Hope this helps,