cancel
Showing results for 
Search instead for 
Did you mean: 

Linux CubeMX python is not working as pre/post code generation script

nobody
Associate II

What I have to do that I can directly call some python scripts as pre/post code generation step with CubeMX 6.14.1 under Linux?

Currently I can execute directly the python script on a Windows Machine, but on the Linux machine nothing happens. On Linux I can execute the scripts directly from command line without CubeMX and I can execute the scripts over a bash script which is calling the python script.

  • Do I need to configure anything additional?
  • Is there a possibility to select which python version is used?
  • Any other hint where my problem could be?

printscreen_UserAction_prePostCodeGeneration.png

Thanks in advance
nobody

 

16 REPLIES 16
Pavel A.
Super User

Relative path can be wrong. Try: python -c "import os; os.getcwd()"  to see if python works at all and where you are.

 

 

nobody
Associate II

It looks like that it is only possible to call an existing script file. It's not possible to execute directly some command. If I understood you right, that was your suggestion.

nobody_0-1747110676017.png

nobody_1-1747110708781.png

 

 

I think it's not a "terminal window" tab. I think it's only a "file selection" tab.

If I understood you right, you also suggested to directly execute that. Unfortunately it looks that only a file selection is possible.

nobody_0-1747111035859.png

 

As mentioned, I am no Cube user.

Have you tried something like this : https://stackoverflow.com/questions/44220993/how-to-run-system-shell-terminal-inside-eclipse

 

Like other build system, Eclipse use a set of "private" environment variables, like "PROJECT_DIR" or "PROJECT_ROOT". Most internal and external tools and the objects they process are referenced that way, to be easily interchangeable between different machines/developers.

I've tried also to select an existing file, such as (in Windows) c:\tmp\junk.bat  - with same result: "the specified path is invalid". 

Only if the script file is in the same directory with the .ioc , and specified *with NO path* at all  (just junk.bat) - it works.

For me, both .bat and .py files run on Windows.

In Linux, either mark the file executable or wrap in a script.

 

 

 

well, 

KnarfB_0-1747209060554.png

works for me, e.g. with the content 'code' it will start VS code.

Some computer mysteries may remain unsolved forever.

KnarfB