コード例 #1
0
void tst_QProcessEnvironment::keys()
{
    QProcessEnvironment e;
    QVERIFY(e.isEmpty());
    QVERIFY(e.keys().isEmpty());

    e.insert("FOO", "bar");
    QStringList result = e.keys();
    QCOMPARE(result.length(), 1);
    QCOMPARE(result.at(0), QString("FOO"));

    e.clear();
    e.insert("BAZ", "");
    result = e.keys();
    QCOMPARE(result.at(0), QString("BAZ"));

    e.insert("FOO", "bar");
    e.insert("A", "bc");
    e.insert("HELLO", "World");
    result = e.keys();
    QCOMPARE(result.length(), 4);

    // order is not specified, so use contains()
    QVERIFY(result.contains("FOO"));
    QVERIFY(result.contains("BAZ"));
    QVERIFY(result.contains("A"));
    QVERIFY(result.contains("HELLO"));
}
コード例 #2
0
ファイル: msvcprobe.cpp プロジェクト: AtlantisCD9/Qt
QT_END_NAMESPACE

static void writeEnvironment(Profile &p, const QProcessEnvironment &env)
{
    foreach (const QString &name, env.keys())
        p.setValue(QLatin1String("buildEnvironment.") + name, env.value(name));
}
コード例 #3
0
ProcessEnvironment Process::environment() const
{
    ProcessEnvironment env;
    const QProcessEnvironment qpenv = QProcess::processEnvironment();
    foreach (const QString &key, qpenv.keys())
        env.insert(key, qpenv.value(key));
    return env;
}
コード例 #4
0
void PokySDKKitInformation::addToEnvironment(const Kit *kit, Environment &env) const
{
    FileName pokyEnvFile = environmentFile(kit);
    if (pokyEnvFile.isEmpty())
        return;
    PokyRunner runner(pokyEnvFile.toString());
    QProcessEnvironment pokyEnv = runner.processEnvironment();
    foreach (QString key, pokyEnv.keys())
        env.set(key, pokyEnv.value(key));
}
コード例 #5
0
ファイル: TtyProcess.cpp プロジェクト: HenryHu/lumina
// === PUBLIC ===
bool TTYProcess::startTTY(QString prog, QStringList args, QString workdir){
  if(workdir=="~"){ workdir = QDir::homePath(); }
  QDir::setCurrent(workdir);
  QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  setenv("TERM","vt100",1); //vt100: VT100 emulation support
  unsetenv("TERMCAP");
  /*setenv("TERMCAP","mvterm|vv100|mvterm emulator with ANSI colors:\
	:pa#64:Co#8:AF=\E[3%dm:AB=\E[4%dm:op=\E[100m:tc=vt102:",1); //see /etc/termcap as well*/
  QStringList filter = env.keys().filter("XTERM");
  for(int i=0; i<filter.length(); i++){ unsetenv(filter[i].toLocal8Bit().data()); }
  //if(env.contains("TERM")){ unsetenv("TERM"); }
  //else if(env.contains
  //Turn the program/arguments into C-compatible arrays
  char cprog[prog.length()]; strcpy(cprog, prog.toLocal8Bit().data());
  char *cargs[args.length()+2];
  QByteArray nullarray;
  for(int i=0; i<args.length()+2; i++){
    // First arg needs to be the program
    if ( i == 0 ) {
      cargs[i] = new char[ prog.toLocal8Bit().size()+1];
      strcpy( cargs[i], prog.toLocal8Bit().data() );
    } else if(i<args.length()){
      cargs[i] = new char[ args[i].toLocal8Bit().size()+1];
      strcpy( cargs[i], args[i].toLocal8Bit().data() );
    }else{
      cargs[i] = NULL;
    }
  }
  qDebug() << "PTY Start:" << prog;
  //Launch the process attached to a new PTY
  int FD = 0;
  pid_t tmp = LaunchProcess(FD, cprog, cargs);
  qDebug() << " - PID:" << tmp;
  qDebug() << " - FD:" << FD;
  if(tmp<0){ return false; } //error
  else{
    childProc = tmp;
    //Load the file for close notifications
      //TO-DO
    //Watch the socket for activity
    sn= new QSocketNotifier(FD, QSocketNotifier::Read);
	sn->setEnabled(true);
	connect(sn, SIGNAL(activated(int)), this, SLOT(checkStatus(int)) );
    ttyfd = FD;
    qDebug() << " - PTY:" << ptsname(FD);
    return true;
  }
}
コード例 #6
0
ファイル: main.cpp プロジェクト: UbuntuChina/runtime
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 tst_QProcessEnvironment::insertEnv()
{
    QProcessEnvironment e;
    e.insert("FOO", "bar");
    e.insert("A", "bc");
    e.insert("Hello", "World");

    QProcessEnvironment e2;
    e2.insert("FOO2", "bar2");
    e2.insert("A2", "bc2");
    e2.insert("Hello", "Another World");

    e.insert(e2);
    QStringList keys = e.keys();
    QCOMPARE(keys.length(), 5);

    QCOMPARE(e.value("FOO"), QString("bar"));
    QCOMPARE(e.value("A"), QString("bc"));
    QCOMPARE(e.value("Hello"), QString("Another World"));
    QCOMPARE(e.value("FOO2"), QString("bar2"));
    QCOMPARE(e.value("A2"), QString("bc2"));
}
コード例 #8
0
            {
                //qDebug() << "Dir:" << path << "does not exist. Skipping.";
                continue;
            }
            name = QStandardPaths::displayName(i);

            path.replace(" ", "\\ ");
            cmd = "cd " + path;

            addChild(new BookmarkCommandItem(name, cmd, this));
        }
#endif

        // system env - include dirs in the tree
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
        foreach (QString i, env.keys())
        {
            path = env.value(i);
            if (!d.exists(path) || !QFileInfo(path).isDir())
            {
                //qDebug() << "Env Dir:" << path << "does not exist. Skipping.";
                continue;
            }
            path.replace(" ", "\\ ");
            cmd = "cd " + path;
            addChild(new BookmarkCommandItem(i, cmd, this));
        }
    }
};

class BookmarkFileGroupItem : public BookmarkGroupItem