2

I need to call an external programme from python plugin in qgis, I didn't use os.systeme because I want to hide the launched programme with 'startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW'.

import subprocess
import os
startupinfo = None
if os.name == 'nt':
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
subprocess.Popen("TeighaFileConverter",shell=True, stdin=None, stdout=PIPE, stderr=PIPE,startupinfo=startupinfo)

it's workin on pyzo but not working in QGIS editor.
this code is working on linux but not on windows :/

2

you could also try subprocess.call

subprocess.call(["TeighaFileConverter"])

and make sure that you have the path to your TeighaFileConverter installation in you path variable

EDIT:

I tested the code above again in the python console in qgis and it didn't work, sorry for posting a wrong code, you have to mention the whole path in order to call it

subprocess.call(['C:/Program Files (x86)/ODA/Teigha File Converter 4.3.2/TeighaFileConverter.exe'])
  • thanks for ur comment, subprocess.call(["TeighaFileConverter"]) it's not working i've changed it to subprocess.call(["TeighaFileConverter"],shell=True) in output i get '1' – Anass Ayar Jul 23 '18 at 15:25
  • @AnassAyar Did you also add Teigha to your path variable ? – Hicham Zouarhi Jul 23 '18 at 15:26
  • yes and I've tested running the code in pyzo and it's working – Anass Ayar Jul 23 '18 at 15:32
  • @AnassAyar I've edited my answer with a working code – Hicham Zouarhi Jul 23 '18 at 15:46
  • now it's working thanks ! is it possible to avoid the full path to the programme ? – Anass Ayar Jul 23 '18 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.