A common coding pattern used in AML was to run an AML (with parameters) inside another AML.
An application that I'm currently developing would benefit from being able to run a Python script (with parameters) within another Python script.
However, this does not seem to be at all straightforward.
Using ArcGIS 10, I'm experimenting with wrapping the "inner" Python script into an ArcGIS tool that has the parameters. I thought it would be a simple matter to have the "outer" Python script use arcpy.ImportToolbox to import the toolbox and then run the tool(s) within it. However, in testing so far all my attempts to run the "inner" tool from the "outer" script appear to simply skip the "inner" tool (no error is thrown).
Here is some test code to try and illustrate better what I am trying to describe.
My testinner.py script is:
inputString = arcpy.GetParameterAsText(0)
newFC = "C:\\Temp\\test.gdb\\" + inputString
arcpy.Copy_management("C:\\Temp\\test.gdb\\test",newFC)
My testouter.py script is:
import arcpy
inputString1 = arcpy.GetParameterAsText(0)
inputString2 = arcpy.GetParameterAsText(1)
arcpy.ImportToolbox("C:\\Temp\\test.tbx")
arcpy.testinner_test(inputString1)
arcpy.testinner_test(inputString2)
For testinner.py its tool needs a single String parameter.
For testouter.py its tool needs two String parameters
The two tools are placed in a test.tbx.
The test.gdb just needs a single empty feature class called test.
Once you have the above assembled, running the testinner tool with a string like 'abc' passed in as its parameter should result in feature class 'test' being copied to one called 'abc' OK.
But when you try running the testouter tool with two strings like 'uvw' and 'xyz' as its parameters, the testinner tool within testouter.py seems to run OK once, but sends ArcMap 10 SP2 on Vista SP2 to a Serious Application Error when trying to use it the second time.
The same test using Windows XP SP3 and ArcGIS Desktop 10 SP2 also produces a Serious Application Error at the same point.