Runs on desktop, errors on server

590
6
12-18-2023 12:52 PM
Chris_Kell
New Contributor III

Pro Version 3.1.1

ArcGIS Server 11.1

Using propy.bat the following code runs on my desktop without a hitch.  When trying to run on Server it errors out with attached error.

For the life of me I can't figure why.  Any insights would be appreciated!

 

 

 

# Imports
import os
import arcpy
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
from arcgis.features import FeatureLayerCollection
from datetime import datetime

# Define paths and files
unc_path = r'\\abc.local\AdminData\GIS'
root_path = os.path.join(unc_path, 'gis')
data_path = os.path.join(root_path, 'Database')
#project_path = os.path.join(root_path, "Projects", "Overnight", "overnight.aprx")
project_path = os.path.join(root_path, "Projects", "Overnight", "overnightDEV.aprx")
sdfile_path = os.path.join(root_path, "sdFiles")

db99_sde = os.path.join(data_path,"db99.sde")
gis_test = os.path.join(data_path,"gisTest.gdb")
workspace = os.path.join(data_path, 'Workspace.gdb')
behaviorNoOSS = os.path.join(campus_sde, "dbo.NoOss")
behaviorNoInc = os.path.join(campus_sde, "dbo.NoInc")

# other setup
arcpy.env.overwriteOutput = True
gis = GIS("https://servername.abc.local/portal", username="admin", password="adminPassword")
wksp = arcpy.EnvManager(scratchWorkspace=workspace, workspace=workspace)
shrOrg = True
shrEveryone = False
shrGroups = ""

# Process: Make Query Layer (Make Query Layer) (management)
student_temp = arcpy.management.MakeQueryLayer(input_database=db99_sde, out_layer_name="out_layer", query="select * from table", oid_fields=["id_number"])

Tags (1)
0 Kudos
6 Replies
DonMorrison1
Occasional Contributor III

I would try to dump out the value of 'db99_sde' to see what it is really set to.  Are you publishing this code as a geoprocessing tool, or just copying it to the server?  If you are doing a publish then that process (consolidation) can can alter source code statements that contain file paths (eg. unc_path = r'\\abc.local\AdminData\GIS')

0 Kudos
Chris_Kell
New Contributor III
Hi Don,
I'm a newbie with python, and I'm not sure what you mean "dump out the value of 'db99_sde," I am attempting to schedule this as a windows task on Server 2019. The code works from the ArcGIS Python command prompt on desktop, and from inside a project, but dies with the shown error on the server.
The error occurs on a arcpy.management.MakeQueryLayer. My thinking is there is an issue with the unc path. Our network team has me signing-on the server as myself, but running the job as a domain user.
0 Kudos
DonMorrison1
Occasional Contributor III

Hi Chris. I would add "print" message after every relevant line to make sure your assignments are resulting in the strings that you expect.  I've never used propy.bat but I assume it is something you run from the DOS command line, so those print statement should show up in the DOS window. If the path looks correct then you coud try to do a DOS "dir <path>" so see if the server can access it.

db99_sde = os.path.join(data_path,"db99.sde")
print ("db99_sde: " + db99_sde)

 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You will likely get more responses if you take the time to type out the errors and traceback instead of using a screenshot.

0 Kudos
RhettZufelt
MVP Frequent Contributor

Is the server separate from your desktop?  If so, do yo have Pro (and thus python 3.x) installed on the server computer as well?

R_

0 Kudos
Chris_Kell
New Contributor III
Desktop and server on different machines. Pro 3.1.1 on desktop only

0 Kudos