~VisualizerProcess()
			{
				if(state() == QProcess::Running)
				{
					closeWriteChannel();
					// 1 day. If you're debugging for longer, you have some real issues
					waitForFinished(86400000);
				}
			}
Example #2
0
    void stopLanguage (void)
    {
        if(state() != QProcess::Running) {
            emit statusMessage("Interpreter is not running!");
            return;
        }

        closeWriteChannel();
    }
Example #3
0
/*!
 * \brief Translates text on not Linux paltforms.
 */
QString Translator::notLinuxTranslate(QString text)
{
    QString name = parent->getCurrentSourceLang() + "-" + parent->getCurrentTargetLang();
    if (name.isEmpty())
        return "";

    QDir dir(QDir(DATALOCATION).absoluteFilePath("usr/share/apertium/modes"));
    if (!dir.exists() || !dir.exists(name + ".mode"))
        return "";

    QFile file(dir.absoluteFilePath(name + ".mode"));
    if (file.open(QIODevice::ReadOnly) == false) {
        return "";
    }
    QString mode = file.readAll();
    file.close();

    mode = mode.trimmed();
    if (mode.isEmpty()) {
        return "";
    }
    mode.replace("$1", "-g");
    mode.remove("$2");
    if (mode.indexOf("'/usr/share") == -1) {
        mode.replace(QRegularExpression("(\\s*)(/usr/share/\\S+)(\\s*)"), "\\1\"\\2\"\\3");
    }
    mode.replace("/usr/share", QDir(DATALOCATION).absolutePath() + "/usr/share");
#ifdef Q_OS_WIN
    // Windows can't handle C:/ paths in ' quotes
    mode.replace("'", "\"");
#define OS_SEP ";"
#else
#define OS_SEP ":"
#endif

    auto env = QProcessEnvironment::systemEnvironment();
    env.insert("PATH", QDir(DATALOCATION).absoluteFilePath("apertium-all-dev/bin") + OS_SEP +
               env.value("PATH"));
    env.insert("LC_ALL", "en_US.UTF-8");

    auto run = new QProcess(this);
    run->setProcessEnvironment(env);
    run->setProcessChannelMode(QProcess::MergedChannels);
#ifdef Q_OS_WIN
    run->setNativeArguments(mode);
    run->start("cmd", QStringList() << "/D" << "/Q" << "/S" << "/C");
#else
    run->start("/bin/sh", QStringList() << "-c" << mode);
#endif
    run->waitForStarted();
    run->write(text.toUtf8() + "  ");
    run->closeWriteChannel();
    run->waitForFinished();
    run->deleteLater();
    return QString::fromUtf8(run->readAll());
}
Example #4
0
QString IpProcess::executeSynchronous(const QString &program, const QStringList &arguments)
{
    QString empty("");
    QString result("");

    printCmdLine(program, arguments);

    if (arguments.count() > 0)
    {
        start(program, arguments);
    }
    else
    {
        start(program);
    }

    if (! waitForStarted())
        return empty;

    closeWriteChannel();

    int secondsToWait = 30;
    if (! waitForFinished(secondsToWait * 1000))
        return empty;

    // exit code of zero means command completed ok
    // and that output is from stdout - error output is on stderrs
    if ( (exitCode() == 0) && (errStr.isEmpty()) )
    {
        result = QString(QString(readAllStandardOutput()));
    }
    else
    {
        result = QString(QString(readAllStandardError()));
    }

    if (result.isEmpty())
    {
        // result = parseErrorCode();
    }

    // Send the result of executing the command
    emit cmdOutput(program, arguments, exitCode(), result);

    return QString(result);
}