Exemplo n.º 1
0
    bool DisplayServer::start() {
        // check flag
        if (m_started)
            return false;

        // create process
        process = new QProcess(this);

        // delete process on finish
        connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished()));

        // log message
        qDebug() << " DAEMON: Display server starting...";

        if (Configuration::instance()->testing) {
            process->start("/usr/bin/Xephyr", { m_display, "-ac", "-br", "-noreset", "-screen",  "800x600"});
        } else {
            // set process environment
            QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
            env.insert("DISPLAY", m_display);
            env.insert("XAUTHORITY", m_authPath);
            env.insert("XCURSOR_THEME", Configuration::instance()->cursorTheme());
            process->setProcessEnvironment(env);

            // get display
            Display *display = qobject_cast<Display *>(parent());

            // start display server
            process->start(Configuration::instance()->serverPath(), { m_display, "-auth", m_authPath, "-nolisten", "tcp", QString("vt%1").arg(QString::number(display->vtNumber()), 2, '0')});
        }

        // wait for display server to start
        if (!process->waitForStarted()) {
            // log message
            qCritical() << " DAEMON: Failed to start display server process.";

            // return fail
            return false;
        }

        // wait until we can connect to the display server
        if (!this->waitForStarted()) {
            // log message
            qCritical() << " DAEMON: Failed to connect to the display server.";

            // return fail
            return false;
        }

        // log message
        qDebug() << " DAEMON: Display server started.";

        // set flag
        m_started = true;

        // return success
        return true;
    }
void ServerManager::startServer(int id) const
{
    QStringList args = QCoreApplication::arguments();
    args.removeFirst();

    if (id < 0) {
        id = startCounter;
    }

    TWebApplication::MultiProcessingModule mpm = Tf::app()->multiProcessingModule();
    if (mpm == TWebApplication::Hybrid || mpm == TWebApplication::Thread) {
        if (id < maxServers) {
            args.prepend(QString::number(id));
            args.prepend("-i");  // give ID for app server
        }
    }

    if (listeningSocket > 0) {
        args.prepend(QString::number(listeningSocket));
        args.prepend("-s");
    }

    QProcess *tfserver = new QProcess;
    serversStatus.insert(tfserver, id);

    connect(tfserver, SIGNAL(started()), this, SLOT(updateServerStatus()));
    connect(tfserver, SIGNAL(error(QProcess::ProcessError)), this, SLOT(errorDetect(QProcess::ProcessError)));
    connect(tfserver, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(serverFinish(int, QProcess::ExitStatus)));
    connect(tfserver, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));    // For error notification

#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
    // Sets LD_LIBRARY_PATH environment variable
    QString ldpath = ".";  // means the lib dir
    QString sysldpath = QProcess::systemEnvironment().filter("LD_LIBRARY_PATH=", Qt::CaseSensitive).value(0).mid(16);
    if (!sysldpath.isEmpty()) {
        ldpath += ":";
        ldpath += sysldpath;
    }

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("LD_LIBRARY_PATH", ldpath);
    tSystemDebug("export %s=%s", "LD_LIBRARY_PATH", qPrintable(ldpath));

    QString preload = Tf::appSettings()->value(Tf::LDPreload).toString();
    if (!preload.isEmpty()) {
        env.insert("LD_PRELOAD", preload);
        tSystemDebug("export %s=%s", "LD_PRELOAD", qPrintable(preload));
    }
    tfserver->setProcessEnvironment(env);
#endif

    // Executes treefrog server
    tfserver->start(TFSERVER_CMD, args, QIODevice::ReadOnly);
    tfserver->closeReadChannel(QProcess::StandardOutput);
    tfserver->closeWriteChannel();
    tSystemDebug("tfserver started");
    ++startCounter;
}
Exemplo n.º 3
0
/*
 * Initialize and launch process object
 */
bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args)
{
    static AssignProcessToJobObjectFun AssignProcessToJobObjectPtr = NULL;

    QMutexLocker lock(m_mutex_startProcess);
    emit messageLogged(commandline2string(program, args) + "\n");

    QProcessEnvironment env = process.processEnvironment();
    if(env.isEmpty()) env = QProcessEnvironment::systemEnvironment();
    env.insert("TEMP", QDir::toNativeSeparators(lamexp_temp_folder2()));
    env.insert("TMP", QDir::toNativeSeparators(lamexp_temp_folder2()));
    process.setProcessEnvironment(env);

    if(!AssignProcessToJobObjectPtr)
    {
        QLibrary Kernel32Lib("kernel32.dll");
        AssignProcessToJobObjectPtr = (AssignProcessToJobObjectFun) Kernel32Lib.resolve("AssignProcessToJobObject");
    }

    process.setProcessChannelMode(QProcess::MergedChannels);
    process.setReadChannel(QProcess::StandardOutput);
    process.start(program, args);

    if(process.waitForStarted())
    {

        if(AssignProcessToJobObjectPtr)
        {
            AssignProcessToJobObjectPtr(m_handle_jobObject, process.pid()->hProcess);
        }
        if(!SetPriorityClass(process.pid()->hProcess, BELOW_NORMAL_PRIORITY_CLASS))
        {
            SetPriorityClass(process.pid()->hProcess, IDLE_PRIORITY_CLASS);
        }

        lock.unlock();

        if(m_firstLaunch)
        {
            emit statusUpdated(0);
            m_firstLaunch = false;
        }

        return true;
    }

    emit messageLogged("Process creation has failed :-(");
    QString errorMsg= process.errorString().trimmed();
    if(!errorMsg.isEmpty()) emit messageLogged(errorMsg);

    process.kill();
    process.waitForFinished(-1);
    return false;
}
Exemplo n.º 4
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.º 5
0
    bool Greeter::start() {
        // check flag
        if (m_started)
            return false;

        if (daemonApp->testing()) {
            // create process
            m_process = new QProcess(this);

            // delete process on finish
            connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished()));

            connect(m_process, SIGNAL(readyReadStandardOutput()), SLOT(onReadyReadStandardOutput()));
            connect(m_process, SIGNAL(readyReadStandardError()), SLOT(onReadyReadStandardError()));

            // log message
            qDebug() << "Greeter starting...";

            // set process environment
            QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
            env.insert("DISPLAY", m_display->name());
            env.insert("XAUTHORITY", m_authPath);
            env.insert("XCURSOR_THEME", mainConfig.Theme.CursorTheme.get());
            m_process->setProcessEnvironment(env);

            // start greeter
            QStringList args;
            if (daemonApp->testing())
                args << "--test-mode";
            args << "--socket" << m_socket
                 << "--theme" << m_theme;
            m_process->start(QString("%1/sddm-greeter").arg(BIN_INSTALL_DIR), args);

            //if we fail to start bail immediately, and don't block in waitForStarted
            if (m_process->state() == QProcess::NotRunning) {
                qCritical() << "Greeter failed to launch.";
                return false;
            }
            // wait for greeter to start
            if (!m_process->waitForStarted()) {
                // log message
                qCritical() << "Failed to start greeter.";

                // return fail
                return false;
            }

            // log message
            qDebug() << "Greeter started.";

            // set flag
            m_started = true;
        } else {
Exemplo n.º 6
0
/*
 * Based on the given file, we use 'slocate' to suggest complete paths
 */
QStringList UnixCommand::getFilePathSuggestions(const QString &file)
{
  QProcess slocate;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  slocate.setProcessEnvironment(env);
  slocate.start("slocate -l 8 " + file);
  slocate.waitForFinished();

  QString ba = slocate.readAllStandardOutput();
  return ba.split("\n", QString::SkipEmptyParts);
}
Exemplo n.º 7
0
bool StyleInjector::launch(const QStringList &programAndArgs,
                          const QString &probeDll, const QString &probeFunc)
{
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("GAMMARAY_STYLEINJECTOR_PROBEDLL", probeDll);
  env.insert("GAMMARAY_STYLEINJECTOR_PROBEFUNC", probeFunc);

  QString qtPluginPath = env.value("QT_PLUGIN_PATH");
  if (!qtPluginPath.isEmpty()) {
    qtPluginPath.append(":");
  }
  qtPluginPath.append(GAMMARAY_LIB_INSTALL_DIR "/qt4/plugins");
  env.insert("QT_PLUGIN_PATH", qtPluginPath);

  InteractiveProcess proc;
  proc.setProcessEnvironment(env);
  proc.setProcessChannelMode(QProcess::ForwardedChannels);

  QStringList args = programAndArgs;

  if (env.value("GAMMARAY_GDB").toInt()) {
    QStringList newArgs;
    newArgs << "gdb" << "--eval-command" << "run" << "--args";
    newArgs += args;
    args = newArgs;
  } else if (env.value("GAMMARAY_MEMCHECK").toInt()) {
    QStringList newArgs;
    newArgs << "valgrind" << "--tool=memcheck" << "--track-origins=yes" << "--num-callers=25";
    newArgs += args;
    args = newArgs;
  } else if (env.value("GAMMARAY_HELGRIND").toInt()) {
    QStringList newArgs;
    newArgs << "valgrind" << "--tool=helgrind";
    newArgs += args;
    args = newArgs;
  }

  const QString program = args.takeFirst();
  args << QLatin1String("-style") << QLatin1String("gammaray-injector");
  proc.start(program, args);
  proc.waitForFinished(-1);

  mExitCode = proc.exitCode();
  mProcessError = proc.error();
  mExitStatus = proc.exitStatus();
  mErrorString = proc.errorString();

  return mExitCode == EXIT_SUCCESS && mExitStatus == QProcess::NormalExit;
}
Exemplo n.º 8
0
/*
 * Given a package name, which can be installed or uninstalled on system
 * returns a string containing all the files inside it, the file list is
 * obtained using pkgfile
 */
QByteArray UnixCommand::getPackageContentsUsingPkgfile(const QString &pkgName)
{
  QByteArray result("");
  QProcess pkgfile;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  pkgfile.setProcessEnvironment(env);

  pkgfile.start("pkgfile -l " + pkgName);
  pkgfile.waitForFinished();
  result = pkgfile.readAllStandardOutput();

  return result;
}
Exemplo n.º 9
0
QStringList AuthorizationManager::getUserGroups(QString user){
  QProcess proc;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_All", "C");
  proc.setProcessEnvironment(env);
  proc.setProcessChannelMode(QProcess::MergedChannels);
  proc.start("id", QStringList() << "-nG" << user);
  if(!proc.waitForStarted(30000)){ return QStringList(); } //process never started - max wait of 30 seconds
  while(!proc.waitForFinished(500)){
    if(proc.state() != QProcess::Running){ break; } //somehow missed the finished signal
    QCoreApplication::processEvents();
  }
  QStringList out = QString(proc.readAllStandardOutput()).split(" ");
  return out;	
}
Exemplo n.º 10
0
void HeightmapDialog::compile()
{
  QString     working_directory = QDir::currentPath();
  QProcess    process(this);
  QStringList args;

  generateInputFile();
  args << "--compile-heightmap" << inputFilename() << outputFilename();
  process.setWorkingDirectory(working_directory);
#ifdef _WIN32
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("Path", "..\\Panda3D-1.9.0\\bin;" + env.value("Path"));
    process.setProcessEnvironment(env);
    process.start("./game.exe", args);
#else
    process.start("./game", args);
#endif
    if (process.waitForFinished())
    {
      if (process.exitCode() == 0)
        emit heightmapCreated(outputFilename());
      else
        QMessageBox::warning(this, "Error", "The heightmap compiling failed.");
    }
    else
      QMessageBox::warning(this, "Error", "The heightmap compiling failed to start.");

}
Exemplo n.º 11
0
Action::Action(QObject *parent)
    : QProcess(parent)
    , m_failed(false)
    , m_firstProcess(NULL)
    , m_currentLine(-1)
{
    setProcessChannelMode(QProcess::SeparateChannels);
    connect( this, SIGNAL(error(QProcess::ProcessError)),
             SLOT(actionError(QProcess::ProcessError)) );
    connect( this, SIGNAL(started()),
             SLOT(actionStarted()) );
    connect( this, SIGNAL(finished(int,QProcess::ExitStatus)),
             SLOT(actionFinished()) );
    connect( this, SIGNAL(readyReadStandardError()),
             SLOT(actionErrorOutput()) );

    connect( this, SIGNAL(readyReadStandardOutput()),
             this, SLOT(actionOutput()) );

    quintptr id = actionId(this);
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("COPYQ_ACTION_ID", QString::number(id));
    setProcessEnvironment(env);
    setProperty("COPYQ_ACTION_ID", id);

    const QMutexLocker lock(&actionsLock);
    actions.append(this);
}
Exemplo n.º 12
0
/** @brief This internal function controls how to launch the Salome tool, specially due to the path of this tool (not in
* traditional Linux paths like usr/bin). So, with this function we locate the path to Salome to run it
*
*/
void MainWindow::launchSalomeMeshTool()
{
   // Step 1. Set up the working directory in the project

   QString _workingDir = QDir(_projectData.getProjectPath()).filePath(TOOL4);
   _salomeLocationProccess->setWorkingDirectory(_workingDir);

   // Esto no funciona --> Revisar ...
   QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
   env.insert("WORKINGDIR", _workingDir); // Add an environment variable
   _salomeLocationProccess->setProcessEnvironment(env);

   // Step 2. Launch Mesh Tool
 //  QString _command = "export WORKINGDIR=\"" +_workingDir +"\"; echo $WORKINGDIR";//+
   QString _command = _userPreferencesData.getMeshViewerPath();
   // By default for Salome tools
   if ( (_command.isNull()) || (_command.isEmpty()) )
   {
       // There is no configuration for the Salome Mesher. The user shall provide the location of the executable
        MeshingToolConfigurationWarningDialog _meshingWarning;
        _meshingWarning.initializeStructures(&_userPreferencesData,&_solverManager);
        _meshingWarning.exec();
        return;
   }


    QProcess * _runSalome = new QProcess(this) ;
    connect(_runSalome, SIGNAL(error(QProcess::ProcessError)),
             this, SLOT(slotProcessError(QProcess::ProcessError)));
    _runSalome->start(_command);

}
Exemplo n.º 13
0
// ----------------------------------------------------------------------------
void LocalEvaluator::startJulia( QStringList args )
{
  QDir julia_dir(Singleton<JuliaSettings>::GetInstance()->GetPathToBinaries());

  process_string = QDir::toNativeSeparators(julia_dir.absoluteFilePath("bin/julia-release-basic"));

#if defined(Q_OS_WIN)
  process_string = QDir::toNativeSeparators(julia_dir.absoluteFilePath("julia.bat"));
  // set up context for julia (only for windows)
  QDir lib_dir(julia_dir);
  lib_dir.cd("lib");

  QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
  environment.insert("PATH", environment.value("Path") + ";" + QDir::toNativeSeparators( lib_dir.absolutePath() ) );
  process->setProcessEnvironment( environment );
#endif

  process->start( process_string, args, QProcess::ReadWrite );


  if ( curr_working_dir.count() )
  {
    QString command;

#if defined(Q_OS_WIN)
    command = QString("cd(\"" + curr_working_dir + "\")\r\n");
#else
    command = QString( "cd(\"" + curr_working_dir + "\")\n" );
#endif

    process->write( command.toAscii() );
  }

}
Exemplo n.º 14
0
void Process::setEnvironment(const ProcessEnvironment &e)
{
    QProcessEnvironment qpenv;
    for (ProcessEnvironment::const_iterator it = e.constBegin(); it != e.constEnd(); ++it)
        qpenv.insert(it.key().toQString(), it.value());
    QProcess::setProcessEnvironment(qpenv);
}
Exemplo n.º 15
0
/*
 * Pings google site, to make sure internet is OK
 */
bool UnixCommand::doInternetPingTest()
{
  QProcess ping;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  ping.setProcessEnvironment(env);
  ping.start("ping -c 1 -W 3 www.google.com");

  ping.waitForFinished();

  int res = ping.exitCode();
  ping.close();

  return (res == 0);
}
Exemplo n.º 16
0
void SvnWcModel::refresh()
{
    Q_ASSERT(0 == m->svnProcess);
    Q_ASSERT(0 == m->xmlInputSource);

    m->handler = new SvnInfoXmlHandler();

    m->xmlReader = new QXmlSimpleReader();
    m->xmlReader->setContentHandler(m->handler);

    QStringList args;
    args << "info" << "--recursive" << "--xml" << m->root;

    QProcessEnvironment processEnvironment = QProcessEnvironment::systemEnvironment();
    processEnvironment.insert("LANG", "C");

    m->svnProcess = new QProcess(this);
    m->svnProcess->setProcessEnvironment(processEnvironment);
    m->svnProcess->setReadChannel(QProcess::StandardOutput);

    m->xmlInputSource = new QXmlInputSource(m->svnProcess);
    m->xmlReader->parse(m->xmlInputSource, true);

    m->svnProcess->start("svn", args, QProcess::ReadOnly);
    m->svnProcess->waitForFinished();
}
Exemplo n.º 17
0
    QProcessEnvironment PamHandle::getEnv() {
        QProcessEnvironment env;
        // get pam environment
        char **envlist = pam_getenvlist(m_handle);
        if (envlist == NULL) {
            qWarning() << "[PAM] getEnv: Returned NULL";
            return env;
        }

        // copy it to the env map
        for (int i = 0; envlist[i] != nullptr; ++i) {
            QString s(envlist[i]);

            // find equal sign
            int index = s.indexOf('=');

            // add to the hash
            if (index != -1)
                env.insert(s.left(index), s.mid(index + 1));

            free(envlist[i]);
        }
        free(envlist);
        return env;
    }
Exemplo n.º 18
0
QStringList gpu::getGLXInfo(QString gpuName) const {
    QStringList data, gpus = globalStuff::grabSystemInfo("lspci").filter(QRegExp(".+VGA.+|.+3D.+"));
    gpus.removeAt(gpus.indexOf(QRegExp(".+Audio.+"))); //remove radeon audio device

    // loop for multi gpu
    for (int i = 0; i < gpus.count(); i++)
        data << "VGA:"+gpus[i].split(":",QString::SkipEmptyParts)[2];

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    if (!gpuName.isEmpty())
        env.insert("DRI_PRIME",gpuName.at(gpuName.length()-1));
    QStringList driver = globalStuff::grabSystemInfo("xdriinfo",env).filter("Screen 0:",Qt::CaseInsensitive);
    if (!driver.isEmpty())  // because of segfault when no xdriinfo
        data << "Driver:"+ driver.filter("Screen 0:",Qt::CaseInsensitive)[0].split(":",QString::SkipEmptyParts)[1];

    switch (currentDriver) {
    case XORG:
        data << dXorg::getGLXInfo(gpuName, env);
        break;
    case FGLRX:
        data << dFglrx::getGLXInfo();
        break;
    case DRIVER_UNKNOWN:
        break;
    }
    return data;
}
Exemplo n.º 19
0
void ProcessRunner::run()
{
  if (!process)
    process = new QProcess();
#ifdef WIN32
  QProcessEnvironment env = env.systemEnvironment();
  env.insert("CYGWIN", "nodosfilewarning");
  process->setProcessEnvironment(env);
#endif

  connect(process, SIGNAL(readyReadStandardError()), this, SLOT(updateError()), Qt::DirectConnection);
  connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()), Qt::DirectConnection);

  if(arguments)
    process->start(program, *arguments);
  else
    process->start(program);

  interact(process);
  process->waitForFinished(-1); // no timeout

  process->close();

  disconnect(process, SIGNAL(readyReadStandardError()), this, SLOT(updateError()));
  disconnect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()));
}
Exemplo n.º 20
0
    bool PamBackend::openSession() {
        if (!m_pam->setCred(PAM_ESTABLISH_CRED)) {
            m_app->error(m_pam->errorString(), Auth::ERROR_AUTHENTICATION);
            return false;
        }

        QProcessEnvironment sessionEnv = m_app->session()->processEnvironment();
        if (sessionEnv.value(QStringLiteral("XDG_SESSION_TYPE")) == QStringLiteral("x11")) {
            QString display = sessionEnv.value(QStringLiteral("DISPLAY"));
            if (!display.isEmpty()) {
#ifdef PAM_XDISPLAY
                m_pam->setItem(PAM_XDISPLAY, qPrintable(display));
#endif
                m_pam->setItem(PAM_TTY, qPrintable(display));
            }
        } else if (sessionEnv.value(QStringLiteral("XDG_SESSION_TYPE")) == QStringLiteral("wayland")) {
            QString tty = QStringLiteral("/dev/tty%1").arg(sessionEnv.value(QStringLiteral("XDG_VTNR")));
            m_pam->setItem(PAM_TTY, qPrintable(tty));
        }

        if (!m_pam->putEnv(sessionEnv)) {
            m_app->error(m_pam->errorString(), Auth::ERROR_INTERNAL);
            return false;
        }
        if (!m_pam->openSession()) {
            m_app->error(m_pam->errorString(), Auth::ERROR_INTERNAL);
            return false;
        }
        sessionEnv.insert(m_pam->getEnv());
        m_app->session()->setProcessEnvironment(sessionEnv);
        return Backend::openSession();
    }
Exemplo n.º 21
0
PluginProxy::PluginProxy(QString type, QObject *parent):
    QObject(parent)
{
    TRACE();

    m_type = type;
    m_isProcessing = false;
    m_isResultObtained = false;
    m_currentResultOperation = -1;
    m_process = new PluginProcess(this);

#ifdef SIGNOND_TRACE
    if (criticalsEnabled()) {
        const char *level = debugEnabled() ? "2" : "1";
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
        env.insert(QLatin1String("SSO_DEBUG"), QLatin1String(level));
        m_process->setProcessEnvironment(env);
    }
#endif

    connect(m_process, SIGNAL(readyReadStandardError()),
            this, SLOT(onReadStandardError()));

    /*
     * TODO: some error handling should be added here, at least remove of
     * current request data from the top of the queue and reply an error code
     */
    connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
            this, SLOT(onExit(int, QProcess::ExitStatus)));
    connect(m_process, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(onError(QProcess::ProcessError)));
}
Exemplo n.º 22
0
bool Program::start(const QString& path, const QStringList &arguments)
{
	if(path.isEmpty()) return false;
	stop();
	m_process = new QProcess(this);
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  const QString libPath = env.value("LD_LIBRARY_PATH");
  env.insert("LD_LIBRARY_PATH", (libPath.isEmpty() ? "" : libPath + ":")
    + SystemPrefix::ref().rootManager()->libDirectoryPaths().join(":"));
  m_process->setProcessEnvironment(env);
	m_process->setProcessChannelMode(QProcess::MergedChannels);
	connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), SIGNAL(finished(int, QProcess::ExitStatus)));
	connect(m_process, SIGNAL(readyRead()), SIGNAL(readyRead()));
	
	set_auto_publish(true);
	halt();
	set_auto_publish(false);
	
	m_process->start(path, arguments);
	if(!m_process->waitForStarted()) {
		delete m_process;
		m_process = 0;
		return false;
	}
	emit started();
	m_time.restart();
	return true;
}
Exemplo n.º 23
0
bool uwsgiProcess::run(const QString &appFilename, int port, bool restart)
{
    QDir projectDir;
    if (!uwsgiProcess::findProjectDir(QDir::current(), &projectDir)) {
        qDebug() << "Error: failed to find project";
        return false;
    }

    QString localFilename = appFilename;
    if (localFilename.isEmpty()) {
        localFilename = findApplication(projectDir);
    }

    QFileInfo fileInfo(localFilename);
    if (!fileInfo.exists()) {
        qDebug() << "Error: Application file not found";
        return false;
    }

    QStringList args;
    args.append(QStringLiteral("--http-socket"));
    args.append(QLatin1String(":") % QString::number(port));

    args.append(QStringLiteral("--chdir"));
    args.append(projectDir.absolutePath());

    args.append(QStringLiteral("-M"));

    args.append(QStringLiteral("--plugin"));
    args.append(QStringLiteral("cutelyst"));

    args.append(QStringLiteral("--cutelyst-app"));
    args.append(localFilename);

    if (restart) {
        args.append(QStringLiteral("--lazy"));
        args.append(QStringLiteral("--touch-reload"));
        args.append(localFilename);
    }

#ifdef Q_OS_UNIX
    if (setup_unix_signal_handlers()) {
        return false;
    }
#endif

    qDebug() << "Running: uwsgi" << args.join(QStringLiteral(" ")).toLatin1().data();

    // Enable loggin if restart is set
    if (restart && !qEnvironmentVariableIsSet("QT_LOGGING_RULES")) {
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
        env.insert(QStringLiteral("QT_LOGGING_RULES"), QStringLiteral("cutelyst.*=true"));
        m_proc->setProcessEnvironment(env);
    }

    m_proc->start(QStringLiteral("uwsgi"), args);

    return true;
}
Exemplo n.º 24
0
/*
 * Performs a pacman query
 */
QByteArray UnixCommand::performQuery(const QStringList args)
{
  QByteArray result("");
  QProcess pacman;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  env.insert("LC_ALL", "C");
  pacman.setProcessEnvironment(env);

  pacman.start("pkg", args);
  pacman.waitForFinished();
  result = pacman.readAllStandardOutput();
  pacman.close();

  return result;
}
Exemplo n.º 25
0
    bool Greeter::start() {
        // check flag
        if (m_started)
            return false;

        // create process
        process = new QProcess(this);

        // delete process on finish
        connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished()));

        // log message
        qDebug() << " DAEMON: Greeter starting...";

        // set process environment
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
        env.insert("DISPLAY", m_display);
        env.insert("XAUTHORITY", m_authPath);
        env.insert("XCURSOR_THEME", Configuration::instance()->cursorTheme());
        process->setProcessEnvironment(env);

#if !TEST
        // start greeter
        process->start(QString("%1/sddm-greeter").arg(BIN_INSTALL_DIR), { "--socket", m_socket, "--theme", m_theme });
#else
        // start greeter
        process->start(QString("%1/sddm-greeter").arg("."), { "--socket", m_socket, "--theme", m_theme });
#endif
        // wait for greeter to start
        if (!process->waitForStarted()) {
            // log message
            qCritical() << " DAEMON: Failed to start greeter.";

            // return fail
            return false;
        }

        // log message
        qDebug() << " DAEMON: Greeter started.";

        // set flag
        m_started = true;

        // return success
        return true;
    }
void tst_QProcessEnvironment::clearAndIsEmpty()
{
    QProcessEnvironment e;
    e.insert("FOO", "bar");
    QVERIFY(!e.isEmpty());
    e.clear();
    QVERIFY(e.isEmpty());
}
void tst_QProcessEnvironment::emptyNull()
{
    QProcessEnvironment e;

    e.insert("FOO", "");
    QVERIFY(e.contains("FOO"));
    QVERIFY(e.value("FOO").isEmpty());
    QVERIFY(!e.value("FOO").isNull());

    e.insert("FOO", QString());
    QVERIFY(e.contains("FOO"));
    QVERIFY(e.value("FOO").isEmpty());
    // don't test if it's NULL, since we shall not make a guarantee

    e.remove("FOO");
    QVERIFY(!e.contains("FOO"));
}
Exemplo n.º 28
0
RISE::RISE(QString *p)
{
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QDir pt(*p);
    pt.cdUp();
    backend.setWorkingDirectory(pt.path());
    env.insert("ROOTDIR", ".");
    env.insert("DOC_ROOT", "./site/static");
    QStringList args;
    QString vsn = "v", erts;
    QFile vsn_file(pt.path() + "/releases/start_erl.data");
    if (vsn_file.open(QFile::ReadOnly)) {
        QList <QByteArray> vdata = vsn_file.readLine().split(' ');
        erts = vdata.first().trimmed();
        vsn = vdata.last().trimmed();
    }
    path = *p;
    backend.setProcessEnvironment(env);



#ifdef Q_OS_WIN32
    args << "-args_file" << "./etc/vm.args";
    clog.setFileName(env.value("APPDATA") + "/RISE/log/erlang.log");
    if (clog.exists())
      clog.remove();
    clog.open(QFile::WriteOnly);
    backend.start(backend.workingDirectory() + "/erts-" + erts + "/bin/erl.exe", args );
#else
    clog.setFileName(env.value("HOME") + "/.config/RISE/log/erlang.log");
    if (clog.exists())
      clog.remove();
    clog.open(QFile::WriteOnly);
    args << "-args_file" << "./etc/vm.args";
    backend.start(backend.workingDirectory() + "/erts-" + erts + "/bin/erl", args );
#endif
    connect(&backend, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
    backend.waitForStarted(300000);
    backend.waitForReadyRead();
    //setAcceptHoverEvents(true);
    pWebPage = page();
    pWebPage->setForwardUnsupportedContent(true);
    setAcceptDrops(true);
    createActions();
    showMaximized();
}
Exemplo n.º 29
0
/*
 * Performs a yourt command
 */
QByteArray UnixCommand::performAURCommand(const QString &args)
{
  QByteArray result("");
  QProcess aur;

  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  aur.setProcessEnvironment(env);

  aur.start(StrConstants::getForeignRepositoryToolName() + " " + args);
  aur.waitForFinished(-1);
  result = aur.readAllStandardOutput();

  aur.close();
  return result;
}
Exemplo n.º 30
0
Terminal::Terminal(QObject *parent, const QString &selectedTerminal) : QObject(parent)
{
  m_process = new QProcess(parent);
  m_processWrapper = new utils::ProcessWrapper(parent);

  //Make the needed signal propagations...
  connect(m_process, SIGNAL(started()), this, SIGNAL(started()));
  connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SIGNAL(finished(int,QProcess::ExitStatus)));
  connect(m_processWrapper, SIGNAL(startedTerminal()), this, SIGNAL(startedTerminal()));
  connect(m_processWrapper, SIGNAL(finishedTerminal(int,QProcess::ExitStatus)),
          this, SIGNAL(finishedTerminal(int,QProcess::ExitStatus)));

  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  m_process->setProcessEnvironment(env);
  m_selectedTerminal = selectedTerminal;
}