/**
 * @brief KernelModel::getRunningKernel get running kernel in the system
 * @return string with the version of running kernel
 */
QString
KernelModel::getRunningKernel() const
{
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert( "LANG", "C" );
    env.insert( "LC_MESSAGES", "C" );
    env.insert( "LC_ALL", "C" );

    QProcess uname;
    uname.setProcessEnvironment( env );

    uname.start( "uname", QStringList() << "-r" );
    uname.waitForFinished();
    QString result = uname.readAllStandardOutput();
    uname.close();
    QStringList aux = result.split( ".", QString::SkipEmptyParts );
    return QString( "linux%1%2" ).arg( aux.at( 0 ) ).arg( aux.at( 1 ) );
}
예제 #2
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("pacman", args);
  pacman.waitForFinished();
  result = pacman.readAllStandardOutput();
  pacman.close();

  return result;
}
예제 #3
0
/*
 * Executes given command and returns the StandardError Output.
 */
QString UnixCommand::runCommand(const QString& commandToRun)
{
  QProcess proc;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.remove("LANG");
  env.remove("LC_MESSAGES");
  env.insert("LANG", "C");
  env.insert("LC_MESSAGES", "C");
  proc.setProcessEnvironment(env);
  proc.start(commandToRun);
  proc.waitForStarted();
  proc.waitForFinished(-1);

  QString res = proc.readAllStandardError();
  proc.close();

  return res;
}
예제 #4
0
파일: app.cpp 프로젝트: rygwdn/CopyQ
App::App(QCoreApplication *application, const QString &sessionName)
    : m_app(application)
    , m_exitCode(0)
    , m_closed(false)
{
    QString session("copyq");
    if ( !sessionName.isEmpty() ) {
        session += "-" + sessionName;
        m_app->setProperty( "CopyQ_session_name", QVariant(sessionName) );
    }

#ifdef HAS_TESTS
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    if ( env.value("COPYQ_TESTING") == "1" )
        session += ".test";
#endif

    QCoreApplication::setOrganizationName(session);
    QCoreApplication::setApplicationName(session);

    const QString locale = QLocale::system().name();
    QTranslator *translator = new QTranslator(m_app.data());
    translator->load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    QCoreApplication::installTranslator(translator);

    translator = new QTranslator(m_app.data());
    translator->load("copyq_" + locale, ":/translations");
    QCoreApplication::installTranslator(translator);

#ifdef Q_OS_UNIX
    // Safely quit application on TERM and HUP signals.
    struct sigaction sigact;

    sigact.sa_handler = ::exitSignalHandler;
    sigemptyset(&sigact.sa_mask);
    sigact.sa_flags = 0;
    sigact.sa_flags |= SA_RESTART;

    if ( sigaction(SIGHUP, &sigact, 0) > 0
         || sigaction(SIGINT, &sigact, 0) > 0
         || sigaction(SIGTERM, &sigact, 0) > 0 )
        log( QString("sigaction() failed!"), LogError );
#endif
}
예제 #5
0
void MainWindow::on_buttonBox_accepted() {
  writeSettings();

  QSettings settings(QSettings::IniFormat, QSettings::UserScope,
                     Organization, ProjectName);
  QString ocrCmd;

  if (settings.contains("OCR/program"))
    ocrCmd = settings.value("OCR/program").toString();

  // TODO(zdenop): check for missing setting or empty string

  QStringList args;

  QString in = ui->lineEditIn->text();
  args << in;
  QString out = ui->lineEditOut->text();
  out = out.replace(".txt", "").replace(".html", "");
  args << out;

  QString lang = ui->comboBoxLang->itemData(
                   ui->comboBoxLang->currentIndex()).toString();
  args << "-l" << lang;

  if (ui->comboBoxPSM->isEnabled()) {
    int PSM = ui->comboBoxPSM->currentIndex();
    args  << "-psm" << QString::number(PSM);
  }

  if (ui->comboBoxForm->currentIndex() == 1) {
    args << "hocr";
  }

  if (!settings.value("OCR/sys_prefix").toBool()) {
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TESSDATA_PREFIX", settings.value("OCR/prefix").toString());
    process.setProcessEnvironment(env);
    }

  ui->tb_Log->appendHtml(tr("OCR program started..."));
  ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
  process.start(ocrCmd, args);
}
예제 #6
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    // Try to get all of the env variables here
    QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();

    QStringList keys = environment.keys();

    QList<QObject*> dataList;

    foreach (QString key, keys) {
        qDebug() << "key: " << key;

        QString value = environment.value(key);
        qDebug() << "value: " << value;

        dataList.append(new DataObject(key, value));
    }
예제 #7
0
void QvkPulse::pulseUnloadModule()
{
  //qDebug( " " );
  qDebug() << "[vokoscreen] ---Begin Pulse unload Module---";
  QProcess Process;
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("LANG", "c");
  Process.setProcessEnvironment(env);
  Process.start( "pactl list" );
  Process.waitForFinished();
  QString output = Process.readAllStandardOutput();
  Process.close();
  
  QStringList list = output.split( "\n" );
  
  QStringList modulNumberList;
  QString str;
  QString strLog;
  for ( int i = 0; i < list.count(); i++ )
  {
     str = list[ i ];
     if ( str.contains("vokoscreenMix", Qt::CaseInsensitive) )
     {
       str = list[ i - 2 ];
       if ( str.contains("Module", Qt::CaseInsensitive) )
       {
	 str.replace("Module #", "");
	 str.replace("\n", "");
	 modulNumberList.insert ( 0, str );
       }
     }
  }
  
  for ( int i = 0; i < modulNumberList.count(); i++ )
  {
    Process.start("pactl unload-module " + modulNumberList[ i ] );
    Process.waitForFinished();
    Process.close();
    qDebug() << "[vokoscreen] pactl unload-module number" << modulNumberList[ i ] ;
  }
  qDebug() << "[vokoscreen] ---End Pulse unload Module---";
  qDebug( " " );
}
예제 #8
0
bool ProcessInjector::launchProcess(const QStringList& programAndArgs, const QProcessEnvironment& env)
{
    InteractiveProcess proc;
    proc.setProcessEnvironment(env);
    proc.setProcessChannelMode(QProcess::ForwardedChannels);

    QStringList args = programAndArgs;

    if (!env.value("GAMMARAY_TARGET_WRAPPER").isEmpty()) {
        const QString fullWrapperCmd = env.value("GAMMARAY_TARGET_WRAPPER");
        // ### TODO properly handle quoted arguments!
        QStringList newArgs = fullWrapperCmd.split(' ');
        newArgs += args;
        args = newArgs;
        qDebug() << "Launching with target wrapper:" << args;
    } else if (env.value("GAMMARAY_GDB").toInt()) {
        QStringList newArgs;
        newArgs << "gdb";
#ifndef Q_OS_MAC
        newArgs << "--eval-command" << "run";
#endif
        newArgs << "--args";
        newArgs += args;
        args = newArgs;
    }

    const QString program = args.takeFirst();
    proc.start(program, args);
    proc.waitForFinished(-1);

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

    if (mProcessError == QProcess::FailedToStart) {
        mErrorString.prepend(QString("Could not start '%1': ").arg(program));
    }

    return mExitCode == EXIT_SUCCESS && mExitStatus == QProcess::NormalExit
           && mProcessError == QProcess::UnknownError;
}
예제 #9
0
QProcessEnvironment CompositorLauncher::compositorEnv() const
{
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

    // Standard environment
//    env.insert(QStringLiteral("QT_QPA_PLATFORMTHEME"), QStringLiteral("Material"));
//    env.insert(QStringLiteral("QT_QUICK_CONTROLS_STYLE"), QStringLiteral("Material"));
//    env.insert(QStringLiteral("XCURSOR_THEME"), QStringLiteral("Adwaita"));
//    env.insert(QStringLiteral("XCURSOR_SIZE"), QStringLiteral("16"));
    env.insert(QStringLiteral("QSG_RENDER_LOOP"), QStringLiteral("windows"));

    // Specific environment
    switch (m_mode) {
    case EglFSMode:
        // General purpose distributions do not have the proper eglfs
        // integration and may want to build it out of tree, let them
        // specify a QPA plugin with an environment variable
        if (qEnvironmentVariableIsSet("U2T_QPA_PLATFORM"))
            env.insert(QStringLiteral("QT_QPA_PLATFORM"), qgetenv("U2T_QPA_PLATFORM"));
        else
            // FIXME this should not be eglfs and shold be xcb unless wayland
            env.insert(QStringLiteral("QT_QPA_PLATFORM"), QStringLiteral("eglfs"));

        switch (m_hardware) {
        case BroadcomHardware:
            env.insert(QStringLiteral("QT_QPA_EGLFS_INTEGRATION"), QStringLiteral("eglfs_brcm"));
            break;
        default:
            env.insert(QStringLiteral("QT_QPA_EGLFS_INTEGRATION"), QStringLiteral("eglfs_kms"));
            env.insert(QStringLiteral("QT_QPA_EGLFS_KMS_CONFIG"),
                       QStandardPaths::locate(QStandardPaths::GenericDataLocation,
                                              QStringLiteral("u2t-shell/eglfs/eglfs_kms.json")));
            break;
        }

        if (m_hasLibInputPlugin)
            env.insert(QStringLiteral("QT_QPA_EGLFS_DISABLE_INPUT"), QStringLiteral("1"));
        break;
    case X11Mode:
        env.insert(QStringLiteral("QT_XCB_GL_INTEGRATION"), QStringLiteral("xcb_egl"));
        break;
    default:
        break;
    }

    return env;
}
예제 #10
0
QString QInstaller::replaceWindowsEnvironmentVariables(const QString &str)
{
    const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString res;
    int pos = 0;
    while (true) {
        int pos1 = str.indexOf(QLatin1Char( '%'), pos);
        if (pos1 == -1)
            break;
        int pos2 = str.indexOf(QLatin1Char( '%'), pos1 + 1);
        if (pos2 == -1)
            break;
        res += str.mid(pos, pos1 - pos);
        QString name = str.mid(pos1 + 1, pos2 - pos1 - 1);
        res += env.value(name);
        pos = pos2 + 1;
    }
    res += str.mid(pos);
    return res;
}
예제 #11
0
bool MercurialClient::synchronousPull(const QString &workingDir, const QString &srcLocation, const QStringList &extraOptions)
{
    QStringList args;
    args << vcsCommandString(PullCommand) << extraOptions << srcLocation;
    // Disable UNIX terminals to suppress SSH prompting
    const unsigned flags =
            VcsCommand::SshPasswordPrompt
            | VcsCommand::ShowStdOut
            | VcsCommand::ShowSuccessMessage;

    // cause mercurial doesn`t understand LANG
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
    const SynchronousProcessResponse resp = VcsBasePlugin::runVcs(
                workingDir, vcsBinary(), args, vcsTimeoutS(), flags, nullptr, env);
    const bool ok = resp.result == SynchronousProcessResponse::Finished;

    parsePullOutput(resp.stdOut().trimmed());
    return ok;
}
예제 #12
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);

  if (UnixCommand::getLinuxDistro() == ectn_MOOOSLINUX)
    ping.start("torsocks ping -c 1 -W 3 www.google.com");
  else
    ping.start("ping -c 1 -W 3 www.google.com");

  ping.waitForFinished();

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

  return (res == 0);
}
// TODO: remove as much of this file as possible, as most of it isn't necessary
QScriptValue QProcessEnvironmenttoScriptValue(QScriptEngine *engine, const QProcessEnvironment &item)
{
  QScriptValue result = engine->newObject();
  QStringList env = item.toStringList();
  for (int i = 0; i < env.size(); i++)
  {
    QStringList line = env[i].split("=");
    result.setProperty(line[0], line[1]);
  }
  return result;
}
예제 #14
0
void GoplayBrowser::run()
{
    m_editor->saveAs(m_playFile);
    if (!m_editFile.isEmpty()) {
        m_editor->saveAs(m_editFile);
    }
    QProcessEnvironment env = LiteApi::getCurrentEnvironment(m_liteApp);
    QString go = FileUtil::lookPath("go",env,false);
    QStringList args;
    args << "run";
    args << "goplay.go";
    if (m_process->isRuning()) {
        m_process->kill();
    }
    m_output->clear();
    m_output->appendTag(QString("Run start ...\n\n"));
    m_process->setEnvironment(env.toStringList());

    m_process->start(go,args);
}
예제 #15
0
QStringList MenuItem::systemCMD(QString command){ 
   QProcess p;
   QString outstr;
   //Make sure we use the system environment to properly read system variables, etc.
   QProcessEnvironment penv = QProcessEnvironment::systemEnvironment();
   penv.insert("BLOCKSIZE","K"); //make sure we use a 1KB block size
   p.setProcessEnvironment(penv);
   //Merge the output channels to retrieve all output possible
   p.setProcessChannelMode(QProcess::MergedChannels);   
   p.start(command);
   while(p.state()==QProcess::Starting || p.state() == QProcess::Running){
     p.waitForFinished(200);
     QCoreApplication::processEvents();
   }
   QString tmp = p.readAllStandardOutput();
   outstr.append(tmp);
   if(outstr.endsWith("\n")){outstr.chop(1);} //remove the newline at the end 
   QStringList out = outstr.split("\n");
   return out;
}
예제 #16
0
void TgtProcessIntf::tgtMakeConnection()
{
    std::shared_ptr<const TgtConnectionConfig> connectionConfig = std::dynamic_pointer_cast<const TgtConnectionConfig>(
        _connectionConfig);
    _proc = new QProcess(this);
    connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
    connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()));
    connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processDone(int,QProcess::ExitStatus)));
    _proc->setWorkingDirectory(connectionConfig->_workingDir.c_str());
    QStringList args(connectionConfig->_args.c_str());

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TERM", "xterm");
    env.insert("COLORTERM", "gnome-terminal");
    _proc->setProcessEnvironment(env);

    _proc->start(connectionConfig->_program.c_str(), args);
    _processWriterThread = TgtThread::create(boost::protect(std::bind(&TgtProcessIntf::writerThread, this)));
}
예제 #17
0
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QString toolDir = QDir::current().absoluteFilePath(WINDOWS_YLE_DL_DIR).replace('/', '\\');
    QString newPath = toolDir + ";" + env.value("PATH");
    ::SetEnvironmentVariableA("PATH", newPath.toLocal8Bit());
#endif

    QApplication app(argc, argv);
    QApplication::setOrganizationName("nobody");
    QApplication::setApplicationName("yle-downloader-gui");

    QSettings settings;
    QVariant localeNameVar = settings.value("language", QVariant());
    QLocale locale;
    if (!localeNameVar.isValid()) {
        locale = QLocale::Finnish;
        settings.setValue("language", locale.name());
    } else {
        locale = QLocale(localeNameVar.toString());
    }

    setApplicationLanguage(&app, locale);

    MainWindow w;
    w.setWindowIcon(QIcon(":/icons/icon.ico"));
    w.setLocale(locale);
    if (QApplication::arguments().size() > 0 && looksLikeUrl(QApplication::arguments().last())) {
        w.setExitOnSuccess(true);
        w.setSaveAndRestoreSession(false);
        w.init();
        w.startDownloadFrom(QApplication::arguments().last());
    } else {
        w.setSaveAndRestoreSession(true);
        w.init();
    }
    w.show();

    return app.exec();
}
예제 #18
0
void WareSrcContainer::build()
{
  if (m_CMakeProgramPath.isEmpty())
    findCMake();

  mp_Stream->clear();
  m_Messages.clear();

  if (!QFile(m_BuildDirPath).exists())
  {
    configure();
    mp_Process->waitForFinished(-1);
  }


  QProcessEnvironment RunEnv = QProcessEnvironment::systemEnvironment();

  // Set PATH env. var. if configured
  QString CustomPath = openfluid::base::PreferencesManager::instance()->getWaresdevBuildEnv("PATH");
  if (!CustomPath.isEmpty())
  {
    QByteArray ExistingPath = qgetenv("PATH");
    if (!ExistingPath.isNull())
    {
      CustomPath.replace("%%PATH%%", ExistingPath);
      RunEnv.insert("PATH", CustomPath);
    }
  }


  delete mp_CurrentParser;
  mp_CurrentParser = new openfluid::waresdev::WareSrcMsgParserGcc();


  QString Command = QString("\"%1\" -E chdir \"%2\" \"%1\" --build . %3")
		                .arg(m_CMakeProgramPath)
		                .arg(m_BuildDirPath)
		                .arg(m_BuildMode == BuildMode::BUILD_WITHINSTALL ? "--target install" : "");

  runCommand(Command, RunEnv);
}
예제 #19
0
bool versionControl::isModelUnderMercurial() {

    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"));

    // 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()));

    mercurial->start("hg summary");

    bool noerror = mercurial->waitForFinished(1000);

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

    }
    return false;
}
예제 #20
0
bool LldbDebugger::start(KConfigGroup& config, const QStringList& extraArguments)
{
    // Get path to executable
    QUrl lldbUrl = config.readEntry(Config::LldbExecutableEntry, QUrl());
    if (!lldbUrl.isValid() || !lldbUrl.isLocalFile()) {
        debuggerBinary_ = "lldb-mi";
    } else {
        debuggerBinary_ = lldbUrl.toLocalFile();
    }

    if (!checkVersion()) {
        return false;
    }

    // Get arguments
    QStringList arguments = extraArguments;
    //arguments << "-quiet";
    arguments.append(KShell::splitArgs(config.readEntry(Config::LldbArgumentsEntry, QString())));

    // Get environment
    const EnvironmentGroupList egl(config.config());
    const auto &envs = egl.variables(config.readEntry(Config::LldbEnvironmentEntry, egl.defaultGroup()));
    QProcessEnvironment processEnv;
    if (config.readEntry(Config::LldbInheritSystemEnvEntry, true)) {
        processEnv = QProcessEnvironment::systemEnvironment();
    }
    for (auto it = envs.begin(), ite = envs.end(); it != ite; ++it) {
        processEnv.insert(it.key(), it.value());
    }

    // Start!
    process_->setProcessEnvironment(processEnv);
    process_->setProgram(debuggerBinary_, arguments);
    process_->start();

    qCDebug(DEBUGGERLLDB) << "Starting LLDB with command" << debuggerBinary_ + ' ' + arguments.join(' ');
    qCDebug(DEBUGGERLLDB) << "LLDB process pid:" << process_->pid();
    emit userCommandOutput(debuggerBinary_ + ' ' + arguments.join(' ') + '\n');

    return true;
}
예제 #21
0
    bool UserSession::start() {
        QProcessEnvironment env = qobject_cast<HelperApp*>(parent())->session()->processEnvironment();

        if (env.value(QStringLiteral("XDG_SESSION_CLASS")) == QStringLiteral("greeter")) {
            QProcess::start(m_path);
        } else if (env.value(QStringLiteral("XDG_SESSION_TYPE")) == QStringLiteral("x11")) {
            qDebug() << "Starting:" << mainConfig.XDisplay.SessionCommand.get()
                     << m_path;
            QProcess::start(mainConfig.XDisplay.SessionCommand.get(),
                            QStringList() << m_path);
        } else if (env.value(QStringLiteral("XDG_SESSION_TYPE")) == QStringLiteral("wayland")) {
            qDebug() << "Starting:" << mainConfig.WaylandDisplay.SessionCommand.get()
                     << m_path;
            QProcess::start(mainConfig.WaylandDisplay.SessionCommand.get(),
                            QStringList() << m_path);
        } else {
            qCritical() << "Unable to run user session: unknown session type";
        }

        return waitForStarted();
    }
예제 #22
0
//
// Slot to find if a specified program is available in the environment path
bool Settings::isProgramAvailable(const QString& prog_name)
{
	// get search paths
	QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  QStringList sl_dirs = env.value("PATH").split(':');
	
	// return false if there are no paths to search	
	if (sl_dirs.size() < 1) return false;
	
	// iterate over the search paths 
	for (int i = 0; i < sl_dirs.size(); ++i) { 
		QDirIterator dit(QString(sl_dirs.at(i) ), QDirIterator::Subdirectories);
		while (dit.hasNext()) {
			QFileInfo fi(dit.next());
			if (fi.completeBaseName() == prog_name) return true;
		}	// while
	}	// for

	// no found, return false
	return false;
}
static PyObject *meth_QProcessEnvironment_clear(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QProcessEnvironment *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QProcessEnvironment, &sipCpp))
        {
            sipCpp->clear();

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QProcessEnvironment, sipName_clear, doc_QProcessEnvironment_clear);

    return NULL;
}
void EnvironmentVariablesDialog::setProcessEnvironment(const QProcessEnvironment &environment)
{
    QStringList values = environment.toStringList();
    ui->valueViewer->setRowCount(values.size());
    for (int i = 0; i < values.size(); i ++) {
        int tmp = values[i].indexOf('=');
        QString variable = values[i].mid(0, tmp);
        QString value = values[i].mid(tmp + 1);
        ui->valueViewer->setItem(i, 0, new QTableWidgetItem(variable));
        ui->valueViewer->setItem(i, 1, new QTableWidgetItem(value));
    }
}
static PyObject *meth_QProcessEnvironment_insert(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QString* a0;
        int a0State = 0;
        const QString* a1;
        int a1State = 0;
        QProcessEnvironment *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1J1", &sipSelf, sipType_QProcessEnvironment, &sipCpp, sipType_QString,&a0, &a0State, sipType_QString,&a1, &a1State))
        {
            sipCpp->insert(*a0,*a1);
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);
            sipReleaseType(const_cast<QString *>(a1),sipType_QString,a1State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        const QProcessEnvironment* a0;
        QProcessEnvironment *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QProcessEnvironment, &sipCpp, sipType_QProcessEnvironment, &a0))
        {
            sipCpp->insert(*a0);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QProcessEnvironment, sipName_insert, doc_QProcessEnvironment_insert);

    return NULL;
}
예제 #26
0
파일: PamBackend.cpp 프로젝트: hykwok/sddm
    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();
    }
void OMIProxy::startInteractiveSimulation(QString file)
{
  QStringList parameters;
  parameters << QString("-interactive");
  // if platform is win32 add .exe to the file
  QString init_file(file.split("/").last());
#ifdef WIN32
  file = file.append(".exe");
#endif
  QFileInfo fileInfo(file);
  // start the process
  mpSimulationProcess = new QProcess();
#ifdef WIN32
  QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
  environment.insert("PATH", environment.value("Path") + ";" + QString(Helper::OpenModelicaHome).append("MinGW\\bin"));
  mpSimulationProcess->setProcessEnvironment(environment);
#endif
  mpSimulationProcess->setWorkingDirectory(fileInfo.absolutePath());
  connect(mpSimulationProcess, SIGNAL(readyReadStandardOutput()), SLOT(readProcessStandardOutput()));
  connect(mpSimulationProcess, SIGNAL(readyReadStandardError()), SLOT(readProcessStandardError()));
  mpSimulationProcess->start(file, parameters);
  mpSimulationProcess->waitForStarted();
  // start the client control server
  QString omiNetworkAddress = "127.0.0.1";
  mpControlServer = new OMIServer(OMIServer::CONTROLSERVER, this);
  mpControlServer->listen(QHostAddress(omiNetworkAddress), 10500);
  connect(mpControlServer, SIGNAL(recievedMessage(QString)), SLOT(readControlServerMessage(QString)));
  // start the transfer control server
  mpTransferServer = new OMIServer(OMIServer::TRANSFERSERVER, this);
  mpTransferServer->listen(QHostAddress(omiNetworkAddress), 10502);
  // create the control client socket and make signals slots connections
  mpControlClientSocket = new QTcpSocket(this);
  connect(mpControlClientSocket, SIGNAL(connected()), SLOT(controlClientConnected()));
  connect(mpControlClientSocket, SIGNAL(disconnected()), SLOT(controlClientDisConnected()));
  connect(mpControlClientSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(getSocketError(QAbstractSocket::SocketError)));
  connect(mpTransferServer, SIGNAL(recievedMessage(QString)), SLOT(readTransferServerMessage(QString)));
  // connect to omi control server
  mpControlClientSocket->connectToHost(QHostAddress(omiNetworkAddress), 10501);
  emit interactiveSimulationStarted(init_file.append("_init.xml"));
}
예제 #28
0
void mainWin::startPkgProcess() {

  if ( pkgCmdList.isEmpty() )
    return;
  if ( pkgCmdList.at(0).at(0).isEmpty() )
     return; 

  // Get the command name
  QString cmd;
  cmd = pkgCmdList.at(0).at(0);

  // Get any optional flags
  QStringList flags;
  for (int i = 0; i < pkgCmdList.at(0).size(); ++i) {
     if ( i == 0 )
       continue;
     flags << pkgCmdList.at(0).at(i);
  } 

  qDebug() << cmd + " " + flags.join(" ");
  
  // Setup the first process
  uProc = new QProcess();
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  env.insert("PCFETCHGUI", "YES");
  uProc->setProcessEnvironment(env);
  uProc->setProcessChannelMode(QProcess::MergedChannels);

  // Connect the slots
  connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadPkgOutput()) );
  connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPkgDone()) );

  uProc->start(cmd, flags);

  stackedTop->setCurrentIndex(1);

  progressUpdate->setRange(0, 0 );
  progressUpdate->setValue(0);

}
예제 #29
0
Preferences::Preferences( QObject * parent )
  : QObject( parent )
  , m_environmentEnabled( true )
  , m_normalsLineLength( 1.f )
  , m_transparencyMode( static_cast<unsigned int>(dp::sg::renderer::rix::gl::TransparencyMode::ORDER_INDEPENDENT_ALL) )
{
  load();

  QProcessEnvironment pe = QProcessEnvironment::systemEnvironment();
  QString home = pe.contains( "DPHOME" ) ? pe.value( "DPHOME" ) : QString( "." );

  // Add the DPHOME media folders if m_searchPath is empty
  // which is the case on the very first program run.
  // Different paths can be added inside the Preferences Dialog.
  if ( !m_searchPaths.count() )
  {
    m_searchPaths.append( home + QString( "/media/dpfx" ) );
    m_searchPaths.append( home + QString("/media/effects") );
    m_searchPaths.append( home + QString("/media/effects/xml") );
    m_searchPaths.append( home + QString("/media/textures") );
    m_searchPaths.append( home + QString("/media/textures/maxbench") );
  }

  if ( m_environmentTextureName.isEmpty() )
  {
    m_environmentTextureName = home + "/media/textures/spheremaps/spherical_checker.png";
  }
  if ( m_materialCatalogPath.isEmpty() )
  {
    m_materialCatalogPath = home + "/media/effects";
  }
  if ( m_sceneSelectionPath.isEmpty() )
  {
    m_sceneSelectionPath = home + QString( "/media/scenes" );
  }
  if ( m_textureSelectionPath.isEmpty() )
  {
    m_textureSelectionPath = home + QString( "/media/textures" );
  }
}
예제 #30
0
bool BlastSearch::findProgram(QString programName, QString * command)
{
    QString findCommand = "which " + programName;
#ifdef Q_OS_WIN32
    findCommand = "WHERE " + programName;
#endif

    QProcess find;

    //On Mac, it's necessary to do some stuff with the PATH variable in order
    //for which to work.
#ifdef Q_OS_MAC
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    QStringList envlist = env.toStringList();

    //Add some paths to the process environment
    envlist.replaceInStrings(QRegularExpression("^(?i)PATH=(.*)"), "PATH="
                                                                   "/usr/bin:"
                                                                   "/bin:"
                                                                   "/usr/sbin:"
                                                                   "/sbin:"
                                                                   "/opt/local/bin:"
                                                                   "/usr/local/bin:"
                                                                   "$HOME/bin:"
                                                                   "/usr/local/ncbi/blast/bin:"
                                                                   "\\1");

    find.setEnvironment(envlist);
#endif

    find.start(findCommand);
    find.waitForFinished();

    //On a Mac, we need to use the full path to the program.
#ifdef Q_OS_MAC
    *command = QString(find.readAll()).simplified();
#endif

    return (find.exitCode() == 0);
}