MCPcopy Create free account
hub / github.com/analogdevicesinc/scopy / runScript

Method runScript

core/src/scopymainwindow_api.cpp:261–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261void ScopyMainWindow_API::runScript(QString scriptPath, bool exitApp)
262{
263 QFile file(scriptPath);
264 if(!file.open(QFile::ReadOnly)) {
265 qCritical(CAT_SCOPY_API) << "Unable to open the script file: " << scriptPath;
266 return;
267 }
268 const QString scriptContent = getScriptContent(&file);
269 QJSValue val = ScopyJS::GetInstance()->engine()->evaluate(scriptContent, scriptPath);
270 int ret = EXIT_SUCCESS;
271 if(val.isError()) {
272 qWarning(CAT_SCOPY_API) << "Exception:" << val.toString();
273 ret = EXIT_FAILURE;
274 } else if(!val.isUndefined()) {
275 qWarning(CAT_SCOPY_API) << val.toString();
276 }
277
278 qInfo(CAT_SCOPY_API) << "Script finished with status" << ret;
279 /* Exit application */
280 if(exitApp)
281 qApp->exit(ret);
282}
283
284void ScopyMainWindow_API::runScriptList(QStringList scriptPathList, bool exitApp)
285{

Callers

nothing calls this directly

Calls 4

engineMethod · 0.80
openMethod · 0.45
toStringMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected