当前位置: 首页>>代码示例>>C++>>正文


C++ QProcess::atEnd方法代码示例

本文整理汇总了C++中QProcess::atEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::atEnd方法的具体用法?C++ QProcess::atEnd怎么用?C++ QProcess::atEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QProcess的用法示例。


在下文中一共展示了QProcess::atEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_net_usage__

bool resource_minitor::get_net_usage__()
{
    QProcess process;
    process.start("cat /proc/net/dev");        //读取文件/proc/net/dev获取网络收发包数量,再除取样时间得到网络速度
    process.waitForFinished();
    process.readLine();
    process.readLine();
    while(!process.atEnd())
    {
        QString str = process.readLine();
        str.replace("\n","");
        str.replace(QRegExp("( ){1,}")," ");
        auto lst = str.split(" ");
        if(lst.size() > 9 && lst[0] == "enp2s0:")
        {
            double recv = 0;
            double send = 0;
            if(lst.size() > 1)
                recv = lst[1].toDouble();
            if(lst.size() > 9)
                send = lst[9].toDouble();
            qDebug("%s  接收速度:%.0lfbyte/s 发送速度:%.0lfbyte/s",lst[0].toStdString().c_str(),(recv - m_recv_bytes__) / (m_timer_interval__ / 1000.0),(send - m_send_bytes__) / (m_timer_interval__ / 1000.0));
            m_recv_bytes__ = recv;
            m_send_bytes__ = send;
        }
    }
    return true;
}
开发者ID:yangyang0312,项目名称:C-,代码行数:28,代码来源:resource_minitor.cpp

示例2: parseHelperProg

void MemSpecParser::parseHelperProg(MemSpecs* specs)
{
    QProcess proc;
    proc.setWorkingDirectory(_buildDir);

    // Invoke the command
    QString cmd = "./memspec";

    proc.start(cmd);
    proc.waitForFinished(-1);

    if (proc.exitStatus() || proc.exitCode() != 0) {
        _errorOutput = proc.readAllStandardError();
        memSpecParserError(
                QString("Command failed with exit code %2 and exit status \"%3\": %1")
                    .arg(cmd)
                    .arg(proc.exitCode())
                    .arg((proc.exitStatus()) ? "crashed" : "normal"));
    }

    const int bufsize = 1024;
    char buf[1024];

    QRegExp re("^\\s*([^\\s]+)\\s*=\\s*(.*)$");
    while (!proc.atEnd() && proc.readLine(buf, bufsize) > 0) {
        if (re.exactMatch(buf))
            // Update the given MemSpecs object with the parsed key-value pair
            specs->setFromKeyValue(re.cap(1), re.cap(2).trimmed());
    }
}
开发者ID:wxdublin,项目名称:insight-vmi,代码行数:30,代码来源:memspecparser.cpp

示例3: atEnd

