I'm using the ArcGIS API for Python to export a feature service to a FGDB and then download it. My problem is that the export function appears to be asynchronous even though I set
The returned item from
gis.item.export() has a jobid so this shouldn't be a problem if I could poll the service for job status but I don't see a URL to do this.
Without a synchronous export or a job status I am user
time.sleep(60) to slow things down but that not exactly ideal
So how do I get my export to execute synchronously, or how do I query the job status?
def Get_AGOL_Data_All2(itemID): """ PARAMETERS: itemID (str) = Ther Portal itemID of the feature service to download. RETURNS: None FUNCTION: Uses the arcgis api for python library to connect to Portal and copy a feature service to a FGDB. Portal returns a zipped file which then has to be unzipped and the contents moved to the staging location NOTE: """ print ('Starting Get_AGOL_Data_All()') # #anon_gis = GIS() mygis = GIS(username="userid",password="****") service = mygis.content.get(itemID) itemDesc = service.export(title="DamageReports", export_format= 'File Geodatabase', parameters=None, wait='True') time.sleep(60) fgdb = mygis.content.get(itemDesc['exportItemId']) fgdb.download(r"D:\temp") with zipfile.ZipFile(os.path.join( r"D:\temp" , fgdb.name),'r') as zip_tar: zip_tar.extractall(r"D:\temp") print ('Finished Get_AGOL_Data_All()') arcpy.Rename_management(os.path.join(r"D:\temp", zip_tar.filelist.filename.split("/")),"DamageReports.gdb") return
Solved! Go to Solution.