Exemplo n.º 1
1
void DlvDebugger::stepOut()
{
    QString cmd = LiteApi::getGotools(m_liteApp);
    QProcess process;
    process.setEnvironment(LiteApi::getCurrentEnvironment(m_liteApp).toStringList());
    QFileInfo info(m_lastFileName);
    process.setWorkingDirectory(info.path());
    QStringList args;
    args << "finddecl" << "-file" << info.fileName() << "-line" << QString("%1").arg(m_lastFileLine+1);
    process.start(cmd,args);
    if (!process.waitForFinished(3000)) {
        emit debugLog(LiteApi::DebugErrorLog,"error wait find decl process");
        process.kill();
        return;
    }
    if (process.exitCode() != 0) {
        emit debugLog(LiteApi::DebugErrorLog,"error get find decl result");
        return;
    }
    QByteArray data = process.readAll().trimmed();
    QStringList ar = QString::fromUtf8(data).split(" ");
    if (ar.size() != 4 || ar[0] != "func") {
        emit debugLog(LiteApi::DebugErrorLog,"error find func decl in line");
        return;
    }
    m_funcDecl.fileName = m_lastFileName;
    m_funcDecl.funcName = ar[1];
    m_funcDecl.start = ar[2].toInt()-1;
    m_funcDecl.end = ar[3].toInt()-1;
    m_checkFuncDecl = true;
    command("next");
}
Exemplo n.º 2
0
void MainWindow::on_btnStart_clicked()
{
    if (!QFile(programPath).exists()) {
        QMessageBox::warning(this,
                             tr("Невозможно запустить процесс"),
                             tr("Не найден файл программы.\n"
                                "Возможно, не указан путь к файлу gostunnel.exe"));
        return;
    }
    if (ui->lwGroups->count() == 0) {
        return;
    }
    QString el = ui->lwGroups->currentItem()->text();
    QProcess *proc = connections.value(el);
    if (proc->pid() <= 0) {
        QDir wd = QDir(programPath);
        wd.cdUp();
        proc->setWorkingDirectory(wd.path());
        QStringList args;
        args << "--config" << programConfig
             << "-s" << el;
        connect(proc, SIGNAL(error(QProcess::ProcessError)),
                this, SLOT(processError(QProcess::ProcessError)));
        connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)),
                this, SLOT(processFinished(int,QProcess::ExitStatus)));
        connect(proc, SIGNAL(stateChanged(QProcess::ProcessState)),
                this, SLOT(processStateChenged(QProcess::ProcessState)));
        connect(proc, SIGNAL(readyReadStandardError()),
                this, SLOT(processReadyReadError()));
        connect(proc, SIGNAL(started()),
                this, SLOT(processStarted()));
        ui->lwGroups->currentItem()->setBackgroundColor(QColor::fromRgb(255, 233, 113));
        proc->start(programPath, args);
    }
Exemplo n.º 3
0
void normalize( const QString &output )
{
    QProcess vorbisgain;
    vorbisgain.setWorkingDirectory( output );
    vorbisgain.start( "vorbisgain", QStringList() << "-a" << tomTomFiles() << marbleFiles() );
    vorbisgain.waitForFinished();
}
Exemplo n.º 4
0
void ImportThread::run()
{	
	QProcess compileProcess;
	QString processBin = QString();
	
	if ((Preferences::p_getCompiler()=="latex")||(Preferences::p_getCompiler()=="tex"))
	{
		processBin=Preferences::p_getLtx2pdf();
	}
	else processBin=Preferences::p_getBin(Preferences::p_getCompiler());
	
#ifndef Q_OS_WIN
	QStringList env = QProcess::systemEnvironment();
	int j = env.indexOf(QRegExp("^PATH=(.*)"));
	int limit = env.at(j).indexOf("=");
	QString value = env.at(j).right(env.at(j).size()-limit-1).trimmed();
	value = "PATH=" + value + ":" + QFileInfo(processBin).path() + ":" + QFileInfo(Preferences::p_getBin("latex")).path() + ":" + QFileInfo(Preferences::p_getBin("dvips")).path() + ":" + QFileInfo(Preferences::p_getBin("ps2pdf")).path();
        env.replace(j,value);
	compileProcess.setEnvironment(env);
#endif
	
	int listLen = fileList.size();
	
	QString exoFile;
	QMap<QString,QString> * exoMap = new QMap<QString,QString>;
	
	for (int i=0; i<listLen; i++)
		{	
			exoMap = new QMap<QString,QString>;
			*exoMap = fileList.at(i);
			exoFile = exoMap->value("filepath");
			compileProcess.setWorkingDirectory(QFileInfo(exoFile).path());
			QStringList args;
			QString tmpFileName = QFileInfo(exoFile).baseName() + "-preview.tex";
			
			if ((Preferences::p_getCompiler()=="latex")||(Preferences::p_getCompiler()=="tex"))
			{ 
#ifdef Q_OS_WIN
				args << QFileInfo(exoFile).baseName() + "-preview" << Preferences::p_getBin("latex") << Preferences::p_getBin("dvips") << Preferences::p_getBin("ps2pdf") << Preferences::p_getCompilationOptions();
#else
                              args << "-c" << tmpFileName << Preferences::p_getBin("latex") << Preferences::p_getBin("dvips") << Preferences::p_getBin("ps2pdf") << Preferences::p_getCompilationOptions();
                //             args << "-c" << tmpFileName << "latex" << "dvips" << "ps2pdf" << Preferences::p_getCompilationOptions();
#endif
			}
			else args << Preferences::p_getCompilationOptions() << tmpFileName;
	
			// On exécute la compilation
			compileProcess.start(processBin,args);
			compileProcess.waitForFinished(-1);
			QString errorOutput = compileProcess.readAll();
			QString outName=QString();
			outName = QFileInfo(exoFile).path() + QDir::separator()+ QFileInfo(exoFile).baseName()+"-preview.pdf";
			
			QFile outFile;
			if (outFile.exists(outName)) {	emit exoTreated(exoMap);		} 
				else emit errorOccured(exoFile,errorOutput);
			exoMap->~QMap();
		}
}
Exemplo n.º 5
0
QProcess * Engine::run(QFileInfo input, QObject * parent /* = nullptr */)
{
	QString exeFilePath = programPath(program());
	if (exeFilePath.isEmpty())
		return nullptr;

	QStringList env = QProcess::systemEnvironment();
	QProcess * process = new QProcess(parent);

	QString workingDir = input.canonicalPath();
#if defined(Q_OS_WIN)
	// files in the root directory of the current drive have to be handled specially
	// because QFileInfo::canonicalPath() returns a path without trailing slash
	// (i.e., a bare drive letter)
	if (workingDir.length() == 2 && workingDir.endsWith(QChar::fromLatin1(':')))
		workingDir.append(QChar::fromLatin1('/'));
#endif
	process->setWorkingDirectory(workingDir);


#if !defined(Q_OS_DARWIN) // not supported on OS X yet :(
	// Add a (customized) TEXEDIT environment variable
	env << QString::fromLatin1("TEXEDIT=%1 --position=%d %s").arg(QCoreApplication::applicationFilePath());

	#if defined(Q_OS_WIN) // MiKTeX apparently uses it's own variable
	env << QString::fromLatin1("MIKTEX_EDITOR=%1 --position=%l \"%f\"").arg(QCoreApplication::applicationFilePath());
	#endif
#endif

	QStringList args = arguments();

	// for old MikTeX versions: delete $synctexoption if it causes an error
	static bool checkedForSynctex = false;
	static bool synctexSupported = true;
	if (!checkedForSynctex) {
		QString pdftex = programPath(QString::fromLatin1("pdftex"));
		if (!pdftex.isEmpty()) {
			int result = QProcess::execute(pdftex, QStringList() << QString::fromLatin1("-synctex=1") << QString::fromLatin1("-version"));
			synctexSupported = (result == 0);
		}
		checkedForSynctex = true;
	}
	if (!synctexSupported)
		args.removeAll(QString::fromLatin1("$synctexoption"));

	args.replaceInStrings(QString::fromLatin1("$synctexoption"), QString::fromLatin1("-synctex=1"));
	args.replaceInStrings(QString::fromLatin1("$fullname"), input.fileName());
	args.replaceInStrings(QString::fromLatin1("$basename"), input.completeBaseName());
	args.replaceInStrings(QString::fromLatin1("$suffix"), input.suffix());
	args.replaceInStrings(QString::fromLatin1("$directory"), input.absoluteDir().absolutePath());

	process->setEnvironment(env);
	process->setProcessChannelMode(QProcess::MergedChannels);

	process->start(exeFilePath, args);

	return process;
}
bool BuildableHelperLibrary::buildHelper(const BuildHelperArguments &arguments,
                                         QString *log, QString *errorMessage)
{
    const QChar newline = QLatin1Char('\n');
    // Setup process
    QProcess proc;
    proc.setEnvironment(arguments.environment.toStringList());
    proc.setWorkingDirectory(arguments.directory);
    proc.setProcessChannelMode(QProcess::MergedChannels);

    log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                          "Building helper \"%1\" in %2\n").arg(arguments.helperName,
                                                                              arguments.directory));
    log->append(newline);

    const FileName makeFullPath = arguments.environment.searchInPath(arguments.makeCommand);
    if (QFileInfo::exists(arguments.directory + QLatin1String("/Makefile"))) {
        if (makeFullPath.isEmpty()) {
            *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
                                                       "%1 not found in PATH\n").arg(arguments.makeCommand);
            return false;
        }
        const QString cleanTarget = QLatin1String("distclean");
        log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                                   "Running %1 %2...\n")
                    .arg(makeFullPath.toUserOutput(), cleanTarget));
        if (!runBuildProcess(proc, makeFullPath, QStringList(cleanTarget), 30, true, log, errorMessage))
            return false;
    }
    QStringList qmakeArgs;
    if (!arguments.targetMode.isEmpty())
        qmakeArgs << arguments.targetMode;
    if (!arguments.mkspec.isEmpty())
        qmakeArgs << QLatin1String("-spec") << arguments.mkspec.toUserOutput();
    qmakeArgs << arguments.proFilename;
    qmakeArgs << arguments.qmakeArguments;

    log->append(newline);
    log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                            "Running %1 %2 ...\n").arg(arguments.qmakeCommand.toUserOutput(),
                                                                       qmakeArgs.join(QLatin1Char(' '))));

    if (!runBuildProcess(proc, arguments.qmakeCommand, qmakeArgs, 30, false, log, errorMessage))
        return false;
    log->append(newline);
    if (makeFullPath.isEmpty()) {
        *errorMessage = QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                                "%1 not found in PATH\n").arg(arguments.makeCommand);
        return false;
    }
    log->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary",
                                            "Running %1 %2 ...\n")
                .arg(makeFullPath.toUserOutput(), arguments.makeArguments.join(QLatin1Char(' '))));
    if (!runBuildProcess(proc, makeFullPath, arguments.makeArguments, 120, false, log, errorMessage))
        return false;
    return true;
}
Exemplo n.º 7
0
    void run()
    {
        QProcess process;
        QString dir = QCoreApplication::applicationDirPath() + "/plugins/hilec";
        process.setWorkingDirectory(dir);
        process.start(dir + "/compile.bat", QStringList(QFileInfo(mFile).canonicalFilePath()) << mBase);
        if(!process.waitForFinished(5000))
        {
            QByteArray standardOutput = process.readAllStandardOutput();
            if(!standardOutput.isEmpty()){
                qDebug() << standardOutput;
            }
            QByteArray standardError = process.readAllStandardError();
            if(!standardError.isEmpty()){
                qDebug() << standardError;
            }
            process.kill();
            return;
        }

        QString str = process.readAllStandardOutput();
        QStringList errors = str.split("\n", QString::SkipEmptyParts);
        ScriptCompileInfo info;
        info.file = mFile;
        QDir baseDir(mBase);
        foreach(QString line, errors)
        {
            ScriptCompileProblem problem;
            QStringList parts = line.split(":");
            if(parts.size() < 3)
                continue;
            QString file = parts.takeFirst();
            if(file.size() == 1) // this is a windows disc
                file += ":" + parts.takeFirst();
            if(QFileInfo(baseDir.absoluteFilePath(file)) != QFileInfo(mFile))
                continue;
            if(parts.size() < 2)
                continue;
            problem.line = parts.takeFirst().toInt();
            QString msg = parts.join(":").trimmed().mid(1);
            int pos = msg.indexOf("]");
            if(pos < 1)
                continue;
            QChar mode = msg[0];
            if(mode == 'E' || mode == 'F')
                problem.mode = ScriptCompileProblem::Error;
            else if(mode == 'W')
                problem.mode = ScriptCompileProblem::Warning;
            else if(mode == 'C')
                problem.mode = ScriptCompileProblem::Info;
            else
                continue;
            problem.msg = msg.mid(pos + 1).trimmed();
            info.problems << problem;
            //qDebug() << mode << msg;
        }
Exemplo n.º 8
0
bool PatchTool::runPatch(const QByteArray &input, const QString &workingDirectory,
                         int strip, bool reverse)
{
    const QString patch = patchCommand();
    if (patch.isEmpty()) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "There is no patch-command configured in the general \"Environment\" settings."));
        return false;
    }

    QProcess patchProcess;
    if (!workingDirectory.isEmpty())
        patchProcess.setWorkingDirectory(workingDirectory);
    QStringList args;
    // Add argument 'apply' when git is used as patch command since git 2.5/Windows
    // no longer ships patch.exe.
    if (patch.endsWith(QLatin1String("git"), Qt::CaseInsensitive)
        || patch.endsWith(QLatin1String("git.exe"), Qt::CaseInsensitive)) {
        args << QLatin1String("apply");
    }
    if (strip >= 0)
        args << (QLatin1String("-p") + QString::number(strip));
    if (reverse)
        args << QLatin1String("-R");
    MessageManager::write(QApplication::translate("Core::PatchTool", "Executing in %1: %2 %3").
                          arg(QDir::toNativeSeparators(workingDirectory),
                              QDir::toNativeSeparators(patch), args.join(QLatin1Char(' '))));
    patchProcess.start(patch, args);
    if (!patchProcess.waitForStarted()) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "Unable to launch \"%1\": %2").arg(patch, patchProcess.errorString()));
        return false;
    }
    patchProcess.write(input);
    patchProcess.closeWriteChannel();
    QByteArray stdOut;
    QByteArray stdErr;
    if (!Utils::SynchronousProcess::readDataFromProcess(patchProcess, 30, &stdOut, &stdErr, true)) {
        Utils::SynchronousProcess::stopProcess(patchProcess);
        MessageManager::write(QApplication::translate("Core::PatchTool", "A timeout occurred running \"%1\"").arg(patch));
        return false;

    }
    if (!stdOut.isEmpty())
        MessageManager::write(QString::fromLocal8Bit(stdOut));
    if (!stdErr.isEmpty())
        MessageManager::write(QString::fromLocal8Bit(stdErr));

    if (patchProcess.exitStatus() != QProcess::NormalExit) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "\"%1\" crashed.").arg(patch));
        return false;
    }
    if (patchProcess.exitCode() != 0) {
        MessageManager::write(QApplication::translate("Core::PatchTool", "\"%1\" failed (exit code %2).").arg(patch).arg(patchProcess.exitCode()));
        return false;
    }
    return true;
}
Exemplo n.º 9
0
void MainWindow::on_pushButton_clicked()   // process one should be launched (bash launches)
{
    QProcess *proc = new QProcess();
    proc->setWorkingDirectory("/home/kondo/");
    proc->start("/bin/bash", QStringList() << "/home/syed/backup.sh");
    qDebug() << "Error in opening the file =" << proc->errorString();
   // MainWindow::on_checkBox_2_stateChanged(0);
  //  MainWindow::pushbutton3(TRUE);

}
Exemplo n.º 10
0
//////// NOT USED //////////
void Gridifier::copyCheckPointFiles(const QString &host){
  QProcess *rgcpcProcess = new QProcess(QString("./rgcpc.pl"));
  rgcpcProcess->setWorkingDirectory(mScriptsDir);
  rgcpcProcess->addArgument("-t");
  rgcpcProcess->addArgument(host);
  rgcpcProcess->addArgument("-f");
  rgcpcProcess->addArgument("checkPointDataCache.xml");
  rgcpcProcess->start();

  // and then do something clever to give the users an update status on the file transfer progress
}
Exemplo n.º 11
0
bool versionControl::runMercurial(QString options) {

    if (!this->isMercurialThere)
        return false;

    QSettings settings;

    // get current model path from QSettings

    QString path = settings.value("files/currentFileName", "No model").toString();

    if (path == "No model")
        return false;

    // set up the environment for the spawned processes
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("PATH", qgetenv("PATH"));
    // to be used as a username if one is not set
    env.insert("EMAIL", QHostInfo::localHostName());

    // make the QProcess
    QProcess * mercurial = new QProcess;
    mercurial->setWorkingDirectory(QDir::toNativeSeparators(path));
    mercurial->setProcessEnvironment(env);

    connect(mercurial, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
    connect(mercurial, SIGNAL(readyReadStandardOutput()), this, SLOT(standardOutput()));
    connect(mercurial, SIGNAL(readyReadStandardError()), this, SLOT(standardError()));

    // clear stdOut & stdErr texts
    stdOutText.clear();
    stdErrText.clear();

    // launch
    mercurial->start("hg " + options);

    // wait until complete, or 3 s
    bool noerror = mercurial->waitForFinished(3000);

    if (noerror) {
        // check output
        if (mercurial->exitCode() == 0) {
            delete mercurial;
            return true;
        } else {
            delete mercurial;
            return false;
        }

    }
    delete mercurial;
    return false;

}
Exemplo n.º 12
0
int RSLOutputNode::compile()    const
{
    QProcess *process = new QProcess();
    QStringList arguments;
    arguments << getFileName();
    process->setStandardErrorFile("compiler.log");
    process->setWorkingDirectory(QFileInfo(getFileName()).canonicalPath());
    process->start("shaderdl", arguments);
    process->waitForFinished(10000);
    return 1;
}
Exemplo n.º 13
0
bool OpenModelica::start(QString exeFile,QString &errMsg,int maxnsec)
{

    QFileInfo exeFileInfo(exeFile);
    QString exeDir = exeFileInfo.absolutePath();
    if(!QFile::exists(exeFile))
    {
        errMsg = "Cannot find model executable file : " + exeFile;
        return false;
    }

    QProcess simProcess;
    simProcess.setWorkingDirectory(exeDir);


#ifdef WIN32
    QString appPath = "\""+exeFile+"\"";
    // add OM path in PATH
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString omHome = env.value("OpenModelicaHome");
    omHome = omHome+QDir::separator()+"bin";
    QString mingw = env.value("OpenModelicaHome");
    mingw = mingw+QDir::separator()+"MinGW"+QDir::separator()+"bin";
    env.insert("PATH", env.value("Path") + ";"+omHome+";"+mingw);

    simProcess.setProcessEnvironment(env);

    //start process
    simProcess.start(appPath, QStringList());
#else
    QStringList arguments;
    arguments << "-c";
    arguments << "./"+exeFileInfo.fileName() << " > log.txt";
    simProcess.start("sh", arguments);
#endif

    int nmsec;
    if(maxnsec==-1)
        nmsec = -1;
    else
        nmsec = maxnsec*1000;
    bool ok = simProcess.waitForFinished(nmsec);
    if(!ok)
    {
        errMsg = "Simulation process failed or time limit reached";
        simProcess.close();
        return false;
    }

    QString output(simProcess.readAllStandardOutput());
    InfoSender::instance()->send(Info(output,ListInfo::OMCNORMAL2));
    return ok;
}
Exemplo n.º 14
0
void Compress::execGzipCmd(const QString& savedFilename, const QString &sourceDir)
{
   QProcess process;
   QStringList args;
   process.setWorkingDirectory(QFileInfo(m_buildDir).absolutePath());
   args << "-czvf" << savedFilename << sourceDir;
   process.start("tar", args);
   bool status = process.waitForFinished(-1);
   if(!status || process.exitCode() != 0){
      throw ErrorInfo(process.errorString());
   }
}
Exemplo n.º 15
0
void MainDialog::showAssfreezer()
{
	if( !QFile::exists( cAFPath ) ) {
		QMessageBox::warning( this, "Assfreezer Missing", "Assfreezer could not be found at: " + cAFPath );
		return;
	}
	QProcess * p = new QProcess(this);
	// Delete Automatically when assfreezer exits
	connect( p, SIGNAL( finished ( int, QProcess::ExitStatus ) ), p, SLOT(deleteLater()));
	p->setWorkingDirectory( QFileInfo(cAFPath).path() );
	p->start( cAFPath, QStringList() << "-current-render" );
}
Exemplo n.º 16
0
bool SerzFile::RunSerz(const QString op, QString inPath, QString outPath)
{
	bool ok = false;
	int retCode;
	int tries = 0;
	QString in(QDir::toNativeSeparators(inPath));
	QString out(QDir::toNativeSeparators(outPath));
	
	QStringList args = QStringList() << in << op + out;
	QString exe(serzExePath());
	QString wd = QFileInfo(exe).absolutePath();

retry:
	{
		QProcess p;
		QByteArray output;
		tries++;
		p.setProcessChannelMode(QProcess::MergedChannels);
		p.setWorkingDirectory(wd);
		p.start(exe, args, QIODevice::ReadWrite);

		// TODO: make async
		QApplication::processEvents();
		p.waitForFinished(10000);
		output = p.readAllStandardOutput();
		if (output.contains("Conversion complete"))
		{
			setResult(SerzFile::Ok);
			ok = true;
		}
		else if (output.contains("Could not open input file"))
		{
			setResult(SerzFile::DecodeBadInputFile);
			ok = false;
		}
		else if (output.contains("Could not open output file"))
		{
			setResult(SerzFile::DecodeBadOutputFile);
			ok = false;
		}
		else
		{
			if (tries < 2)
				goto retry;
			setResult(SerzFile::UnknownError);
			QString e = p.errorString();
			ok = false;
		}
		retCode = p.exitCode(); // sadly it's always 0...
	}

	return ok;
}
Exemplo n.º 17
0
bool CodeManager::edit()
{
    QProcess *proc = new QProcess();
    QStringList args
        = QStringList::split(' ', Settings::instance()->editorCmd());
    args.append(filename());

    proc->setArguments(args);
    proc->setWorkingDirectory(QDir(sourcePath()));

    return proc->launch("");
}
Exemplo n.º 18
0
void KinectGrabber::grabFromKinect()
{


    QProcess* rosLaunch = new QProcess();

   rosLaunch->setWorkingDirectory(QDir::temp().absolutePath());
     //  rosLaunch->setProcessChannelMode(QProcess::MergedChannels);

   // QString launch= "roslaunch openni_launch openni.launch";

  //  QProcess::execute("killall XnSensorServer");

  //  sleep(3);

   // rosLaunch->start(launch);

   // QProcess::execute("roslaunch", QStringList() << "");

  //  openni->start();

 //   while(!rosLaunch->waitForStarted());


    ros::NodeHandle n;

    // If fails, it returns an empty subscriber
    sub = n.subscribe<sensor_msgs::PointCloud2> ("/camera/depth_registered/points", 1,&KinectGrabber::cb,this);

    imageSub = n.subscribe<sensor_msgs::Image>("/camera/rgb/image_color",1,&KinectGrabber::imagecb,this);

    if(!sub) emit error();
    else
        emit started();



  /*  while(ros::ok() && !shouldQuit){


    }*/


  //  rosLaunch->terminate();
  //  while(rosLaunch->waitForFinished());

   // n.shutdown();

   // emit finished();


}
Exemplo n.º 19
0
void Compiler::run(const QString &inputFile) {
  QProcess process;
  process.setProcessChannelMode(QProcess::MergedChannels);
  process.setWorkingDirectory(QFileInfo(inputFile).absolutePath());

  QString command = commandFor(inputFile);
  process.start(command, QProcess::ReadOnly);

  if (process.waitForFinished()) {
    output_ = process.readAll();
  } else {
    output_ = process.errorString();
  }
}
Exemplo n.º 20
0
void TestAusmt::preparePatches()
{
    GET_DIR;
    GET_FILES_DIR;
    GET_PATCHES_DIR;

    // Dump patches
    QDir patchesResDir (":/patches/");
    foreach (const QString &fileName, patchesResDir.entryList(QDir::Files)) {
        QFile file (patchesResDir.absoluteFilePath(fileName));
        if (patchesDir.exists(fileName)) {
            QVERIFY(QFileInfo(patchesDir.absoluteFilePath(fileName)).isFile());
            QVERIFY(patchesDir.remove(fileName));
        }
        QVERIFY(file.copy(patchesDir.absoluteFilePath(fileName)));
    }

    foreach (const QString &dirName, patchesResDir.entryList(QDir::Dirs)) {
        if (patchesDir.exists(dirName)) {
            QVERIFY(QFileInfo(patchesDir.absoluteFilePath(dirName)).isDir());
            QDir subDir (patchesDir);
            QVERIFY(subDir.cd(dirName));
            QVERIFY(subDir.removeRecursively());
        }

        patchesDir.mkdir(dirName);
        QDir patchesSubDir (patchesDir);
        QVERIFY(patchesSubDir.cd(dirName));

        QDir patchesResSubDir (patchesResDir);
        QVERIFY(patchesResSubDir.cd(dirName));

        foreach (const QString &fileName, patchesResSubDir.entryList(QDir::Files)) {
            QFile file (patchesResSubDir.absoluteFilePath(fileName));
            QVERIFY(file.copy(patchesSubDir.absoluteFilePath(fileName)));
        }
    }

    // Update patches
    QString makePatchName = patchesDir.absoluteFilePath(MAKE_PATCH_SH);
    QFile makePatch (makePatchName);
    QVERIFY(makePatch.exists());
    QVERIFY(makePatch.setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser));
    QProcess makePatchProcess;
    makePatchProcess.setWorkingDirectory(patchesDir.absolutePath());
    makePatchProcess.start(patchesDir.absoluteFilePath(MAKE_PATCH_SH),
                           QStringList() << filesDir.absolutePath());
    makePatchProcess.waitForFinished(-1);
    QCOMPARE(makePatchProcess.exitCode(), 0);
}
Exemplo n.º 21
0
bool runUpdater()
{
    QStringList args;
    args<<"-v"<<GlobalDef::CLIENT_VER;
    QProcess *process = new QProcess(qApp);
    process->setWorkingDirectory(QDir::currentPath());
    QObject::connect(qApp, &QApplication::aboutToQuit, process, &QProcess::kill);
    process->start(QDir::current().filePath("updater"), args);
    if (!process->waitForStarted()){
        GradualBox::showText(QObject::tr("We cannot find updater.\n"
                                         "You may need to check update yourself."));
        return false;
    }
    return true;
}
Exemplo n.º 22
0
/** Instructs the simulation associated with the specified SGS
    to take a checkpoint and then stop.  This call blocks until
    job has stopped or a time-out occurs. */
QString Gridifier::checkPointAndStop(const QString &sgsGSH){
  QProcess *checkPointAndStopProcess = new QProcess(QString("./checkpoint_and_stop.pl"));
  checkPointAndStopProcess->setWorkingDirectory(mScriptsDir);
  checkPointAndStopProcess->addArgument(sgsGSH);
  checkPointAndStopProcess->start();

  while (checkPointAndStopProcess->isRunning()){
    usleep(10000);
    mApplication->processEvents();
  }

  QString result = checkPointAndStopProcess->readStdout();

  return result;
}
Exemplo n.º 23
0
void caddons_installer_dialog::step1_5_refresh_repos_from_www()
{
    //1. get std repo: http://master.dl.sourceforge.net/project/gnurpgm/addons/repo_index.ini

    QProcess *p = new QProcess();
    QStringList args;
    QDir d( QDir::homePath() + "/.gnurpgm/repo_cache" );
    if ( !d.exists() )
        d.mkdir( QDir::homePath() + "/.gnurpgm/repo_cache" );
    p->setWorkingDirectory( d.path() );
    args.append( "http://master.dl.sourceforge.net/project/gnurpgm/addons/repo_index.ini" );
    p->start( "/usr/bin/wget", args );
    this->step2_get_all_repos_into_the_lists();

}
Exemplo n.º 24
0
bool MTFile::touch(QApplication *
#ifdef Q_WS_WIN
    app
#endif
    )
{
    QStringList arguments; QProcess touch;
#ifdef Q_WS_WIN
    touch.setWorkingDirectory(QFileInfo(app->arguments().at(0)).absolutePath());
#endif
	arguments << "-cmf" << fileName();
	if (touch.execute("touch", arguments) == 0) {
		return true;
	} else { return false; }
	return false;
}
Exemplo n.º 25
0
static bool isGit(const QString &filename)
{
    QFileInfo fi(filename);
    QDir dir(fi.absoluteDir());
    QProcess git;
    git.setWorkingDirectory(dir.absolutePath());
    QStringList args;
    args << QStringLiteral("ls-files") << fi.fileName();
    git.start(QStringLiteral("git"), args);
    bool isGit = false;
    if (git.waitForStarted() && git.waitForFinished()) {
        QStringList files = QString::fromLocal8Bit(git.readAllStandardOutput()).split(QRegExp(QStringLiteral("[\n\r]")), QString::SkipEmptyParts);
        isGit = files.contains(fi.fileName());
    }
    return isGit;
}
Exemplo n.º 26
0
void HgMergeDialog::updateInitialDialog()
{
    HgWrapper *hgWrapper = HgWrapper::instance();

    // update label - current branch
    QString line("<b>parents:</b> ");
    line += hgWrapper->getParentsOfHead();
    m_currentChangeset->setText(line);

    // update heads list
    QProcess process;
    process.setWorkingDirectory(hgWrapper->getBaseDir());

    QStringList args;
    args << QLatin1String("heads");
    args << QLatin1String("--template");
    args << QLatin1String("{rev}\n{node|short}\n{branch}\n"
                          "{author}\n{desc|firstline}\n");

    process.start(QLatin1String("hg"), args);
    m_commitInfoWidget->clear();

    const int FINAL = 5;
    char buffer[FINAL][1024];
    int count = 0;
    while (process.waitForReadyRead()) {
        while (process.readLine(buffer[count], sizeof(buffer[count])) > 0) {
            if (count == FINAL - 1) {
                QString rev = QTextCodec::codecForLocale()->toUnicode(buffer[0]).trimmed();
                QString changeset = QTextCodec::codecForLocale()->toUnicode(buffer[1]).trimmed();
                QString branch = QTextCodec::codecForLocale()->toUnicode(buffer[2]).trimmed();
                QString author = QTextCodec::codecForLocale()->toUnicode(buffer[3]).trimmed();
                QString log = QTextCodec::codecForLocale()->toUnicode(buffer[4]).trimmed();

                QListWidgetItem *item = new QListWidgetItem;
                item->setData(Qt::DisplayRole, changeset);
                item->setData(Qt::UserRole + 1, rev);
                item->setData(Qt::UserRole + 2, branch);
                item->setData(Qt::UserRole + 3, author);
                item->setData(Qt::UserRole + 4, log);
                m_commitInfoWidget->addItem(item);

            }
            count = (count + 1)%FINAL;
        }
    }
}
void SyncProcess::startQProcess(QProcess& process)
{
    const QString command = generateFullCommand();
    if (command.isEmpty())
        throw SyncProcessException("Cannot start process '" + generateDescription() + "'. The full command is '" + command + "'.");

    if (!mStdInFile.isEmpty())
        process.setStandardInputFile(mStdInFile);

    process.setProcessEnvironment(generateFullEnvironment());
    mDiagnosticInfo += QObject::tr("Starting process '%1'\n").arg(generateDescription());
    process.setWorkingDirectory(mWorkingDirectory);
    process.start(command, generateFullArguments());
    process.waitForStarted();

    if (process.state() != QProcess::Running)
        throw SyncProcessException("Starting process '" + generateDescription() + "' failed. The process is not in a running state.");
}
Exemplo n.º 28
0
/**
 * Method calls lb3d_client.pl script to call web service
 * to actually launch the job on the target machine
 */
void Gridifier::webServiceJobSubmit(const QString & scriptConfigFileName){

  // Construct name of script from name of application
  QProcess *launchSimScriptProcess = new QProcess(QString("./lb3d_client.pl"));
  launchSimScriptProcess->setWorkingDirectory(mScriptsDir);
  launchSimScriptProcess->addArgument(scriptConfigFileName);

  launchSimScriptProcess->start();

  while (launchSimScriptProcess->isRunning()){
    usleep(10000);
    mApplication->processEvents();
  }

  cout << "Stdout:" << endl << launchSimScriptProcess->readStdout() << endl;
  if (launchSimScriptProcess->canReadLineStderr())
    cout << "Stderr:" << endl << launchSimScriptProcess->readStderr() << endl;
}
Exemplo n.º 29
0
/*
 * Setup QPorcess object
 */
void lamexp_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir)
{
	//Environment variable names
	static const char *const s_envvar_names_temp[] =
	{
		"TEMP", "TMP", "TMPDIR", "HOME", "USERPROFILE", "HOMEPATH", NULL
	};
	static const char *const s_envvar_names_remove[] =
	{
		"WGETRC", "SYSTEM_WGETRC", "HTTP_PROXY", "FTP_PROXY", "NO_PROXY", "GNUPGHOME", "LC_ALL", "LC_COLLATE", "LC_CTYPE", "LC_MESSAGES", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LANG", NULL
	};

	//Initialize environment
	QProcessEnvironment env = process.processEnvironment();
	if(env.isEmpty()) env = QProcessEnvironment::systemEnvironment();

	//Clean a number of enviroment variables that might affect our tools
	for(size_t i = 0; s_envvar_names_remove[i]; i++)
	{
		env.remove(QString::fromLatin1(s_envvar_names_remove[i]));
		env.remove(QString::fromLatin1(s_envvar_names_remove[i]).toLower());
	}

	const QString tempDir = QDir::toNativeSeparators(lamexp_temp_folder2());

	//Replace TEMP directory in environment
	if(bReplaceTempDir)
	{
		for(size_t i = 0; s_envvar_names_temp[i]; i++)
		{
			env.insert(s_envvar_names_temp[i], tempDir);
		}
	}

	//Setup PATH variable
	const QString path = env.value("PATH", QString()).trimmed();
	env.insert("PATH", path.isEmpty() ? tempDir : QString("%1;%2").arg(tempDir, path));
	
	//Setup QPorcess object
	process.setWorkingDirectory(wokringDir);
	process.setProcessChannelMode(QProcess::MergedChannels);
	process.setReadChannel(QProcess::StandardOutput);
	process.setProcessEnvironment(env);
}
Exemplo n.º 30
0
// when create is pressed
void MainWindow::on_Create_clicked()
{
    // declarations
    QMessageBox Finished;
    QString Message;
    QProcess bximage;
    QStringList arguments;
    int size2;
    bool ok;
    size_t BufSize = 1024;
    char buf[BufSize];
    QString currentPath;

    // make size argument
    size2 = Size.toInt(&ok, 10);
    snprintf(buf, BufSize, "-size=%i", size2);
    Size = QString::fromAscii(buf);

    // put bximage arugments in arguments
    arguments << type << format;
    arguments << Size << "-q";
    arguments << path;

    // print arguments
    for(int count = 0; count < 5; count++)
        qDebug() << arguments[count];

    // print current path
    currentPath = QDir::currentPath();
    qDebug() << currentPath;

    // start bximage
    bximage.setReadChannel(QProcess::StandardOutput);
    bximage.setWorkingDirectory(QString(QDir::currentPath()));
    bximage.start("bximage", arguments);
    bximage.waitForStarted(-1);

    // make messagebox
    Message = path + QString(" has been created");
    Finished.setWindowTitle("Finished");
    Finished.setText(Message);
    Finished.setIcon(QMessageBox::Information);
    Finished.exec();
}