bool QProcessProto::atEnd() const
{
  QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
  if (item)
    return item->atEnd();
  return false;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: init

void imageio::init()
{
    if(isInitialized)return;
    QProcess im;
    im.start("identify", QStringList() << "-list" << "format");
    im.waitForFinished();
    formats.clear();

    while(!im.atEnd())
    {
        QString line = im.readLine().trimmed();
        //      3FR  r--   Hasselblad CFV/H3D39II
        line.replace("   "," ");
        line.replace("  " ," ");
        //3FR r-- Hasselblad CFV/H3D39II
        QString word1 = line.mid(0, line.indexOf(" "));
        QString word2 = line.mid(word1.length()+1, 3);
        QString desc = line.mid(word1.length()+word2.length()+2);
        bool nbs = word1.contains("*");
        word1.replace("*","");

        // At this stage we can check is this a valid file format description.
        // Word2 must only be in form of [r-][w-][+-].
        bool valid = true, write, read, multi;
        if(word2[0]=='r')read=true;
        else if(word2[0]=='-')read=false;
        else valid=false;
        if(word2[1]=='w')write=true;
        else if(word2[0]=='-')write=false;
        else valid=false;
        if(word2[2]=='+')multi=true;
        else if(word2[2]=='-')multi=false;
        else valid=false;

        if(valid)
        {
            imageFormat* f = new imageFormat;
            f->description = desc;
            f->format = word1;
            f->read = read;
            f->write = write;
            f->multi = multi;
            f->nativeblob = nbs;
            if(desc.toLower().contains("video")) f->warnForHugeData = true;

            //Settings:
            if(f->format=="PDF")f->additionalArgs << "-density" << "1000";

            //Exclusions: TXT files won't be added to the list at all!
            if(f->format!="TXT")
            formats << f;

            QString fDesc = f->format.rightJustified(10,' ',true)+ " "+(f->read?"R":"-") + (f->write?"W":"-") + (f->multi?" M":" -")
                    +" "+f->description;
            qDebug(fDesc.toLocal8Bit());
        }
    }
    isInitialized = true;
}
开发者ID:,项目名称:,代码行数:59,代码来源:

示例5: getUserFriendlyNames

QStringList DeviceEnumerator_unix::getUserFriendlyNames(const QStringList &devices) const
{
    QStringList returnList;

    foreach (QString s, devices) {
#ifdef Q_OS_LINUX
        qint64 size = driveSize(s);
        QStringList partInfo = getPartitionsInfo(s);

        QTextStream friendlyName(&s);
        friendlyName.setRealNumberNotation(QTextStream::FixedNotation);
        friendlyName.setRealNumberPrecision(2);
        friendlyName << " (";
        if (size > 0) {
            friendlyName << size/(1024*1024*1024.0) << " GB";
        }
        else {
            friendlyName << "??? GB";
        }
        friendlyName << ", partitions: ";
        foreach (QString partition, partInfo) {
            friendlyName << partition << ", ";
        }
        s.chop(2);
        friendlyName << ")";

        returnList.append(s);
#else
        QProcess lsblk;
        lsblk.start(QString("diskutil info %1").arg(s), QIODevice::ReadOnly);
        lsblk.waitForStarted();
        lsblk.waitForFinished();

        QString output = lsblk.readLine();
        QStringList iddata;
        QString item = "";
        while (!lsblk.atEnd()) {
            output = output.trimmed(); // Odd trailing whitespace
            if (output.contains("Device / Media Name:")) { // We want the volume name of this device
                output.replace("Device / Media Name:      ","");
                iddata.append(output);
            }else if (output.contains("Device Identifier:")) { // We want the volume name of this device
                output.replace("Device Identifier:        ","");
                iddata.append(output);
            }else if (output.contains("Total Size:")) { // We want the volume name of this device
                 output.replace("Total Size:               ","");
                 QStringList tokens = output.split(" ");
                 iddata.append( "("+tokens[0]+tokens[1]+")");
            }

            output = lsblk.readLine();
        }

        foreach(QString each,iddata)
        {
            item += each+": ";
        }
开发者ID:RasPlex,项目名称:rasplex-installer,代码行数:57,代码来源:deviceenumerator_unix.cpp

示例6: mystring

std::list<int> ProcessControl::getPidProcessByName(std::string name)
{
    std::list<int> result;
    qDebug() << "ProcessControl::getPidProcessByName: Begin:";
#ifndef WIN32
    QProcess myprocess;
    std::string command = std::string("ps -C ")+name+std::string(" -o pid --no-heading");
    qDebug() << "ProcessControl::getPidProcessByName: comando solicitado:" << command.c_str();
    myprocess.start(command.c_str());
    if (!myprocess.waitForFinished()) return result;
    while (!myprocess.atEnd())
    {
        char buf[16];
        qint64 length = myprocess.readLine(buf,sizeof(buf));
        if (length != -1)
        {
            QString mystring(buf);
            result.push_back(mystring.toInt());
        }
        else break;
    }
#else
      DWORD aProcesses[1024], cbNeeded, cProcesses;
      if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
	      return result;
      // Calculate how many process identifiers were returned.

      cProcesses = cbNeeded / sizeof(DWORD);
      for ( int i = 0 ; i < cProcesses; i++)
      {
	      if (aProcesses[i] != 0)
	      {
		      std::wstring nombre = PrintProcessNameAndID( aProcesses[i] );
		      std::string temp;
		      std::copy(nombre.begin(), nombre.end(), std::back_inserter(temp));
		      qDebug() << "ProcessControl::getPidProcessByName: New pid name" << aProcesses[i] <<  temp.c_str();
		      if (QString(temp.c_str()).toLower()==QString(name.c_str()).toLower())
		      {
			      qDebug() << "ProcessControl::getPidProcessByName: found proccess";
			      result.push_back((int)aProcesses[i]);
		      }
	      }
      }
      
      


#endif
    return result;
}
开发者ID:nesaro,项目名称:adelin,代码行数:50,代码来源:ProcessControl.cpp

示例7: atEnd

bool BlockingIODevice::atEnd() const
{
    /*
     * XXX: QProcess::atEnd() documentation is wrong -- it will return true
     * even when the process is running --, so we try to workaround that here.
     */
    if (m_device->atEnd()) {
        if (m_device->state() == QProcess::Running) {
            if (!m_device->waitForReadyRead(-1)) {
                return true;
            }
        }
    }
    return false;
}
开发者ID:Hsaniva,项目名称:apitrace,代码行数:15,代码来源:retracer.cpp

示例8: sendBugReport

bool KBugReport::sendBugReport()
{
#ifndef EMSCRIPTEN
  QString recipient ( d->m_aboutData ?
    d->m_aboutData->bugAddress() :
    QString::fromLatin1("[email protected]") );

  QString command;
  command = KStandardDirs::locate("exe", "ksendbugmail");
  if (command.isEmpty())
      command = KStandardDirs::findExe( QString::fromLatin1("ksendbugmail") );

  QProcess proc;
  QStringList args;
  args << "--subject" << d->m_subject->text() << "--recipient" << recipient;
  proc.start( command, args );
  //kDebug() << command << args;
  if (!proc.waitForStarted())
  {
    kError() << "Unable to open a pipe to " << command << endl;
    return false;
  }
  proc.write( text().toUtf8() );
  proc.closeWriteChannel();

  proc.waitForFinished();
  kDebug() << "kbugreport: sendbugmail exit, status " << proc.exitStatus() << " code " << proc.exitCode();

  QByteArray line;
  if (proc.exitStatus() == QProcess::NormalExit && proc.exitCode() != 0) {
      // XXX not stderr?
      while (!proc.atEnd())
          line = proc.readLine();
      d->lastError = QString::fromUtf8( line );
      return false;
  }
  return true;
#else
  kWarning() << "Bug report stuff not supported on Emscripten";
  return false;
#endif
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例9: getRemovableDeviceNames

QStringList DeviceEnumerator_unix::getRemovableDeviceNames() const
{
    QStringList names;
    QStringList unmounted;

#ifdef Q_OS_LINUX
    names = getDeviceNamesFromSysfs();

    foreach (QString device, names)
    {
        if (! checkIsMounted(device))
            unmounted << "/dev/"+device;
    }

    return unmounted;
#else
    QProcess lsblk;
    lsblk.start("diskutil list", QIODevice::ReadOnly);
    lsblk.waitForStarted();
    lsblk.waitForFinished();

    QString device = lsblk.readLine();
    while (!lsblk.atEnd()) {
        device = device.trimmed(); // Odd trailing whitespace

        if (device.startsWith("/dev/disk")) {
            QString name = device.split(QRegExp("\\s+")).first();
#if USE_ONLY_USB_DEVICES_ON_OSX == 0
        names << name;
#else
            // We only want to add USB devics
            if (this->checkIfUSB(name)) {
                names << name;
            }
#endif
        }
        device = lsblk.readLine();
    }

    return names;
#endif
}
开发者ID:RasPlex,项目名称:rasplex-installer,代码行数:42,代码来源:deviceenumerator_unix.cpp

示例10: get_disk_space__

bool resource_minitor::get_disk_space__()
{
    QProcess process;
    process.start("df -k");
    process.waitForFinished();
    process.readLine();
    while(!process.atEnd())
    {
        QString str = process.readLine();
        if(str.startsWith("/dev/sda"))
        {
            str.replace("\n","");
            str.replace(QRegExp("( ){1,}")," ");
            auto lst = str.split(" ");
            if(lst.size() > 5)
                qDebug("挂载点:%s 已用:%.0lfMB 可用:%.0lfMB",lst[5].toStdString().c_str(),lst[2].toDouble()/1024.0,lst[3].toDouble()/1024.0);
        }
    }
    return true;
}
开发者ID:yangyang0312,项目名称:C-,代码行数:20,代码来源:resource_minitor.cpp

示例11: sofaExited

void SofaModeler::sofaExited(int exitCode, QProcess::ExitStatus existStatus)
{
    QProcess *p = ((QProcess*) sender());
    std::string programName;

    programName = p->objectName().toStdString();

    removeTemporaryFiles(programName);
    if (existStatus == QProcess::NormalExit )
    {
        p->closeWriteChannel();
        disconnect(p, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(sofaExited(int, QProcess::ExitStatus)));
        disconnect(p, SIGNAL( readyReadStandardOutput () ), this , SLOT ( redirectStdout() ) );
        disconnect(p, SIGNAL( readyReadStandardError () ), this , SLOT ( redirectStderr() ) );
        if(p->atEnd())
            std::cout << "Sofa exited safely." << std::endl;
        else
            std::cout << "Chelou." << std::endl;
        p->kill();
        return;
    }
开发者ID:151706061,项目名称:sofa,代码行数:21,代码来源:SofaModeler.cpp

示例12: loadSettings

void KeyboardLayoutConfig::loadSettings() {
  // load current settings from the output of setxkbmap command
  QProcess setxkbmap;
  setxkbmap.start(QLatin1String("setxkbmap -query -verbose 5"));
  setxkbmap.waitForFinished();
  if(setxkbmap.exitStatus() == QProcess::NormalExit) {
    QList<QByteArray> layouts, variants;
    while(!setxkbmap.atEnd()) {
      QByteArray line = setxkbmap.readLine();
      if(line.startsWith("model:")) {
        keyboardModel_ = QString::fromLatin1(line.mid(6).trimmed());
      }
      else if(line.startsWith("layout:")) {
        layouts = line.mid(7).trimmed().split(',');
      }
      else if(line.startsWith("variant:")) {
        variants = line.mid(8).trimmed().split(',');
      }
      else if(line.startsWith("options:")) {
        const QList<QByteArray> options = line.mid(9).trimmed().split(',');
        Q_FOREACH(const QByteArray &option, options) {
          if(option.startsWith("grp:"))
            switchKey_ = QString::fromLatin1(option);
          else
            currentOptions_ << QString::fromLatin1(option);
        }
      }
    }

    const int size = layouts.size(), variantsSize = variants.size();
    for(int i = 0; i < size; ++i) {
      currentLayouts_.append(QPair<QString, QString>(layouts.at(i), variantsSize > 0 ? variants.at(i) : QString()));
    }

    setxkbmap.close();
  }
开发者ID:rbuj,项目名称:lxqt-config,代码行数:36,代码来源:keyboardlayoutconfig.cpp

示例13: verifyRevisions

void RCSTest::verifyRevisions()
{
    RCS::init();

    RCS *rcs = new RCS(test_file);

    QList<Revision> rcsrevs;
    for (QList<Revision>::iterator i=rcs->begin(); i!=rcs->end(); ++i)
    {
        Revision rev = *i;
        QStringList log = rev.log.split("\n");
        log.removeFirst();
        rev.log = log.join("\n");
        rcsrevs.append(rev);
    }
    QProcess rlog;
    rlog.start("rlog", QStringList() << test_file);

    rlog.waitForFinished();

    QList<Revision> realrevs;
    QRegExp revlock("revision\\s+([\\.\\d]+)(\\s+locked by: (\\w+);)?\\n");
    revlock.setPatternSyntax(QRegExp::RegExp2);
    QRegExp dateauth("date: (\\d\\d\\d\\d/\\d\\d/\\d\\d \\d\\d\\:\\d\\d\\:\\d\\d);\\s+author\\: (\\w+);\\s+state\\: (\\w+);(\\s+lines: \\+(\\d+) \\-(\\d+))?\\n");

    QMap <QString, Revision> realrevsmap;

    QString line;

    while (!rlog.atEnd() && line != "----------------------------\n") // skip header
        line = rlog.readLine();
    while (!rlog.atEnd())
    {
        QStringList lines;
        while (!rlog.atEnd())
        {
            line = rlog.readLine();
            if (line != "----------------------------\n" &&
                line != "=============================================================================\n")
                lines.append(line);
            else
                break;
        }
        QStringList comment;
        for (int i = 2; i< lines.size(); i++)
            comment.append(lines.at(i));
        Revision rev;
        rev.log = comment.join("");
        revlock.indexIn(lines[0]);
        rev.locked_by = revlock.capturedTexts()[3];
        rev.rev = revlock.capturedTexts()[1];
        dateauth.indexIn(lines[1]);
        rev.date = dateauth.capturedTexts()[1].replace("/", "-");
        rev.author = dateauth.capturedTexts()[2];
        rev.filename = test_file;

        realrevs.insert(0, rev);
        realrevsmap[rev.rev] = rev;
    }

    CPPUNIT_ASSERT(realrevs.size() == rcsrevs.size());

    for (int i = 0; i < realrevs.size(); i++)
    {
        Revision rcsr = rcsrevs.at(i);
        Revision realr = realrevsmap[rcsr.rev];
/*
        qDebug() << realr.author << rcsr.author;
        qDebug() << realr.date << rcsr.date;
        qDebug() << realr.filename << rcsr.filename;
        qDebug() << realr.locked_by << rcsr.locked_by;
        qDebug() << realr.log << rcsr.log;
        qDebug() << realr.rev << rcsr.rev;
        qDebug() << "----------";
        qDebug() << (realr == rcsr);
*/
        CPPUNIT_ASSERT (realr == rcsr);
    }

}
开发者ID:BrendanThompson,项目名称:fwbuilder,代码行数:80,代码来源:RCSTest.cpp

示例14: run


//.........这里部分代码省略.........

        if (m_captureState) {
            /*
             * Parse JSON from the output.
             *
             * XXX: QJSON's scanner is inneficient as it abuses single
             * character QIODevice::peek (not cheap), instead of maintaining a
             * lookahead character on its own.
             */

            bool ok = false;
            QJson::Parser jsonParser;

            // Allow Nan/Infinity
            jsonParser.allowSpecialNumbers(true);
#if 0
            parsedJson = jsonParser.parse(&io, &ok).toMap();
#else
            /*
             * XXX: QJSON expects blocking IO, and it looks like
             * BlockingIODevice does not work reliably in all cases.
             */
            process.waitForFinished(-1);
            parsedJson = jsonParser.parse(&process, &ok).toMap();
#endif
            if (!ok) {
                msg = QLatin1String("failed to parse JSON");
            }
        } else if (m_captureThumbnails) {
            /*
             * Parse concatenated PNM images from output.
             */

            while (!io.atEnd()) {
                unsigned channels = 0;
                unsigned width = 0;
                unsigned height = 0;

                char header[512];
                qint64 headerSize = 0;
                int headerLines = 3; // assume no optional comment line

                for (int headerLine = 0; headerLine < headerLines; ++headerLine) {
                    qint64 headerRead = io.readLine(&header[headerSize], sizeof(header) - headerSize);

                    // if header actually contains optional comment line, ...
                    if (headerLine == 1 && header[headerSize] == '#') {
                        ++headerLines;
                    }

                    headerSize += headerRead;
                }

                const char *headerEnd = image::readPNMHeader(header, headerSize, &channels, &width, &height);

                // if invalid PNM header was encountered, ...
                if (header == headerEnd) {
                    qDebug() << "error: invalid snapshot stream encountered";
                    break;
                }

                // qDebug() << "channels: " << channels << ", width: " << width << ", height: " << height";

                QImage snapshot = QImage(width, height, channels == 1 ? QImage::Format_Mono : QImage::Format_RGB888);

                int rowBytes = channels * width;
开发者ID:Hsaniva,项目名称:apitrace,代码行数:67,代码来源:retracer.cpp

示例15: run

/**
 * Starting point for the retracing thread.
 *
 * Overrides QThread::run().
 */
void Retracer::run()
{
    QString msg = QLatin1String("Replay finished!");

    /*
     * Construct command line
     */

    QString prog;
    QStringList arguments;

    switch (m_api) {
    case trace::API_GL:
        prog = QLatin1String("glretrace");
        break;
    case trace::API_EGL:
        prog = QLatin1String("eglretrace");
        break;
    case trace::API_DX:
    case trace::API_D3D7:
    case trace::API_D3D8:
    case trace::API_D3D9:
    case trace::API_DXGI:
#ifdef Q_OS_WIN
        prog = QLatin1String("d3dretrace");
#else
        prog = QLatin1String("wine");
        arguments << QLatin1String("d3dretrace.exe");
#endif
        break;
    default:
        emit finished(QLatin1String("Unsupported API"));
        return;
    }

    arguments << retraceArguments() << m_fileName;

    /*
     * Support remote execution on a separate target.
     */

    if (m_remoteTarget.length() != 0) {
        arguments.prepend(prog);
        arguments.prepend(m_remoteTarget);
        prog = QLatin1String("ssh");
    }

    /*
     * Start the process.
     */

    {
        QDebug debug(QtDebugMsg);
        debug << "Running:";
        debug << prog;
        foreach (const QString &argument, arguments) {
            debug << argument;
        }
    }

    QProcess process;

    process.start(prog, arguments, QIODevice::ReadOnly);
    if (!process.waitForStarted(-1)) {
        emit finished(QLatin1String("Could not start process"));
        return;
    }

    /*
     * Process standard output
     */

    ImageHash thumbnails;
    QVariantMap parsedJson;
    trace::Profile* profile = NULL;

    process.setReadChannel(QProcess::StandardOutput);
    if (process.waitForReadyRead(-1)) {
        BlockingIODevice io(&process);

        if (m_captureState) {
            parsedJson = decodeUBJSONObject(&io).toMap();
            process.waitForFinished(-1);
        } else if (m_captureThumbnails) {
            /*
             * Parse concatenated PNM images from output.
             */

            while (!io.atEnd()) {
                image::PNMInfo info;

                char header[512];
                qint64 headerSize = 0;
                int headerLines = 3; // assume no optional comment line

//.........这里部分代码省略.........
开发者ID:ShuangxueBai,项目名称:apitrace,代码行数:101,代码来源:retracer.cpp


注:本文中的QProcess::atEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。