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")); }
bool Packages::install(QStringList const &packages, QString const &chroot) { info.currentPkg=tr("Determining installation order"); // cout << "determining installation order" << endl; QString cmdline; FILE *f=fopen("/proc/cmdline", "r"); if(f) { char buf[1024]; fgets(buf, 1024, f); fclose(f); cmdline=buf; } info.progress=0; info.totalprogress=0; totalpackages=packages.count(); package=0; rpm=new QProcess(this); QStringList args; args << "/bin/rpm" << "-iv"; if(cmdline.contains("nodeps")) args << "--nodeps" ; if(cmdline.contains("force")) args << "--force"; #ifdef TEXTONLY args << "--excludedocs" << "--excludepath" << "/usr/share/info" << "--excludepath" << "/usr/share/man" << "--excludepath" << "/usr/share/doc" << "--excludepath" << "/usr/docs" #endif args << "--percent"; if(!chroot.isEmpty()) args << "-r" << chroot; foreach(QString const &pkg, packages) args << pkg; connect(rpm, SIGNAL(processExited()), this, SLOT(rpmDone())); connect(rpm, SIGNAL(readyReadStdout()), this, SLOT(dataStdout())); connect(rpm, SIGNAL(readyReadStderr()), this, SLOT(dataStderr())); emit progress(&info); QProcessEnvironment rpmEnv; rpmEnv.clear(); rpmEnv.insert("PATH", "/bin:/usr/bin:/sbin:/usr/sbin:" + chroot + "/bin:" + chroot + "/usr/bin:" + chroot + "/sbin:" + chroot + "/usr/sbin"); rpmEnv.insert("HOME", "/tmp"); rpmEnv.insert("USER", "root"); rpmEnv.insert("USERNAME", "root"); rpm->setProcessEnvironment(rpmEnv); rpm->start("/bin/rpm", args); _io = new QTextStream(rpm); return true; }
void tst_QProcessEnvironment::clearAndIsEmpty() { QProcessEnvironment e; e.insert("FOO", "bar"); QVERIFY(!e.isEmpty()); e.clear(); QVERIFY(e.isEmpty()); }
void tst_QProcessEnvironment::insert() { QProcessEnvironment e; e.insert("FOO", "bar"); QVERIFY(!e.isEmpty()); QVERIFY(e.contains("FOO")); QCOMPARE(e.value("FOO"), QString("bar")); e.remove("FOO"); QVERIFY(!e.contains("FOO")); QVERIFY(e.value("FOO").isNull()); e.clear(); QVERIFY(!e.contains("FOO")); }
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; }