AnsweredAssumed Answered

Error 000732 - Standalone python script to regenerate cache tiles

Question asked by jamie.leitch@welland.ca on Nov 15, 2019

I have a standalone python script that runs on our ArcGIS 10.7.1 server nightly to regenerate a tile cache.  The script runs fine when I use an admin server connection file, but when I switch to a publisher connection I am getting the error 000732:

 

Input Service: Dataset <path to server connection file>\<service name>.Mapserver does not exist or is not supported
Failed to execute (ManageMapServerCacheTiles).

 

However, the dataset does exist at the path specified on the server.  The publisher connection file uses a user that is a publisher on the server.  Connection file was created in ArcMap.  When I regenerate the tiles in ArcMap using the same publisher connection all works fine.

Here is the script:

import arcpy
from arcpy import env
import os, sys, time, datetime, traceback, string

# Set environment settings
env.workspace = "C:/data"

# List of input variables for map service properties
connectionPath = r"<drive letter>:\Scripts\ManageMapServerCacheTiles"
server = "<publisher connection file name>.ags"
serviceName = r"<service name>.MapServer"
database = "<sde connection file>.sde"
featureClass = "<feature class name>"
inputService = connectionPath + "\\" + server + "\\" + serviceName

scales = [<list of scales>]
numOfCachingServiceInstances = 3
updateMode = "RECREATE_ALL_TILES"
areaOfInterest = ""
waitForJobCompletion = "DO_NOT_WAIT"
updateExtents = connectionPath + "\\" + database + "\\" + featureClass

currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
file = connectionPath + "\\report_%s_<cache name>.txt" % arg1

# print results of the script to a report
report = open(file,'w')

try:
    starttime = time.clock()
    result = arcpy.ManageMapServerCacheTiles_server(inputService, scales,
                                                    updateMode,
                                                    numOfCachingServiceInstances,
                                                    areaOfInterest, updateExtents,
                                                    waitForJobCompletion)
    finishtime = time.clock()
    elapsedtime= finishtime - starttime

    #print messages to a file
    while result.status < 4:
        time.sleep(0.2)
    resultValue = result.getMessages()
    report.write ("completed " + str(resultValue))

    print "Created cache tiles for given schema successfully for " +\
    serviceName + " in " + str(elapsedtime) + " sec on " + arg2
   
except Exception, e:
    # If an error occurred, print line number and error message
    tb = sys.exc_info()[2]
    report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno)
    report.write(e.message)
report.close()
   
print "Created Map server Cache Tiles "

The error occurs on line 36.

 

What would be the reason that the script will run with an admin connection but not a publisher connection, and using the same publisher connection in Desktop I can regenerate all tiles?

Thanks

Outcomes