0

I am building a QGIS plugin with Python (3.7) that is supposed to run a shell command.

This command launches an FME Script with some parameters

os.system("fme D:\script.fmw --param1 D:\file.txt --param2 value")

When i run this command on my python plugin main script, there is no effect.

But when i run the same command in a shell, it works. When i run it from a regular python script, it works too.

I also tried using subprocess module to get more information on my result. It raises a compilation error with code 1.

swiss_knight
11.3k9 gold badges57 silver badges140 bronze badges
asked Oct 1, 2020 at 13:50

2 Answers 2

1

I'm not really up on Python, but I see you're not including the full path to the FME executable. Could that be the issue? i.e. it can't find FME

It's also good practice to do if you have multiple FME versions installed (I know a lot of users who do that) because depending on the PATH the wrong version might get run.

answered Oct 1, 2020 at 14:29
1

I had the same issue and I finally solved it.

Try to check the current path localisation on the QGIS Python Console with

os.getcwd()

Mine was systeme32, so no wonder why it won't let me do system commands. I changed it with:

os.chdir(mypath)

and then everything worked.

Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
answered Jul 21, 2021 at 14:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.