I have a python toolbox that is extracting layers from a feature service. The tools to extract shapefiles and file geodatabases work fine since it's mostly running the out of the box tools. However, I have a workflow that requires DGNs to be extracted while using a Seed and Cell file for custom line styles and point symbols. In order to do that, I have a Spatial ETL tool created in Data Interoperability. The Spatial ETL works fine when I run it via Model Builder.
My issue is I'm trying to import the .atbx toolbox into my python toolbox so I can run either the Model I created or the Spatial ETL directly.
I'm using:
arcpy.ImportToolbox(toolboxPath, "DataExtraction")
When working through the tool, it appears the tool is getting imported correctly. However, when I try and run the Model or Spatial ETL tool by calling them with this:
I get a really really odd error:
File "\\serverName\gisdata\DataExtraction\ExtractCADData.atbx", line 62, in GISToCADwPortal
Ø- dû×ÀÚÒý˜"rñ(úÄMÔ%
^^^^
I'm not sure where to find line 62 because it's not referring to line 62 within the Python toolbox.
Any help anyone can provide would be greatly appreciated!
Thank you,
Matt
This is definitely an encoding error, have you inspected the variables you're passing to the function? It could also be toolbox encryption breaking the syntax.
What is the best way to inspect the variables?
I've added some arcpy.AddMessages to verify the tool is getting recognized and using arcpy.GetParameterInfo to verify the name and datatype of the parameters for the tool.
The variables I'm attempting to pass into the parameters all have the same data type.
Should the ImportToolbox statement be outside or inside of the Execute method?
I just wanted to make sure you weren't passing a file descriptor or raw bytes as one of the arguments there.
Did you check to see if the imported toolbox is encrypted? You can encrypt atbx files with a password (they're secretly just zip directories with some XML files and python scripts in them, so it's using regular zip file encryption techniques).
If the target file is encrypted, the loader might still be able to find the filepath in the encrypted directory, but when it loads the file and looks for that symbol it's going to get nonsense.
That error your getting is coming from that file in the atbx. You can unzip it, find that python file, and check like 62 as well.
Additionally, you can log out (using AddMessage) the value of each parameter to make sure that you didn't pass the wrong type to the parameter object. As far as I know there's nothing stopping you from feeding anything you want to the argument of a parameter in Python since that validation occurs during the updateParameters/updateMessages stage which is called by the geoprocessing interface.
My apologies, I meant to add the toolbox is not encrypted in my last reply.
I'm going to unzip the toolbox and see if I notice anything that might tell me what might be causing the line 62 error. I learned something new today with the unzipping of the toolbox. I'll report back with my findings.
Thank you!
I didn't see anything at line 62 that really stood out. I'll keep digging and see if I can get this figured out. If you have any other suggestions, I'd love to hear them.
Would you mind sharing the toolbox? I could definitely help if I had some more context.
Might also be beneficial to log some things out so you can find out exactly which function is failing.
Let me see if I can get it "cleaned" up, so I don't have sensitive information in there.
HaydenWelch,
I sent you a DM with more information on the project. Again, I appreciate any help you can provide.
Thanks,
Matt