Hi All,
I have a py script that calls a function from another py script, and I am getting the below error:
IOError: The toolbox file C:\Users\benva\AppData\Roaming\Esri\Desktop10.3\ArcCatalog\GISADMIN@SDE_Spatial@Smithy.sde\SDE_SPATIAL.GISADMIN.ToolboxServerAdminToolkit was not found.
I am unsure why the below sequence is occurring, I am completely stuck and unsure how to resolve.
I have double and even triple checked this directory, and the toolkit most definitely resides in this location, please see evidence of this in the below screen grab:
Here is the code of the function throwing the error: - specifically line 4, arcpy.ImportToolbox()
def stopStart(stopORstart,service): # set service to be '11111' to stop them all. import arcpy # Load required toolboxes arcpy.ImportToolbox(r"Database Connections\GISADMIN@SDE_Spatial@Smithy.sde\SDE_SPATIAL.GISADMIN.ToolboxServerAdminToolkit") # List of services to stop/start Service_List = [["Weave_Main.MapServer",1], ["Weave_Alternate.MapServer",1], ["Weave_Inset.MapServer",1], ["Weave_External.MapServer",1], ["Weave_WSData_Sheets.MapServer",1]] # Local variables: Server_Name = "gisserver" Port = "6080" Admin_User = "gisadmin" Admin_Password = error = False if len(service) == len(Service_List): # this loop is for checking of the input 'service' It needs to conform to the format of 5 digits (zeros or ones) to run correctly for x in xrange(0,len(service)): if (int(service) != 0) and (int(service print "'service' not in the format of zero and ones: %s" % (service) != 1): ) error = True else: print "'service' all good, either a zero or one: %s" % (service) error = False else: error = True print "Error in 'service' length: %s\nShould be == : %s" % (len(service),len(Service_List)) if error == False: # error checking, this wont run unless the above test completes if stopORstart.title() == "Stop": print "\nStopping Weave Services...\n" elif stopORstart.title() == "Start": print "\nStarting Weave Services...\n" else: print "\nNeeded 'Stop' or 'Start' passed through, instead this was received: " + stopORstart + "\n" return for x in xrange(0,len(service)): # this code manipulates the Service_List to be either zero (dont run) or one (run) Service_List[1] = service for x in xrange(0,len(service)): # this starts or stops the appropriate services, as defined by the services string if int(Service_List[1]) == 1: print Service_List[0] + " is set to " + Service_List arcpy.StopStartService_ToolboxServerAdminToolkit(Server_Name, Port, Admin_User, Admin_Password, stopORstart, Service_List[1] + ". Modifying this Service" [0]) else:pass print "\n---------------------------------------\nWeave Services Manipulated Successfully\n---------------------------------------\n" else: print "'error' == False\nlook at the WeaveModule.py script for errors" return
Anyone know why the ImportToolbox is not working?
Solved! Go to Solution.
A solution has been found, we had to set the workspace in both the original script and the second script to be identical, now it seems to work fine.
Cheers
Just to add something else I have tried... I have pulled out just this piece of code to test it works as standalone, and it works fine.
# Import arcpy module import arcpy # Load required toolboxes ##arcpy.ImportToolbox("C:/Users/benva/AppData/Roaming/ESRI/Desktop10.3/ArcCatalog/GISADMIN@SDE_Spatial@Smithy.sde/SDE_SPATIAL.GISADMIN.ToolboxServerAdminToolkit") arcpy.ImportToolbox(r"Database Connections\GISADMIN@SDE_Spatial@Smithy.sde\SDE_SPATIAL.GISADMIN.ToolboxServerAdminToolkit") # Process: Stop, Start, Delete Services arcpy.StopStartService_ToolboxServerAdminToolkit("gisserver", "6080", "gisadmin", PASSWORD, "Start", "Weave_WSData_Sheets.MapServer") print 'done'
This is the original line that calls this second script required to stop/start the services....
WeaveModules.stopStart('Stop','00001') # stops CAD mapping services back up |
A solution has been found, we had to set the workspace in both the original script and the second script to be identical, now it seems to work fine.
Cheers
Do you have 64-bit Background Geoprocessing installed?
Whether 64-bit Background Geoprocessing is installed, does enabling or disabling "Background Processing" in the geoprocessing options change anything?
Hi Joshua,
No I do not have it installed as it was causing problems with our geoprocessing.
As i'm not 100% familiar on how the 64-bit geo works, wouldn't this be irrelevant in this instance as the script would be processed on our gisserver? Or would this be running on my local PC? (that could be a very in depth answer, if so please disregard as its purely asked out of curiosity).