Script IOError, toolkit not found - im stumped!

4021
4
Jump to solution
03-05-2015 02:00 PM
BenVan_Kesteren1
Occasional Contributor III

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.

2015-03-06_08-48-05_2015-03-06_08-33-55_Inbox - Microsoft Outlook.jpg - IrfanView (Zoom 1900 x 960).jpg

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:

2015-03-06_08-38-08_ArcCatalog - CUsersbenvaAppDataRoamingESRIDesktop10.3ArcCatalogGISADMIN.jpg

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) != 1):
                print "'service' not in the format of zero and ones: %s" % (service)
                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[1] + ". Modifying this Service"
                arcpy.StopStartService_ToolboxServerAdminToolkit(Server_Name, Port, Admin_User, Admin_Password, stopORstart, Service_List[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?

0 Kudos
1 Solution

Accepted Solutions
BenVan_Kesteren1
Occasional Contributor III

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

View solution in original post

4 Replies
BenVan_Kesteren1
Occasional Contributor III

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
0 Kudos
BenVan_Kesteren1
Occasional Contributor III

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

JoshuaBixby
MVP Esteemed Contributor

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?

0 Kudos
BenVan_Kesteren1
Occasional Contributor III

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).

0 Kudos