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

Method runCommand

Src/Unix/DesktopShortcuts.cpp:464–494  ·  view source on GitHub ↗

通用工具方法

Source from the content-addressed store, hash-verified

462
463// 通用工具方法
464bool CDesktopShortcutManager::runCommand(const QString &program, const QStringList &args, int timeout)
465{
466 QProcess process;
467 process.setProgram(program);
468 if(!args.isEmpty())
469 process.setArguments(args);
470
471 //qDebug(log) << "Command:" << program << args;
472
473 process.start();
474
475 if (!process.waitForFinished(timeout)) {
476 qWarning(log) << "Command timeout:" << program << args;
477 return false;
478 }
479
480 if (process.exitCode() != 0) {
481 QString errorOutput = process.readAllStandardError();
482 qWarning(log) << "Command failed:" << program << args
483 << "exit code:" << process.exitCode()
484 << "failed:" << errorOutput;
485 return false;
486 }
487
488 QString standardOutput = process.readAllStandardOutput();
489 if (!standardOutput.isEmpty()) {
490 qDebug(log) << "Command output:" << standardOutput.trimmed();
491 }
492
493 return true;
494}
495
496QString CDesktopShortcutManager::getCommandOutput(const QString &program, const QStringList &args)
497{

Callers

nothing calls this directly

Calls 2

startMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected