I'm trying to run a Python script from C# using the Process class. Preferably, the script would contain one or more classes, each with def's. Even without that, I would need to pass both the name of the script and a version name argument.
The closest code I can find to accomplish the latter of these possibilities is:
string pyscript = "../../ChangeVersion.py";
ProcessStartInfo sInfo = new ProcessStartInfo(@"C:\\Python26\\ArcGIS10.0\\python.exe");
string x = "pyscript.ToString() childVersion.VersionName";
sInfo.Arguments = x;
Process proc = new Process();
proc.StartInfo = sInfo;
The Python script will further process childVersion.VersionName.
Now this won't work because both pyscript.ToString() and childVersion.VersionName are already strings.
More broadly, Im not clear how the compiler would sort out the arguments beyond the script name. For example, suppose that my arguments statement was:
string x = "pyscript.ToString() myClass myDef childVersion.VersionName";
how would the program know that myClass is a class name and myDef is a method name?
Finally, what's the best way to account for gaps (e.g., "C:\\Program Files") when passing arguments?
I'm using .Net 2008 on a Windows XP SP3 OS. The Python version is 2.6.