Download of a file geodatabase failing when using a script and query

461
2
03-03-2022 03:31 AM
BrianShaw
New Contributor II

Hi everyone,

     I'm trying to download a file geodatabase using a script. The script is taken from the ESRI documentation with minimal changes, basically I'm querying for the required feature layer appending date and time and exporting as a FGDB. The script works as expected by creating the FGDB on AGOL, but when I try and download the FGDB the script fails and fails to export to my local file plan, I can't figure out what is stopping the download, my code is a follows

 

from arcgis.gis import GIS
import datetime as dt
username = "CSV_GIS_Defects"
gis = GIS('url','username','password', verify_cert=False, proxy_host='proxy', proxy_port=port)
folder_path=r'D:\ArcGisExportData\GeoDatabase'
items = gis.content.search(query="title:CSV_GIS_Defects", item_type="Feature Layer", sort_field='modifed', sort_order='desc')
print(str(len(items)) + " items will be backed up to " + folder_path +". See the list below:")
items

def download_as_fgdb(item_list, backup_location):
    for item in item_list:

        try:
            if 'View Service' in item.typeKeywords:
            print(item.title + " is view, not downloading")
       else:
            print("Downloading " + item.title)
            version = dt.datetime.now().strftime("%d_%b_%Y")
            print(version)
            result = item.export(item.title, "File Geodatabase")
            print(result)
            result.download(backup_location)
            result.delete()
            print("Successfully downloaded " + item.title)
    except:
        print("An error occurred downloading " + item.title)
        print("The function has completed")

download_as_fgdb(items, folder_path)

The errors I receive in Jupyter 

1 items will be backed up to D:\ArcGisExportData\GeoDatabase. See the list below:
Downloading CSV_GIS_Defects
03_Mar_2022
<Item title:"CSV_GIS_Defects" type:File Geodatabase owner:shaw_b>
An error occurred downloading CSV_GIS_Defects
The function has completed

any help would be greatfully appreciated

 

 

0 Kudos
2 Replies
HuubZwart
Occasional Contributor

Catching the actual error and displaying that might help you find out what's going wrong (or just remove the try/except statements for testing). Possibly, specifying the file name as well in the download parameters might help here?

0 Kudos
BrianShaw
New Contributor II

Hi HuubZwart

    Thanks for the response, I removed the try/except block and the error was exposed. I should have thought of it so thanks for the pointer. The error is coming back as an Https proxy timeout, I supply the proxy settings in my connection parameters, they work fine for other scripts my error is 

'Tunnel connection failed: 407 Proxy Authentication Required'
0 Kudos