MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / RunCommand

Method RunCommand

Src/Hook.cpp:177–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177bool CHook::RunCommand(const QString &program, const QStringList &args, int timeout)
178{
179 QProcess process;
180 process.setProgram(program);
181 if(!args.isEmpty())
182 process.setArguments(args);
183
184 //qDebug(log) << "Command:" << program << args;
185
186 process.start();
187
188 if (!process.waitForFinished(timeout)) {
189 qWarning(log) << "Command timeout:" << program << args;
190 return false;
191 }
192
193 if (process.exitCode() != 0) {
194 QString errorOutput = process.readAllStandardError();
195 qWarning(log) << "Command failed:" << program << args
196 << "exit code:" << process.exitCode()
197 << "failed:" << errorOutput;
198 return false;
199 }
200
201 QString standardOutput = process.readAllStandardOutput();
202 if (!standardOutput.isEmpty()) {
203 qDebug(log) << "Command output:" << standardOutput.trimmed();
204 }
205
206 return true;
207}

Callers

nothing calls this directly

Calls 2

startMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected