本文整理汇总了C++中QProcessEnvironment::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcessEnvironment::remove方法的具体用法?C++ QProcessEnvironment::remove怎么用?C++ QProcessEnvironment::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcessEnvironment
的用法示例。
在下文中一共展示了QProcessEnvironment::remove方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chain
void QNetCtlTool::chain()
{
QProcess *proc = static_cast<QProcess*>(sender());
const QString tag = proc->property("QNetCtlTag").toString();
const QString info = proc->property("QNetCtlInfo").toString();
if (proc->exitStatus() != QProcess::NormalExit || proc->exitCode()) {
myClient->call(QDBus::NoBlock, "reply", tag, QString("ERROR: %1, %2").arg(proc->exitStatus()).arg(proc->exitCode()));
return;
}
myClient->call(QDBus::NoBlock, "reply", tag, QString::fromLocal8Bit(proc->readAllStandardOutput()));
QString cmd;
if (tag == "remove_profile") {
QFile::remove(gs_profilePath + info);
} else if (tag == "scan_wifi") {
myScanningDevices.removeAll(info);
myUplinkingDevices.removeAll(info);
cmd = TOOL(ip) + " link set " + info + " down";
}
if (cmd.isNull()) // should not happen
return;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("LC_ALL");
env.remove("LANG");
proc = new QProcess(this);
proc->setProcessEnvironment(env);
// proc->setProperty("QNetCtlTag", tag);
// connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(reply()));
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
proc->start(cmd, QIODevice::ReadOnly);
}
示例2: scanWifi
void QNetCtlTool::scanWifi(QString device)
{
if (device.isNull() && sender())
device = sender()->property("QNetCtlScanDevice").toString();
if (myScanningDevices.contains(device))
return;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("LC_ALL");
env.remove("LANG");
QProcess *proc = new QProcess(this);
proc->setProcessEnvironment(env);
bool isDown = false;
proc->start(TOOL(ip) + " link show " + device, QIODevice::ReadOnly);
proc->waitForFinished();
if (proc->exitStatus() == QProcess::NormalExit && !proc->exitCode())
isDown = !QString::fromLocal8Bit(proc->readAllStandardOutput()).section('>', 0, 0).contains("UP");
bool waitsForUp = myUplinkingDevices.contains(device);
if (isDown) {
if (!waitsForUp) {
waitsForUp = true;
myUplinkingDevices << device;
proc->start(TOOL(ip) + " link set " + device + " up", QIODevice::ReadOnly);
proc->waitForFinished();
}
// we're waiting for the device to come up
delete proc;
QTimer *t = new QTimer(this);
t->setProperty("QNetCtlScanDevice", device);
t->setSingleShot(true);
connect(t, SIGNAL(timeout()), this, SLOT(scanWifi()));
connect(t, SIGNAL(timeout()), t, SLOT(deleteLater()));
t->start(500);
return;
}
myScanningDevices << device;
proc->setProperty("QNetCtlTag", "scan_wifi");
proc->setProperty("QNetCtlInfo", device);
// if we set it up, we've to set it back down through the chain slot
connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), waitsForUp ? SLOT(chain()) : SLOT(reply()));
connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
proc->start(TOOL(iw) + " dev " + device + " scan");
}
示例3: runCommand
/*
* 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: lamexp_init_process
/*
* 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);
}
示例5: QObject
/*
* The needed constructor
*/
utils::ProcessWrapper::ProcessWrapper(QObject *parent) :
QObject(parent)
{
m_process = new QProcess(parent);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
//env.insert("LANG", "C");
//env.insert("LC_MESSAGES", "C");
env.remove("LANG");
env.remove("LC_MESSAGES");
env.insert("LANG", QLocale::system().name() + ".UTF-8");
env.insert("LC_MESSAGES", QLocale::system().name() + ".UTF-8");
m_process->setProcessEnvironment(env);
m_timerSingleShot = new QTimer(parent);
m_timerSingleShot->setSingleShot(true);
m_timer = new QTimer(parent);
m_timer->setInterval(1000);
connect(m_timerSingleShot, SIGNAL(timeout()), this, SLOT(onSingleShot()));
connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimer()));
connect(m_process, SIGNAL(started()), SLOT(onProcessStarted()));
}
示例6: insert
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"));
}
示例7: emptyNull
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"));
}
示例8: performQuery
/*
* Performs a pacman query
* Overloaded with QString parameter
*/
QByteArray UnixCommand::performQuery(const QString &args)
{
QByteArray result("");
QProcess pacman;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("COLUMNS");
env.insert("COLUMNS", "170");
env.insert("LANG", "C");
env.insert("LC_MESSAGES", "C");
env.insert("LC_ALL", "C");
pacman.setProcessEnvironment(env);
pacman.start("xbps-" + args);
pacman.waitForFinished();
result = pacman.readAllStandardOutput();
pacman.close();
return result;
}
示例9: sipReleaseType
static PyObject *meth_QProcessEnvironment_remove(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
const QString* a0;
int a0State = 0;
QProcessEnvironment *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QProcessEnvironment, &sipCpp, sipType_QString,&a0, &a0State))
{
sipCpp->remove(*a0);
sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QProcessEnvironment, sipName_remove, doc_QProcessEnvironment_remove);
return NULL;
}
示例10: runCommandInTerminal
/*
* Executes the given command list with root credentials
*/
void Terminal::runCommandInTerminal(const QStringList &commandList)
{
QFile *ftemp = UnixCommand::getTemporaryFile();
QTextStream out(ftemp);
foreach(QString line, commandList)
out << line;
out.flush();
ftemp->close();
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("LANG");
env.remove("LC_MESSAGES");
env.insert("LANG", QLocale::system().name() + ".UTF-8");
env.insert("LC_MESSAGES", QLocale::system().name() + ".UTF-8");
m_process->setProcessEnvironment(env);
QString suCommand = WMHelper::getSUCommand();
if (m_selectedTerminal == ctn_AUTOMATIC)
{
if (UnixCommand::getLinuxDistro() == ectn_MOOOSLINUX && UnixCommand::hasTheExecutable(ctn_RXVT_TERMINAL))
{
QString cmd =
suCommand + " \"" + ctn_RXVT_TERMINAL + " -title pacman -name pacman -e bash -c " + ftemp->fileName() + "\"";
m_process->start(cmd);
}
else if(WMHelper::isXFCERunning() && UnixCommand::hasTheExecutable(ctn_XFCE_TERMINAL)){
QString cmd = suCommand + " \"" + ctn_XFCE_TERMINAL + " -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
else if (WMHelper::isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_TERMINAL)){
QString cmd;
if (UnixCommand::isRootRunning())
{
cmd = "dbus-launch " + ctn_KDE_TERMINAL + " --nofork -e bash -c " + ftemp->fileName();
}
else
{
cmd = suCommand + " \"" + ctn_KDE_TERMINAL + " --nofork -e bash -c " + ftemp->fileName() + "\"";
}
m_process->start(cmd);
}
else if (WMHelper::isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_TERMINAL)){
QString cmd = suCommand + " \"" + ctn_TDE_TERMINAL + " --nofork -e bash -c " + ftemp->fileName() + "\"";
m_process->start(cmd);
}
else if (WMHelper::isLXDERunning() && UnixCommand::hasTheExecutable(ctn_LXDE_TERMINAL)){
QString cmd = suCommand + " \"" + ctn_LXDE_TERMINAL + " -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
else if (WMHelper::isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_TERMINAL)){
QString cmd = suCommand + " \"" + ctn_MATE_TERMINAL + " -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
else if (WMHelper::isLXQTRunning() && UnixCommand::hasTheExecutable(ctn_LXQT_TERMINAL)){
QString cmd = suCommand + " \"" + ctn_LXQT_TERMINAL + " -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
else if (UnixCommand::hasTheExecutable(ctn_XFCE_TERMINAL)){
QString cmd = suCommand + " \"" + ctn_XFCE_TERMINAL + " -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
else if (UnixCommand::hasTheExecutable(ctn_LXDE_TERMINAL)){
QString cmd = suCommand + " \"" + ctn_LXDE_TERMINAL + " -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
else if (UnixCommand::hasTheExecutable(ctn_XTERM)){
QString cmd = suCommand + " \"" + ctn_XTERM +
" -fn \"*-fixed-*-*-*-18-*\" -fg White -bg Black -title xterm -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
}
else //User has chosen his own terminal...
{
if (m_selectedTerminal == ctn_RXVT_TERMINAL)
{
QString cmd =
suCommand + " \"" + ctn_RXVT_TERMINAL + " -title pacman -name pacman -e bash -c " + ftemp->fileName() + "\"";
m_process->start(cmd);
}
else if(m_selectedTerminal == ctn_XFCE_TERMINAL){
QString cmd = suCommand + " \"" + ctn_XFCE_TERMINAL + " -e \'bash -c " + ftemp->fileName() + "'\"";
m_process->start(cmd);
}
else if (m_selectedTerminal == ctn_KDE_TERMINAL){
QString cmd;
if (UnixCommand::isRootRunning())
{
cmd = "dbus-launch " + ctn_KDE_TERMINAL + " --nofork -e bash -c " + ftemp->fileName();
}
//.........这里部分代码省略.........
示例11: request
void QNetCtlTool::request(const QString tag, const QString information)
{
QString cmd;
bool chain = false;
// debug(tag + information);
if (tag == "switch_to_profile") {
cmd = TOOL(netctl) + " switch-to " + information;
} else if (tag == "stop_profile") {
cmd = TOOL(netctl) + " stop " + information;
} else if (tag == "scan_wifi") {
scanWifi(information);
return;
} else if (tag == "enable_profile") {
cmd = TOOL(netctl) + " enable " + information;
} else if (tag == "enable_service") {
if (information.startsWith("netctl-"))
cmd = TOOL(systemctl) + " enable " + information;
}
else if (tag == "disable_profile") {
cmd = TOOL(netctl) + " disable " + information;
} else if (tag == "disable_service") {
if (information.startsWith("netctl-"))
cmd = TOOL(systemctl) + " disable " + information;
} else if (tag == "remove_profile") {
chain = true;
cmd = TOOL(netctl) + " disable " + information;
} else if (tag.startsWith("write_profile")) {
QString name = tag.section(' ', 1);
QFile file(gs_profilePath + name);
if (file.open(QIODevice::WriteOnly|QIODevice::Text)) {
file.write(information.toLocal8Bit());
file.close();
myClient->call(QDBus::NoBlock, "reply", tag, "SUCCESS");
} else {
myClient->call(QDBus::NoBlock, "reply", tag, "ERROR");
}
return; // no process to run
} else if (tag == "reparse_config") {
return;
} else if (tag == "quit") {
quit();
return;
}
if (cmd.isNull()) {
myClient->call(QDBus::NoBlock, "reply", tag, "ERROR: unsupported command / request:" + information);
return;
}
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("LC_ALL");
env.remove("LANG");
QProcess *proc = new QProcess(this);
proc->setProcessEnvironment(env);
proc->setProperty("QNetCtlTag", tag);
if (chain) {
proc->setProperty("QNetCtlInfo", information);
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(chain()));
} else {
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(reply()));
}
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
// debug(cmd);
proc->start(cmd, QIODevice::ReadOnly);
}