| 259 | } |
| 260 | |
| 261 | void 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 | |
| 284 | void ScopyMainWindow_API::runScriptList(QStringList scriptPathList, bool exitApp) |
| 285 | { |