Mr. BUGRA UGUR YAZICI 0 Report post Posted February 4, 2018 Hi, I would like to know whether it is possible to execute python script directly within a feature definition.I don't want to use software connector option because python script should be executed in an if-else statement. If the condition doesn't meet the requirements, python script will not be executed. Thank you very much in advance. Share this post Link to post Share on other sites
Jörg 29 Report post Posted February 5, 2018 Hi, Yes, you can use a FProcess to run anything from within a feature definition, here is an example snippet: string exe(resolveEnv("$BINDIR") + "../../myScript") string os(resolveEnv("$OS")) if (os.contains("Windows")) exe.append(".exe") endif process myTool(exe) myTool.setWorkingDir(getDesignDir()) myTool.setArguments(["-i", getDesignDir()+"/control.dat", "-o", "log.out"]) myTool.run() Hope this helps,Joerg Share this post Link to post Share on other sites
Mr. BUGRA UGUR YAZICI 0 Report post Posted February 5, 2018 Dear Joerg, Thank you very much for your answer.Just to speed up the process for newbies like me : string exe("c:/Python27/python") string os(resolveEnv("$OS")) if (os.contains("Windows")) exe.append(".exe") endif process myTool(exe) myTool.setArguments(["<pathofpythonscript>", "arg1"]) myTool.run() Share this post Link to post Share on other sites
Mr. BUGRA UGUR YAZICI 0 Report post Posted February 5, 2018 Hi again, I realized something about FProcess issue. When I pass arguments in the feature definition, output file has no newlines and args aren't written on the file. The output file that is created within the FProcess and passing arguments as it is written with the above instructions: VCB :8.4946106VCB :8.8417073VCB :9.2119383VCB :8.4946106 The output file that is created with same arguments within a .bat file: VCB :8.4946106 VCB :8.8417073 VCB :9.2119383 VCB :8.4946106 ['C:\\Users\\bugur\\Desktop\\CAESES_Thesis\\Msc_Thesis_Setup\\GM_table.py', 'deneme'] Revised feature: //string exe("c:/Python27/python") //string os(resolveEnv("$OS")) //if (os.contains("Windows")) //exe.append(".exe") //endif //process myTool(exe) //myTool.setArguments(["C:\Users\bugur\Desktop\CAESES_Thesis\Msc_Thesis_Setup\GM_table.py", "deneme"]) //myTool.run() string exe("../../pit.bat") process myTool(exe) myTool.run() Inside .bat file : c:\python27\python.exe C:\Users\bugur\Desktop\CAESES_Thesis\Msc_Thesis_Setup\GM_table.py deneme %* I just wonder why there is a difference between executing .bat file and .py file in the feature definition.Thank you very much for your time and understanding. Share this post Link to post Share on other sites
Jörg 29 Report post Posted February 6, 2018 I am not sure what happens here. There should not be a difference from a technical point of view in CAESES. Does it work now for you with this workaround? Share this post Link to post Share on other sites
Mr. BUGRA UGUR YAZICI 0 Report post Posted February 7, 2018 It works very well for me with the .bat workaround. :) Vielen Dank! Share this post Link to post Share on other sites
Jörg 29 Report post Posted February 7, 2018 Perfect! Good luck with your work! Share this post Link to post Share on other sites