Select to view content in your preferred language

How to get the job status of gis.item.export or make it execute synchronously?

1525
3
Jump to solution
07-23-2020 02:55 PM
DrewDowling
Frequent Contributor

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 wait=True.

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[0].filename.split("/")[0]),"DamageReports.gdb")      
   return
0 Kudos
1 Solution

Accepted Solutions
Arne_Gelfert
Frequent Contributor

Looks to me like the default for "wait' is True, so you really shouldn't need it. Documentation says it's a Boolean, so I'd drop the quotes around True.

item.export (..., wait = True, ...)

View solution in original post

3 Replies
Arne_Gelfert
Frequent Contributor

Looks to me like the default for "wait' is True, so you really shouldn't need it. Documentation says it's a Boolean, so I'd drop the quotes around True.

item.export (..., wait = True, ...)
DrewDowling
Frequent Contributor

DOH

You are exactly right. Thank you.

0 Kudos
Arne_Gelfert
Frequent Contributor

Glad it worked - happy Friday, Drew !!!

0 Kudos