AnsweredAssumed Answered

Why does item status return "Item status doesn't exist?"

Question asked by deleted-user-Qrnw90viByMg on Nov 16, 2018
Latest reply on Dec 4, 2018 by deleted-user-Qrnw90viByMg

I want to download a series of file geodatabases from ArcGIS Online after they've successfully exported from their respective feature classes.  I want to start all of the exports at the same time, let them all run simultaneously, then download them.  


In order to do that, I've put together the following script. The problem is, though, I can't get a status on some of the geodatabases. 

Here's the script: 

from arcgis.gis import GIS,Item,User 
from datetime import datetime as dt
import os,smtplib 

#Define Function to Send Email
def sendError(message):
     print("\tSending results in email.")
     fromaddr = ''
     toaddrs = ''
     username = ''
     password = '1234abcd'
     server = smtplib.SMTP('')
     print ("\tMail Sent!")
     #Set login information for AGO
     username = "user_name"
     password = "pass_word"
     #Set GIS environment

     #Assign User as 'user_name' to gain work with citizen reporter's content
     user = User(gis,'user_name',None)
     #Set datestamp variable
     datestamp ="%Y%m%d")

     #Assign path for backup folder; create it if it doesn't exist
     backup_folder = 'AGO_backup_' + datestamp
     backup_folder_path = os.path.join(r'AGO_backups',backup_folder)
     if not os.path.exists(backup_folder_path):
      #Assemble list of folders for citizen_reporter user
     folder_list = user.folders
     #Create list for database items
     db_list = []
     itemID_list = []
     counter = 0
     #Go to 'Report Layers' folder, then export and download all items
     for folder in folder_list:
         if folder['title'] == 'Feature Layers':
             item_list = user.items(folder)
             for item in item_list:
                 item_name = str(item['title']) + '_' + datestamp
                 if item['type'] == 'Feature Service':
                     print('exporting %s' % item_name)
                     item.export(item_name,'File Geodatabase', None, True)
                     counter += 1
     #Download the geodatabases that were just exported
     print(db_list)     while len(itemID_list) < counter:
         for db in db_list:
             gdb = = db)
             print('%s: %s' % (db,gdb[0].status()['statusMessage']))
             if gdb[0].status()['statusMessage'] == 'completed':
                 if gdb[0].status()['itemId'] not in itemID_list:
                     print('%s %s added to list' % (db,gdb[0].status()['itemId']))
     for itemID in itemID_list:
         itemObject = gis.content.get(itemID)
         itemObject.delete()  except Exception:
     e = sys.exc_info()[1]
     body = "Backup of AGO data failed. \nError: " + str(e)
     message = 'Subject: %s\n\n%s' % ("AGO failed...", body)
### END SCRIPT ###

Here is an example of the messages I get:


Any thoughts or comments on this would be much appreciated. Thanks!