Erik Šťastný
Erik Šťastný

Reputation: 1486

Pyqt - Can not get any output from QProcess

I have read a lot of similiar problems on SO and also anywhere on internet but i could not find solution for this.

i have the following command which i want to run:

c:\\lscc\\Programmer\\3.8_x64\\bin\\nt64\\pgrcmd.exe -infile test.xcf

From CMD window i have standard output like this:

Lattice Programmer Diamond (64-bit) 3.8.0.115.3 Command Line Argument check - OK Loading Programmer Device Database... Done. Writing log file to /programmer.log Opening XCF file... Done. Programming XCF Contents... Connected to Lattice Cable Server. Failed.

I want to run it in my app via QProcess but i cant not find the way how to get same output. I have following code, the command is performed and i cant get any output:

process = QProcess()
process.setProcessChannelMode(QProcess.MergedChannels)
process.start("c:\\lscc\\Programmer\\3.8_x64\\bin\\nt64\\pgrcmd.exe -infile test.xcf")
process.waitForFinished()

> process.readAllStandardError() = b" # empty
> process.readAllStandardOutput() = b" # empty
> process.exitCode() = -9

Only thing where is something usefeull is in errorString:

> process.errorString() = "Unknown error"

Upvotes: 0

Views: 226

Answers (1)

eyllanesc
eyllanesc

Reputation: 243887

You are using the following method:

void QProcess::start(const QString &program, const QStringList &arguments, QIODevice::OpenMode mode = ReadWrite)

and clearly QProcess needs to differentiate between both so you must separate it:

process.start("c:\\lscc\\Programmer\\3.8_x64\\bin\\nt64\\pgrcmd.exe", ["-infile" "test.xcf"])

Upvotes: 1

Related Questions