arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

Publishing an SD file containing a geoprocessing service fails in a disconnected environment

Open sverkerEsriSE opened this issue 1 year ago • 2 comments

Describe the bug We have created a custom print service. When using the ArcGIS Python API 2.1 to publish this to an ArcGIS Server in a disconnect / offline environment, we first get a warning: Using Connection object over GIS object

then directly the error: A connection error has occured: HTTPSConnectionPool(host='www.arcgis.com', port=443): Max retries exceeded with url: /sharing/rest/portals/self (Caused by NewConnectionError)

The problem is the new GIS-object being created in arcgis/geoprocessing/_support.py on line 378 to 384, where the Python API creates a new GIS object with no URL specified, which means it will try to reach out to www.arcgis.com per default.

To Reproduce Steps to reproduce the behavior: Create an SD-file for a print service (probably other GP Services will fail as well)

from arcgis.gis import GIS
gis = GIS("https://myportal.com/portal", "user", "pass")

sd_file = r"C:\temp\prinservice.sd"
# Get the first federated server
target_server = gis.admin.servers.list()[0]

target_server.publish_sd(sd_file)

error:

A connection error has occured: HTTPSConnectionPool(host='www.arcgis.com', port=443): Max retries exceeded with url: /sharing/rest/portals/self (Caused by NewConnectionError)

Screenshots If applicable, add screenshots to help explain your problem.

Expected behavior A clear and concise description of what you expected to happen.

Platform (please complete the following information):

  • OS: Windows Server 2022
  • Python API Version 2.1

Additional context The problem is the new GIS-object being created in arcgis/geoprocessing/_support.py on line 378 to 384, where the Python API creates a new GIS object with no URL specified, which means it will try to reach out to www.arcgis.com per default.

Problematic code, which can be worked around by commenting out the following (might cause other stuff to break?):

    if isinstance(gis, Connection):
        log = logging.getLogger()
        log.warning("Using Connection object over GIS object")
        ngis = GIS(set_active=False)
        ngis._con = gis
        gis = ngis

sverkerEsriSE avatar Sep 13 '23 13:09 sverkerEsriSE

@sverkerEsriSE I'll take a look. Thank you

achapkowski avatar Sep 18 '23 10:09 achapkowski

Any progress so far on this issue? It's nearly a year ago and the problem still exists ...

dstrigl avatar Jul 24 '24 13:07 dstrigl