MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / exec

Method exec

app/src/API/Handlers/SystemHandler.cpp:61–88  ·  view source on GitHub ↗

* @brief Spawns a helper process (e.g. a Python script) tied to the connection lifecycle. */

Source from the content-addressed store, hash-verified

59 * @brief Spawns a helper process (e.g. a Python script) tied to the connection lifecycle.
60 */
61API::CommandResponse API::Handlers::SystemHandler::exec(const QString& id,
62 const QJsonObject& params)
63{
64 const auto program = params.value(QStringLiteral("program")).toString();
65 if (program.isEmpty())
66 return CommandResponse::makeError(
67 id, ErrorCode::MissingParam, QStringLiteral("Missing 'program'"));
68
69 QStringList arguments;
70 for (const auto& arg : params.value(QStringLiteral("args")).toArray())
71 arguments.append(arg.toString());
72
73 auto workingDir = params.value(QStringLiteral("workingDir")).toString();
74 if (workingDir.isEmpty()) {
75 const auto& projectPath = DataModel::ProjectModel::instance().jsonFilePath();
76 if (!projectPath.isEmpty())
77 workingDir = QFileInfo(projectPath).absolutePath();
78 }
79
80 QString error;
81 const int processId = ProcessLauncher::instance().launch(program, arguments, workingDir, error);
82 if (processId < 0)
83 return CommandResponse::makeError(id, ErrorCode::OperationFailed, error);
84
85 QJsonObject result;
86 result[QStringLiteral("processId")] = processId;
87 return CommandResponse::makeSuccess(id, result);
88}
89
90/**
91 * @brief Terminates a single managed helper process by id.

Callers 15

mainFunction · 0.80
setUpdateAvailableMethod · 0.80
installUpdateMethod · 0.80
cancelDownloadMethod · 0.80
authenticateMethod · 0.80
seFunction · 0.80
jquery.jsFile · 0.80
xeFunction · 0.80
YeFunction · 0.80
parseFunction · 0.80
extractTagWithAttributesFunction · 0.80
BtFunction · 0.80

Calls 4

isEmptyMethod · 0.80
launchMethod · 0.80
valueMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected