void AgrosSolver::runSuite() { // log stdout if (m_enableLog) m_log = new LogStdOut(); // silent mode setSilentMode(true); connect(currentPythonEngineAgros(), SIGNAL(pythonShowMessage(QString)), this, SLOT(stdOut(QString))); connect(currentPythonEngineAgros(), SIGNAL(pythonShowHtml(QString)), this, SLOT(stdHtml(QString))); QString testSuite = QString("from test_suite.scenario import run_suite; run_suite(test_suite.test_%1)").arg(m_suiteName); qDebug() << testSuite; bool successfulRun= currentPythonEngineAgros()->runScript(testSuite); if (successfulRun) { Agros2D::scene()->clear(); Agros2D::clear(); QApplication::exit(0); } else { ErrorResult result = currentPythonEngineAgros()->parseError(); Agros2D::log()->printMessage(tr("Scripting Engine"), tr("%1\nLine: %2\nStacktrace:\n%3\n"). arg(result.error()). arg(result.line()). arg(result.traceback())); QApplication::exit(-1); } }
void AgrosSolver::runScript() { // log stdout if (m_enableLog) m_log = new LogStdOut(); if (!QFile::exists(m_fileName)) { Agros2D::log()->printMessage(tr("Scripting Engine"), tr("Python script '%1' not found").arg(m_fileName)); QApplication::exit(-1); } QTime time; time.start(); // silent mode setSilentMode(true); connect(currentPythonEngineAgros(), SIGNAL(pythonShowMessage(QString)), this, SLOT(stdOut(QString))); connect(currentPythonEngineAgros(), SIGNAL(pythonShowHtml(QString)), this, SLOT(stdHtml(QString))); bool successfulRun= currentPythonEngineAgros()->runScript(readFileContent(m_fileName), m_fileName); if (successfulRun) { Agros2D::log()->printMessage(tr("Solver"), tr("Problem was solved in %1").arg(milisecondsToTime(time.elapsed()).toString("mm:ss.zzz"))); Agros2D::scene()->clear(); Agros2D::clear(); QApplication::exit(0); } else { ErrorResult result = currentPythonEngineAgros()->parseError(); Agros2D::log()->printMessage(tr("Scripting Engine"), tr("%1\nLine: %2\nStacktrace:\n%3\n"). arg(result.error()). arg(result.line()). arg(result.traceback())); QApplication::exit(-1); } }
void PythonEngine::pythonShowHtmlCommand(const QString &fileName) { emit pythonShowHtml(fileName); }