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


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

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


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

示例1: if

void CommandHandler::processCommand(const Command &command) const
{
    QWebEngineView *webView = ElectricWebView::instance()->webView();

    if (command.name() == "load") {
        if (command.arguments().isEmpty())
            webView->load(QUrl("about:blank"));
        else
            webView->load(QUrl(command.arguments().first()));
    } else if (command.name() == "stop") {
        webView->stop();
    } else if (command.name() == "reload") {
        webView->reload();
    } else if (command.name() == "back") {
        webView->back();
    } else if (command.name() == "forward") {
        webView->forward();
    } else if (command.name() == "open") {
        QString mode = command.arguments().value(0);

        if (mode == "maximized") {
            webView->showMaximized();
        } else if (mode == "fullscreen") {
            webView->setGeometry(qApp->desktop()->screenGeometry());
            webView->showFullScreen();
        }
    } else if (command.name() == "close") {
        webView->close();
    } else if (command.name() == "current_url") {
        command.sendResponse(webView->url().toString().toLocal8Bit());
    } else if (command.name() == "set_html") {
        QString type = command.arguments().value(0);
        QString value = command.arguments().mid(1, -1).join(' ');

        if (type == "string") {
            webView->page()->setHtml(value.toLocal8Bit());
        } else if (type == "file") {
            QFile file(value);
            file.open(QFile::ReadOnly);

            webView->page()->setHtml(file.readAll());
        }
    } else if (command.name() == "get_html") {
        QString format = command.arguments().value(0);

        QEventLoop loop;

        if (format == "html") {
            webView->page()->toHtml([&command, &loop](const QString &html) {
                if (!command.client().isNull()) {
                    command.sendResponse(QUrl::toPercentEncoding(html));

                    if (command.isGetter())
                        command.client()->close();
                }
                loop.quit();
            });
        } else if (format == "text") {
            webView->page()->toPlainText([&command, &loop](const QString &text) {
                if (!command.client().isNull()) {
                    command.sendResponse(QUrl::toPercentEncoding(text));

                    if (command.isGetter())
                        command.client()->close();
                }
                loop.quit();
            });
        } else {
            return;
        }

        loop.exec();
    } else if (command.name() == "current_title") {
        command.sendResponse(webView->title().toLocal8Bit());
    } else if (command.name() == "screenshot") {
        processScreenshotCommand(command);
    } else if (command.name() == "subscribe") {
        QString eventName = command.arguments().value(0);
        QStringList events = QStringList()
                << "title_changed"
                << "url_changed"
                << "load_started"
                << "load_finished"
                << "user_activity"
                << "info_message_raised"
                << "warning_message_raised"
                << "error_message_raised"
                << "feature_permission_requested";

        if (events.contains(eventName)) {
            Event event(command);
            event.setName(eventName);

            ElectricWebView::instance()->eventManager()->subscribe(event);
        }
    } else if (command.name() == "exec_js") {
        processJavaScriptCommand(command);
    } else if (command.name() == "inject_js") {
        QMap<QString, QWebEngineScript::ScriptWorldId> worlds;
        worlds["main"] = QWebEngineScript::MainWorld;
//.........这里部分代码省略.........
开发者ID:gustavosbarreto,项目名称:electric-webview,代码行数:101,代码来源:commandhandler.cpp

示例2: convert

void QtDcmConvert::convert()
{
    if (QtDcmPreferences::instance()->useDcm2nii())
    {
        QString program = QtDcmPreferences::instance()->getDcm2niiPath();
        QStringList arguments;
        arguments << "-x" << "N";
        arguments << "-r" << "N";
        arguments << "-g" << "N";
        arguments << "-o" << d->outputDirectory << d->inputDirectory;
        
        QProcess * process = new QProcess(this);
        process->setStandardOutputFile(d->tempDirectory + QDir::separator() + "logs" + QDir::separator() + d->serieUID + ".txt");
        process->start(program, arguments);
        process->waitForFinished();

        delete process;
    }
    else
    {
        typedef signed short                                PixelType;
        const unsigned int Dimension = 3;
        typedef itk::Image< PixelType, Dimension >          ImageType;
        typedef itk::ImageSeriesReader< ImageType >         ReaderType;
        typedef itk::ImageFileWriter<ImageType>             WriterType;
        typedef itk::GDCMImageIO                            ImageIOType;
        typedef itk::GDCMSeriesFileNames                    NamesGeneratorType;
        typedef std::vector< std::string >                  FileNamesContainer;
        typedef std::vector< std::string >                  SeriesIdContainer;

//     ImageType::Pointer image = 0;

        ReaderType::Pointer reader = ReaderType::New();
        ImageIOType::Pointer dicomIO = ImageIOType::New();

        NamesGeneratorType::Pointer inputNames = NamesGeneratorType::New();
        inputNames->SetUseSeriesDetails ( true );
        inputNames->AddSeriesRestriction ( "0008|0021" );
        inputNames->AddSeriesRestriction ( "0020,0037" );
        inputNames->LoadSequencesOn();
        inputNames->LoadPrivateTagsOn();
        inputNames->SetInputDirectory ( d->inputDirectory.toStdString() );
        try
        {
            const SeriesIdContainer & seriesUID = inputNames->GetSeriesUIDs();
            std::string seriesIdentifier = seriesUID.begin()->c_str();
            FileNamesContainer filenames = inputNames->GetFileNames ( seriesIdentifier );

            dicomIO->SetFileName ( filenames.begin()->c_str() );
            try
            {
                dicomIO->ReadImageInformation();
            }
            catch ( itk::ExceptionObject &e )
            {
                qDebug() << e.GetDescription();
                return;
            }

            reader->UseStreamingOn();
            reader->SetFileNames ( filenames );
            reader->SetImageIO ( dicomIO );

            try
            {
                reader->Update();
            }
            catch ( itk::ExceptionObject &excp )
            {
                std::cerr << excp << std::endl;
                return;
            }

//         IteratorType itOut;
//
//         image = reader->GetOutput();
//
//         RegionType region;
//         region.SetSize ( 0, image->GetLargestPossibleRegion().GetSize() [0] );
//         region.SetSize ( 1, image->GetLargestPossibleRegion().GetSize() [1] );
//         region.SetSize ( 2, image->GetLargestPossibleRegion().GetSize() [2] );
//         image->SetRegions ( region );
//         image->Allocate();
//         SpacingType spacing;
//         spacing[0] = image->GetSpacing() [0];
//         spacing[1] = image->GetSpacing() [1];
//         spacing[2] = image->GetSpacing() [2];
//         spacing[3] = 1;
//         image->SetSpacing ( spacing );
//         PointType origin;
//         origin[0] = image->GetOrigin() [0];
//         origin[1] = image->GetOrigin() [1];
//         origin[2] = image->GetOrigin() [2];
//         origin[3] = 0;
//         image->SetOrigin ( origin );
//         DirectionType direction;
//         for ( unsigned int i=0; i<4; i++ )
//             for ( unsigned int j=0; j<4; j++ )
//             {
//                 if ( ( i < 3 ) && ( j < 3 ) )
//.........这里部分代码省略.........
开发者ID:NicolasSchnitzler,项目名称:qtdcm,代码行数:101,代码来源:QtDcmConvert.cpp

示例3: main

int main(int argc, char ** argv)
{

    QString appDir = QFileInfo(argv[0]).absolutePath();
    appDir += "/texiteasyPath.txt";
    FILE * file = fopen(appDir.toLatin1().data(), "r");
    //FILE * log = fopen("C:\\Users\\Wybot\\AppData\\Roaming\\TexitEasy\\log.txt", "w");
    //fwrite(appDir.toLatin1().data(), sizeof(char), appDir.toLatin1().size(), log);
    if(!file)
    {
        //fwrite("Unable to open", sizeof(char), 14, log);
        return 1;
    }
    char start[5000];
    size_t s = fread(start, sizeof(char), 5000, file);
    start[s] = '\0';


    QtSingleCoreApplication a("TexitEasy",argc, argv);

    QProcess* proc = new QProcess();
    QString str(start);
    QStringList args = a.arguments();
    args.pop_front();

    /*for(int i = 1; i < argc; ++i)
    {
        args << argv[i];
    }*/
    if ( a.isRunning() && !args.contains("-n") && !args.contains("--new-window"))
    {
        proc->start(str+"/TexitEasy.exe", args);
        return 0;
    }


    QCoreApplication::setOrganizationName("TexitEasy");
    QCoreApplication::setOrganizationDomain("texiteasy.com");
    QCoreApplication::setApplicationName("TexitEasy");
    QSettings::setDefaultFormat(QSettings::IniFormat);



    //fwrite(start, sizeof(char), s, log);
    QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
    QFile updateFile(dataLocation+"/updateFiles.zip");
    if(updateFile.exists())
    {
        QStringList l;
        //l << str+"/texiteasy_upgrade.exe";
        l << dataLocation+"/updateFiles.zip";
        l << str;
        proc->start(str+"/texiteasy_upgrade.exe", l);
        return 0;
    }
    QFile updateFileExe(dataLocation+"/updateFiles.exe");
    if(updateFileExe.exists())
    {
        QStringList l;
        updateFileExe.rename(dataLocation+"/updateTexitEasy.exe");
        //l << str+"/texiteasy_upgrade.exe";
        l << dataLocation+"/updateTexitEasy.exe";
        // l << str;
        proc->start(str+"/elevate.exe", l);
        return 0;
    }

    proc->start(str+"/TexitEasy.exe", args);

}
开发者ID:snursmumrik,项目名称:texiteasy,代码行数:70,代码来源:main.cpp

示例4: traditionalTaskPrepare

bool AssignmentThread::traditionalTaskPrepare()
{
    compileState = NoValidSourceFile;
    QDir contestantDir = QDir(Settings::sourcePath() + contestantName);
    QList<Compiler*> compilerList = settings->getCompilerList();
    
    for (int i = 0; i < compilerList.size(); i ++) {
        if (task->getCompilerConfiguration(compilerList[i]->getCompilerName()) == "disable") continue;
        QStringList filters = compilerList[i]->getSourceExtensions();
        for (int j = 0; j < filters.size(); j ++) {
            filters[j] = task->getSourceFileName() + "." + filters[j];
        }
        QStringList files = contestantDir.entryList(filters, QDir::Files);
        sourceFile = "";
        for (int j = 0; j < files.size(); j ++) {
            qint64 fileSize = QFileInfo(Settings::sourcePath() + contestantName + QDir::separator() + files[j]).size();
            if (fileSize <= settings->getFileSizeLimit() * 1024) {
                sourceFile = files[j];
                break;
            }
        }
        
        if (! sourceFile.isEmpty()) {
            QDir(Settings::temporaryPath()).mkdir(contestantName);
            QFile::copy(Settings::sourcePath() + contestantName + QDir::separator() + sourceFile,
                        Settings::temporaryPath() + contestantName + QDir::separator() + sourceFile);
            QStringList configurationNames = compilerList[i]->getConfigurationNames();
            QStringList compilerArguments = compilerList[i]->getCompilerArguments();
            QStringList interpreterArguments = compilerList[i]->getInterpreterArguments();
            QString currentConfiguration = task->getCompilerConfiguration(compilerList[i]->getCompilerName());
            for (int j = 0; j < configurationNames.size(); j ++) {
                if (configurationNames[j] == currentConfiguration) {
                    timeLimitRatio = compilerList[i]->getTimeLimitRatio();
                    memoryLimitRatio = compilerList[i]->getMemoryLimitRatio();
                    disableMemoryLimitCheck = compilerList[i]->getDisableMemoryLimitCheck();
                    environment = compilerList[i]->getEnvironment();
                    QStringList values = environment.toStringList();
                    for (int k = 0; k < values.size(); k ++) {
                        int tmp = values[k].indexOf("=");
                        QString variable = values[k].mid(0, tmp);
                        environment.insert(variable, 
                                           environment.value(variable) + ";"
                                           + QProcessEnvironment::systemEnvironment().value(variable));
                    }
                    
                    if (compilerList[i]->getCompilerType() == Compiler::Typical) {
#ifdef Q_OS_WIN32
                                executableFile = task->getSourceFileName() + ".exe";
#endif
#ifdef Q_OS_LINUX
                                executableFile = task->getSourceFileName();
#endif
                                interpreterFlag = false;
                    } else {
                        executableFile = compilerList[i]->getInterpreterLocation();
                        arguments = interpreterArguments[j];
                        arguments.replace("%s.*", sourceFile);
                        arguments.replace("%s", task->getSourceFileName());
                        interpreterFlag = true;
                    }
                    
                    if (compilerList[i]->getCompilerType() != Compiler::InterpretiveWithoutByteCode) {
                        QString arguments = compilerArguments[j];
                        arguments.replace("%s.*", sourceFile);
                        arguments.replace("%s", task->getSourceFileName());
                        QProcess *compiler = new QProcess(this);
                        compiler->setProcessChannelMode(QProcess::MergedChannels);
                        compiler->setProcessEnvironment(environment);
                        compiler->setWorkingDirectory(Settings::temporaryPath() + contestantName);
                        compiler->start(QString("\"") + compilerList[i]->getCompilerLocation() + "\" " + arguments);
                        if (! compiler->waitForStarted(-1)) {
                            compileState = InvalidCompiler;
                            delete compiler;
                            break;
                        }
                        QElapsedTimer timer;
                        timer.start();
                        bool flag = false;
                        while (timer.elapsed() < settings->getCompileTimeLimit()) {
                            if (compiler->state() != QProcess::Running) {
                                flag = true;
                                break;
                            }
                            QCoreApplication::processEvents();
                            if (stopJudging) {
                                compiler->kill();
                                delete compiler;
                                return false;
                            }
                            msleep(10);
                        }
                        if (! flag) {
                            compiler->kill();
                            compileState = CompileTimeLimitExceeded;
                        } else
                            if (compiler->exitCode() != 0) {
                                compileState = CompileError;
                                compileMessage = QString::fromLocal8Bit(compiler->readAllStandardOutput().data());
                            } else {
                                if (compilerList[i]->getCompilerType() == Compiler::Typical) {
//.........这里部分代码省略.........
开发者ID:ZhangZisu,项目名称:lemon,代码行数:101,代码来源:assignmentthread.cpp

示例5: main

int main(int argc, char **argv){
  //Run all the actual code in a separate function to have as little memory usage
  //  as possible aside from the main application when running

  //Make sure the XDG environment variables exist first
  LXDG::setEnvironmentVars();
  //now get the command
  QString cmd, args, path;
  bool watch = true; //enable the crash handler by default (only disabled for some *.desktop inputs)
  getCMD(argc, argv, cmd, args, path, watch);
  //qDebug() << "Run CMD:" << cmd << args;
  //Now run the command (move to execvp() later?)
  if(cmd.isEmpty()){ return 0; } //no command to run (handled internally)
  qDebug() << "[lumina-open] Running Cmd:" << cmd;
  int retcode = 0;
  
  if(!watch && path.isEmpty()){
      //Nothing special about this one - just start it detached (less overhead)
      QProcess::startDetached(cmd);
  }else{
    //Keep an eye on this process for errors and notify the user if it crashes
    QString log;
    if(cmd.contains("\\\\")){
      //Special case (generally for Wine applications)
      cmd = cmd.replace("\\\\","\\");
      retcode = system(cmd.toLocal8Bit()); //need to run it through the "system" instead of QProcess
    }else{
      QProcess *p = new QProcess();
      p->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
      if(!path.isEmpty() && QFile::exists(path)){ 
        //qDebug() << " - Setting working path:" << path;
        p->setWorkingDirectory(path); 
      }
      p->start(cmd);
  
      //Now check up on it once every minute until it is finished
      while(!p->waitForFinished(60000)){
        //qDebug() << "[lumina-open] process check:" << p->state();
        if(p->state() != QProcess::Running){ break; } //somehow missed the finished signal
      }
      retcode = p->exitCode();
      if( (p->exitStatus()==QProcess::CrashExit) && retcode ==0){ retcode=1; } //so we catch it later
      log = QString(p->readAllStandardError());
      if(log.isEmpty()){ log = QString(p->readAllStandardOutput()); }
    }
    //qDebug() << "[lumina-open] Finished Cmd:" << cmd << retcode << p->exitStatus();
    if( QFile::exists("/tmp/.luminastopping") ){ watch = false; } //closing down session - ignore "crashes" (app could have been killed during cleanup)
    if( (retcode > 0) && watch && !(retcode==1 && cmd.startsWith("pc-su ")) ){ //pc-su returns 1 if the user cancelles the operation
      
      qDebug() << "[lumina-open] Application Error:" << retcode;
        //Setup the application
        QApplication App(argc, argv);
        LuminaThemeEngine theme(&App);
	  LUtils::LoadTranslation(&App,"lumina-open");
        QMessageBox dlg(QMessageBox::Critical, QObject::tr("Application Error"), QObject::tr("The following application experienced an error and needed to close:")+"\n\n"+cmd );
        if(!log.isEmpty()){ dlg.setDetailedText(log); }
        dlg.exec();
      }
  }
  return retcode;
}
开发者ID:mneumann,项目名称:lumina,代码行数:61,代码来源:main.cpp

示例6: mailTo

void Common::mailTo( const QUrl &url )
{
#if defined(Q_OS_WIN32)
	QString file = url.queryItemValue( "attachment" );
	QByteArray filePath = QDir::toNativeSeparators( file ).toLatin1();
	QByteArray fileName = QFileInfo( file ).fileName().toLatin1();
	QByteArray subject = url.queryItemValue( "subject" ).toLatin1();

	MapiFileDesc doc[1];
	doc[0].ulReserved = 0;
	doc[0].flFlags = 0;
	doc[0].nPosition = -1;
	doc[0].lpszPathName = const_cast<char*>(filePath.constData());
	doc[0].lpszFileName = const_cast<char*>(fileName.constData());
	doc[0].lpFileType = NULL;

	// Create message
	MapiMessage message;
	message.ulReserved = 0;
	message.lpszSubject = const_cast<char*>(subject.constData());
	message.lpszNoteText = "";
	message.lpszMessageType = NULL;
	message.lpszDateReceived = NULL;
	message.lpszConversationID = NULL;
	message.flFlags = 0;
	message.lpOriginator = NULL;
	message.nRecipCount = 0;
	message.lpRecips = NULL;
	message.nFileCount = 1;
	message.lpFiles = (lpMapiFileDesc)&doc;

	QLibrary lib("mapi32");
	typedef ULONG (PASCAL *SendMail)(ULONG,ULONG,MapiMessage*,FLAGS,ULONG);
	SendMail mapi = (SendMail)lib.resolve("MAPISendMail");
	if( mapi )
	{
		mapi( NULL, 0, &message, MAPI_LOGON_UI|MAPI_DIALOG, 0 );
		return;
	}
#elif defined(Q_OS_MAC)
	CFURLRef emailUrl = CFURLCreateWithString( kCFAllocatorDefault, CFSTR("mailto:"), 0 );
	CFURLRef appUrl = 0;
	CFStringRef appPath = 0;
	if( LSGetApplicationForURL( emailUrl, kLSRolesAll, NULL, &appUrl ) == noErr )
	{
		appPath = CFURLCopyFileSystemPath( appUrl, kCFURLPOSIXPathStyle );
		CFRelease( appUrl );
	}
	CFRelease( emailUrl );

	if( appPath )
	{
		QProcess p;
		p.start( "/usr/bin/osascript", QStringList() << "-" << url.queryItemValue("attachment") << url.queryItemValue("subject") );
		p.waitForStarted();
		QTextStream s( &p );
		if( CFStringCompare( appPath, CFSTR("/Applications/Mail.app"), 0 ) == kCFCompareEqualTo )
		{
			s << "on run argv" << endl
				<< "set vattachment to (item 1 of argv)" << endl
				<< "set vsubject to (item 2 of argv)" << endl
				<< "tell application \"Mail\"" << endl
				<< "set composeMessage to make new outgoing message at beginning with properties {visible:true}" << endl
				<< "tell composeMessage" << endl
				<< "set subject to vsubject" << endl
				<< "set content to \" \"" << endl
				<< "tell content" << endl
				<< "make new attachment with properties {file name: vattachment} at after the last word of the last paragraph" << endl
				<< "end tell" << endl
				<< "end tell" << endl
				<< "activate" << endl
				<< "end tell" << endl
				<< "end run" << endl;
		}
		else if( CFStringFind( appPath, CFSTR("Entourage"), 0 ).location != kCFNotFound )
		{
			s << "on run argv" << endl
				<< "set vattachment to (item 1 of argv)" << endl
				<< "set vsubject to (item 2 of argv)" << endl
				<< "tell application \"Microsoft Entourage\"" << endl
				<< "set vmessage to make new outgoing message with properties" << endl
				<< "{subject:vsubject, attachments:vattachment}" << endl
				<< "open vmessage" << endl
				<< "activate" << endl
				<< "end tell" << endl
				<< "end run" << endl;
		}
#if 0
		else if(CFStringCompare(appPath, CFSTR("/Applications/Thunderbird.app"), 0) == kCFCompareEqualTo)
		{
			// TODO: Handle Thunderbird here? Impossible?
		}
#endif
		CFRelease( appPath );
		p.closeWriteChannel();
		p.waitForFinished();
		if( p.exitCode() == 0 )
			return;
	}
#elif defined(Q_OS_LINUX)
//.........这里部分代码省略.........
开发者ID:Krabi,项目名称:idkaart_public,代码行数:101,代码来源:Common.cpp

示例7: file

void TestRailInterface::addRun() {
    QString filename = _outputDirectory + "/addRun.py";
    if (QFile::exists(filename)) {
        QFile::remove(filename);
    }
    QFile file(filename);

    if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
                              "Could not create " + filename);
        exit(-1);
    }

    QTextStream stream(&file);

    // Code to access TestRail
    stream << "from testrail import *\n";
    stream << "client = APIClient('" << _url.toStdString().c_str() << "')\n";
    stream << "client.user = '" << _user << "'\n";
    stream << "client.password = '" << _password << "'\n\n";

    // A test suite is a forest.  Each node is a section and leaves are either sections or test cases
    // The user has selected a root for the run
    // To find the cases in this tree we need all the sections in the tree
    // These are found by building a set of all relevant sections.  The first section is the selected root
    // As the sections are in an ordered array we use the following snippet to find the relevant sections:
    //      initialize section set with the root
    //      for each section in the ordered array of sections in the suite
    //          if the parent of the section is in the section set then
    //              add this section to the section set
    //
    stream << "sections = client.send_get('get_sections/" + _projectID + "&suite_id=" + _suiteID + "')\n\n";

    int sectionID = _sectionIDs[_testRailRunSelectorWindow.getSectionID()];

    stream << "relevantSections = { " + QString::number(sectionID) + " }\n";
    stream << "for section in sections:\n";
    stream << "\tif section['parent_id'] in relevantSections:\n";
    stream << "\t\trelevantSections.add(section['id'])\n\n";

    // We now loop over each section in the set and collect the cases into an array
    stream << "cases = []\n";
    stream << "for section_id in relevantSections:\n";
    stream << "\tcases = cases + client.send_get('get_cases/" + _projectID + "&suite_id=" + _suiteID + "&section_id=' + str(section_id))\n\n";

    // To create a run we need an array of the relevant case ids
    stream << "case_ids = []\n";
    stream << "for case in cases:\n";
    stream << "\tcase_ids.append(case['id'])\n\n";

    // Now, we can create the run
    stream << "data = { 'name': '" + _sectionNames[_testRailRunSelectorWindow.getSectionID()].replace("Section", "Run") + "[" +
                  QHostInfo::localHostName() + "]" + "', 'suite_id': " + _suiteID +
                  ", 'include_all': False, 'case_ids': case_ids}\n";

    stream << "run = client.send_post('add_run/" + _projectID + "', data)\n";

    file.close();

    if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created",
                                        "Do you want to run the script and update TestRail?",
                                        QMessageBox::Yes | QMessageBox::No).exec()
    ) {
        QProcess* process = new QProcess();
        connect(process, &QProcess::started, this, [=]() { _busyWindow.exec(); });
        connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
        connect(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this,
                [=](int exitCode, QProcess::ExitStatus exitStatus) { _busyWindow.hide(); });

#ifdef Q_OS_WIN
        QStringList parameters = QStringList() << _outputDirectory + "/addRun.py";
        process->start(_pythonCommand, parameters);
#elif defined Q_OS_MAC
        QStringList parameters = QStringList() << "-c" <<  _pythonCommand + " " + _outputDirectory + "/addRun.py";
        process->start("sh", parameters);
#endif
    }
}
开发者ID:,项目名称:,代码行数:78,代码来源:

示例8: getOperatingSystem

static QString getOperatingSystem()
{
#if defined (Q_OS_WIN32)
    switch(QSysInfo::windowsVersion())
    {
        case QSysInfo::WV_NT:
            return QString::fromLatin1("Windows NT");
        case QSysInfo::WV_2000:
            return QString::fromLatin1("Windows 2000");
        case QSysInfo::WV_XP:
            return QString::fromLatin1("Windows XP");
        case QSysInfo::WV_2003:
            return QString::fromLatin1("Windows Server 2003");
        case QSysInfo::WV_VISTA:
            return QString::fromLatin1("Windows Vista");
        case QSysInfo::WV_WINDOWS7:
            return QString::fromLatin1("Windows 7");
        case QSysInfo::WV_WINDOWS8:
            return QString::fromLatin1("Windows 8");
#if ((QT_VERSION >= 0x050200) || (QT_VERSION >= 0x040806 && QT_VERSION < 0x050000))
        case QSysInfo::WV_WINDOWS8_1:
            return QString::fromLatin1("Windows 8.1");
#endif
#if QT_VERSION >= 0x040807
        case QSysInfo::WV_WINDOWS10:
            return QString::fromLatin1("Windows 10");
#endif
        default:
            return QString::fromLatin1("Windows");
    }
#elif defined (Q_OS_MAC)
    switch(QSysInfo::MacVersion())
    {
        case QSysInfo::MV_10_3:
            return QString::fromLatin1("Mac OS X 10.3");
        case QSysInfo::MV_10_4:
            return QString::fromLatin1("Mac OS X 10.4");
        case QSysInfo::MV_10_5:
            return QString::fromLatin1("Mac OS X 10.5");
        case QSysInfo::MV_10_6:
            return QString::fromLatin1("Mac OS X 10.6");
        case QSysInfo::MV_10_7:
            return QString::fromLatin1("Mac OS X 10.7");
        case QSysInfo::MV_10_8:
            return QString::fromLatin1("Mac OS X 10.8");
        case QSysInfo::MV_10_9:
            return QString::fromLatin1("Mac OS X 10.9");
        default:
            return QString::fromLatin1("Mac OS X");
    }
#elif defined (Q_OS_LINUX)
    QString exe(QLatin1String("lsb_release"));
    QStringList args;
    args << QLatin1String("-ds");
    QProcess proc;
    proc.setEnvironment(QProcess::systemEnvironment());
    proc.start(exe, args);
    if (proc.waitForStarted() && proc.waitForFinished()) {
        QByteArray info = proc.readAll();
        info.replace('\n',"");
        return QString::fromLatin1((const char*)info);
    }

    return QString::fromLatin1("Linux");
#elif defined (Q_OS_UNIX)
    return QString::fromLatin1("UNIX");
#else
    return QString();
#endif
}
开发者ID:maurerpe,项目名称:FreeCAD,代码行数:70,代码来源:Splashscreen.cpp

示例9: align

void AlignmentDialog::align()
{
	// get & convert indi current ra to double
	bool ok;
	indiRa_dh = QString(talk_indi("ra",0)).toDouble(&ok);	//TODO check if valid
	ui->debug->append("RA" + QString::number(indiRa_dh));
	QTime indiRa(0,0,0);
	indiRa = indiRa.addSecs(indiRa_dh*3600);
	ui->label_MountRa->setText(indiRa.toString("hh:mm:ss"));
	
	// get & convert indi current dec to double
	bool ok2;
	indiDe_dh = QString(talk_indi("de",0)).toDouble(&ok2);	//TODO check if valid
	ui->debug->append("DE" + QString::number(indiDe_dh));

	// convert polaris hour angle from qtime to double
	double pha_d = pha.hour() + pha.minute() / 60.0 + pha.second() / 3600.0;  // QTime to double
	ui->debug->append("PHA=" + QString::number(pha_d));
	ui->label_pha->setText(pha.toString("hh:mm:ss"));
	
	// calculate destination ra decimal & QTime
	double destRa_d = (24.0 - pha_d) + indiRa_dh;
	if(destRa_d > 24.0){
		destRa_d = destRa_d - 24.0;
	}
	ui->debug->append("destRa_d=" + QString::number(destRa_d));
	QTime destRa(0,0,0);
	destRa = destRa.addSecs(destRa_d*3600);
	ui->label_destRa->setText(destRa.toString("hh:mm:ss"));
	
	//NOTE set track after set destRa, default for everyone? EQMod Mount.ON_COORD_SET.TRACK=On

	QString message = "be shure your mount does not bump onto cables etc... You can always press "
					  "STOP MOTION if you fear collision, but also keep an eye on the power plug, just in case. I am not responsible for any damage.\n\n" 
					  "Slewing RA from " + indiRa.toString("hh:mm:ss") + " to " + destRa.toString("hh:mm:ss");
	QMessageBox::StandardButton reply;
	reply = QMessageBox::warning(this,"Please NOTICE!", message,QMessageBox::Yes|QMessageBox::No);
	if(reply == QMessageBox::Yes){
		if(ok){
			// disable limits
			QStringList arguments;
			arguments << "-h" << indi_server << "-p" << indi_port << "EQMod Mount.HORIZONLIMITSONLIMIT.HORIZONLIMITSONLIMITTRACK=Off";
			QProcess *myProcess = new QProcess(this);
			myProcess->start(indiset, arguments);
			myProcess->waitForFinished();
			
			arguments.clear();
			arguments << "-h" << indi_server << "-p" << indi_port << "EQMod Mount.HORIZONLIMITSLIMITGOTO.HORIZONLIMITSLIMITGOTODISABLE=On";
			myProcess->start(indiset, arguments);
			myProcess->waitForFinished();
			
			QString destArgs;
			destArgs = "EQMod Mount.EQUATORIAL_EOD_COORD.RA;DEC=" + QString::number(destRa_d) + ";" + QString::number(indiDe_dh);
		
			// goto destRa
			arguments.clear();
			arguments << "-h" << indi_server << "-p" << indi_port << destArgs;
			myProcess->start(indiset, arguments);
			myProcess->waitForFinished();
		}
		else{
			QMessageBox::warning(this,"ERROR", "RA is not valid, will not slew!");
		}
	}
}
开发者ID:pauledd,项目名称:polarisAlignmentTool,代码行数:65,代码来源:alignmentdialog.cpp

示例10: talk_indi

QString AlignmentDialog::talk_indi(QString const &cmd, bool const &getset)
{
	QString ret;
	QString indicmd;
	QString prop;
	QStringList arguments;
	QProcess *myProcess = new QProcess(this);
	if (getset == 0){								// get property
		indicmd = indiget;
		if (cmd == "connect"){
			prop = movecmds.at(25);
		}
		else if (cmd == "park"){
			prop = movecmds.at(26);
		}
		else if (cmd == "ra"){
			prop = movecmds.at(24);
		}
		else if (cmd == "de"){
			prop = movecmds.at(23);
		}
		else if(cmd == "idle"){
			QStringList a,b;
			b << "Busy" << "Busy" << "Busy" << "Busy";
			for(unsigned int i=27;i<31;i++){
				prop = movecmds.at(i);
				arguments << "-1" << "-h" << indi_server << "-p" << indi_port << prop;
				myProcess->start(indicmd, arguments);
				myProcess->waitForFinished();
				a << myProcess->readAllStandardOutput().simplified();
				ui->debug->append(a.join(" "));
				arguments.clear();
				prop.clear();
				ret = (a==b)?"idle":"busy";
			}
		}
	}
	else if (getset == 1){							// set property
		indicmd = indiset;
		if (cmd == "connect"){
			prop = movecmds.at(4);
		}
		else if(cmd == "park"){
			prop = movecmds.at(6);
		}
		else if(cmd == "unpark"){
			prop = movecmds.at(5);
		}
		else if(cmd == "abort"){
			prop = movecmds.at(3);
		}
		else if(cmd == "move.dec.pos.start"){
			prop = movecmds.at(7);
		}
		else if(cmd == "move.dec.pos.stop"){
			prop = movecmds.at(8);
		}
		else if(cmd == "move.dec.neg.start"){
			prop = movecmds.at(9);
		}
		else if(cmd == "move.dec.neg.stop"){
			prop = movecmds.at(10);
		}
		else if(cmd == "move.ra.pos.start"){
			prop = movecmds.at(11);
		}
		else if(cmd == "move.ra.pos.stop"){
			prop = movecmds.at(12);
		}
		else if(cmd == "move.ra.neg.start"){
			prop = movecmds.at(13);
		}
		else if(cmd == "move.ra.neg.stop"){
			prop = movecmds.at(14);
		}
		else if(cmd == "speed"){
			if(ui->comboBox_speed->currentText() == "64"){
				prop = movecmds.at(32);
			}
			else if(ui->comboBox_speed->currentText() == "128"){
				prop = movecmds.at(33);
			}
			else {
				prop = movecmds.at(34);
			}
		}
	}
	else {
		ui->debug->append("ERROR, getset is not 0,1");
	}
	
	if (getset == 0){
		arguments << "-1" << "-h" << indi_server << "-p" << indi_port << prop;		
	}
	else {
		arguments << "-h" << indi_server << "-p" << indi_port << prop;		
	}
	
	if (cmd != "idle"){
	myProcess->start(indicmd, arguments);
//.........这里部分代码省略.........
开发者ID:pauledd,项目名称:polarisAlignmentTool,代码行数:101,代码来源:alignmentdialog.cpp

示例11: start_new_client

void MainWindow::start_new_client()
{
    QProcess *p = new QProcess(this);
    p->start(_process_name, QStringList("client"));
}
开发者ID:karagog,项目名称:gutil,代码行数:5,代码来源:mainwindow.cpp

示例12: main

int main(int argc, char *argv[])
{
    bool running = false;


        TFullName res;
        TFindProcess find;
        while(find.Next(res) == KErrNone)
        {
            RProcess ph;
            ph.Open(res);

            if(ph.SecureId() == 0x2002B30D)

            if (ph.ExitType() == EExitPending)
            {
                running = true;
                break;
            }

            ph.Close();
        }



    if (running == false)
    {

        QProcess *myProcess = new QProcess;
        myProcess->start("whatsapp.exe");
    }
    else {

        QApplication app(argc, argv);
        CAknConfirmationNote* run = new (ELeave) CAknConfirmationNote;
        QT_TRAP_THROWING(run->ExecuteLD(_L("Closed WhatsApp")));
        TFullName res1;
        TFindProcess find1(_L("*[2002B306]*"));

        while(find1.Next(res1) == KErrNone)
        {
            RProcess ph1;
            ph1.Open(find1);
            ph1.Kill(KErrNone);
            ph1.Close();
        }

        TFullName res2;
        TFindProcess find2(_L("*[2002B310]*"));

        while(find2.Next(res2) == KErrNone)
        {
            RProcess ph2;
            ph2.Open(find2);
            ph2.Kill(KErrNone);
            ph2.Close();
        }

        TFullName res3;
        TFindProcess find3(_L("*[2002B30D]*"));

        while(find3.Next(res3) == KErrNone)
        {
            RProcess ph3;
            ph3.Open(find3);
            ph3.Kill(KErrNone);
            ph3.Close();
        }
        QTest::qWait(1500);
    }
    return 1;
}
开发者ID:huellif,项目名称:WA_Toggle,代码行数:72,代码来源:main.cpp

示例13: spawnChildClient

void AssignmentClientMonitor::spawnChildClient() {
    QProcess* assignmentClient = new QProcess(this);


    // unparse the parts of the command-line that the child cares about
    QStringList _childArguments;
    if (_assignmentPool != "") {
        _childArguments.append("--" + ASSIGNMENT_POOL_OPTION);
        _childArguments.append(_assignmentPool);
    }
    if (!_walletUUID.isNull()) {
        _childArguments.append("--" + ASSIGNMENT_WALLET_DESTINATION_ID_OPTION);
        _childArguments.append(_walletUUID.toString());
    }
    if (_assignmentServerHostname != "") {
        _childArguments.append("--" + CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION);
        _childArguments.append(_assignmentServerHostname);
    }
    if (_assignmentServerPort != DEFAULT_DOMAIN_SERVER_PORT) {
        _childArguments.append("--" + CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION);
        _childArguments.append(QString::number(_assignmentServerPort));
    }
    if (_requestAssignmentType != Assignment::AllTypes) {
        _childArguments.append("--" + ASSIGNMENT_TYPE_OVERRIDE_OPTION);
        _childArguments.append(QString::number(_requestAssignmentType));
    }

    // tell children which assignment monitor port to use
    // for now they simply talk to us on localhost
    _childArguments.append("--" + ASSIGNMENT_CLIENT_MONITOR_PORT_OPTION);
    _childArguments.append(QString::number(DependencyManager::get<NodeList>()->getLocalSockAddr().getPort()));

    QString nowString, stdoutFilenameTemp, stderrFilenameTemp, stdoutPathTemp, stderrPathTemp;


    if (_wantsChildFileLogging) {
        // Setup log files
        const QString DATETIME_FORMAT = "yyyyMMdd.hh.mm.ss.zzz";

        if (!_logDirectory.exists()) {
            qDebug() << "Log directory (" << _logDirectory.absolutePath() << ") does not exist, creating.";
            _logDirectory.mkpath(_logDirectory.absolutePath());
        }

        nowString = QDateTime::currentDateTime().toString(DATETIME_FORMAT);
        stdoutFilenameTemp = QString("ac-%1-stdout.txt").arg(nowString);
        stderrFilenameTemp = QString("ac-%1-stderr.txt").arg(nowString);
        stdoutPathTemp = _logDirectory.absoluteFilePath(stdoutFilenameTemp);
        stderrPathTemp = _logDirectory.absoluteFilePath(stderrFilenameTemp);

        // reset our output and error files
        assignmentClient->setStandardOutputFile(stdoutPathTemp);
        assignmentClient->setStandardErrorFile(stderrPathTemp);
    }

    // make sure that the output from the child process appears in our output
    assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels);
    assignmentClient->start(QCoreApplication::applicationFilePath(), _childArguments);

    QString stdoutPath, stderrPath;

    if (_wantsChildFileLogging) {

        // Update log path to use PID in filename
        auto stdoutFilename = QString("ac-%1_%2-stdout.txt").arg(nowString).arg(assignmentClient->processId());
        auto stderrFilename = QString("ac-%1_%2-stderr.txt").arg(nowString).arg(assignmentClient->processId());
        stdoutPath = _logDirectory.absoluteFilePath(stdoutFilename);
        stderrPath = _logDirectory.absoluteFilePath(stderrFilename);

        qDebug() << "Renaming " << stdoutPathTemp << " to " << stdoutPath;
        if (!_logDirectory.rename(stdoutFilenameTemp, stdoutFilename)) {
            qDebug() << "Failed to rename " << stdoutFilenameTemp;
            stdoutPath = stdoutPathTemp;
            stdoutFilename = stdoutFilenameTemp;
        }

        qDebug() << "Renaming " << stderrPathTemp << " to " << stderrPath;
        if (!QFile::rename(stderrPathTemp, stderrPath)) {
            qDebug() << "Failed to rename " << stderrFilenameTemp;
            stderrPath = stderrPathTemp;
            stderrFilename = stderrFilenameTemp;
        }
        
        qDebug() << "Child stdout being written to: " << stdoutFilename;
        qDebug() << "Child stderr being written to: " << stderrFilename;
    }

    if (assignmentClient->processId() > 0) {
        auto pid = assignmentClient->processId();
        // make sure we hear that this process has finished when it does
        connect(assignmentClient, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
                this, [this, pid]() { childProcessFinished(pid); });

        qDebug() << "Spawned a child client with PID" << assignmentClient->processId();

        _childProcesses.insert(assignmentClient->processId(), { assignmentClient, stdoutPath, stderrPath });
    }
}
开发者ID:AlexanderOtavka,项目名称:hifi,代码行数:98,代码来源:AssignmentClientMonitor.cpp

示例14: doPrintFile

void FilePrinter::doPrintFile( QPrinter &printer, const QString &file, FileDeletePolicy fileDeletePolicy,
                               PageSelectPolicy pageSelectPolicy, const QString &pageRange )
{

    if (!QFile::exists(file)) {
        return;
    }

    bool doDeleteFile = (fileDeletePolicy == FilePrinter::SystemDeletesFiles);

    if ( printer.printerState() == QPrinter::Aborted || printer.printerState() == QPrinter::Error ) {
        if ( doDeleteFile ) {
            QFile::remove( file );
        }
        return;
    }


    // Print to a printer via lpr command

    //Decide what executable to use to print with, need the CUPS version of lpr if available
    //Some distros name the CUPS version of lpr as lpr-cups or lpr.cups so try those first 
    //before default to lpr, or failing that to lp

    QString exe;
    if ( !QStandardPaths::findExecutable(QStringLiteral("lpr-cups")).isEmpty() ) {
        exe = QStringLiteral("lpr-cups");
    } else if ( !QStandardPaths::findExecutable(QStringLiteral("lpr.cups")).isEmpty() ) {
        exe = QStringLiteral("lpr.cups");
    } else if ( !QStandardPaths::findExecutable(QStringLiteral("lpr")).isEmpty() ) {
        exe = QStringLiteral("lpr");
    } else if ( !QStandardPaths::findExecutable(QStringLiteral("lp")).isEmpty() ) {
        exe = QStringLiteral("lp");
    } else {
        if ( doDeleteFile ) {
            QFile::remove( file );
        }
        return;
    }

    bool useCupsOptions = cupsAvailable();
    QStringList argList = printArguments( printer, fileDeletePolicy, pageSelectPolicy,
                                          useCupsOptions, pageRange, exe ) << file;

    QProcess *process = new QProcess();
    QObject::connect(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), [=](QProcess::ProcessError) {
        if ( doDeleteFile ) {
            QFile::remove( file );
        }
        process->deleteLater();
    });
    QObject::connect(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus) {
        if ( doDeleteFile && (exitStatus != QProcess::NormalExit || exitCode != 0) ) {
            // lpr failed, so delete the temporary file in case it still exists.
            // In case of success, we let lpr delete it, it knows best when it is safe to do so.
            // (lpr queues jobs asynchronously.)
            QFile::remove( file );
        }
        process->deleteLater();
    });
    process->start( exe, argList );
}
开发者ID:,项目名称:,代码行数:62,代码来源:

示例15: generate

bool generate(const ToolListType & tools, const String & prefix, const String & binary_directory)
{
  bool errors_occured = false;
  for (ToolListType::const_iterator it = tools.begin(); it != tools.end(); ++it)
  {
    //start process
    QProcess process;
    process.setProcessChannelMode(QProcess::MergedChannels);
    QStringList env = QProcess::systemEnvironment();
    env << String("COLUMNS=110").toQString(); // Add an environment variable (used by each TOPP tool to determine width of help text (see TOPPBase))
    process.setEnvironment(env);

    String command = binary_directory + it->first;
#if defined(__APPLE__)
    if (it->first == "TOPPView" || it->first == "TOPPAS")
    {
      command = binary_directory + it->first + ".app/Contents/MacOS/" + it->first;
    }
#endif
#ifdef OPENMS_WINDOWSPLATFORM
	command += ".exe"; // otherwise File::exists() will fail
#endif

    ofstream f((String("output/") + prefix + it->first + ".cli").c_str());
	if (!File::exists(command))
	{
	  stringstream ss;
	  ss << "Errors occurred while generating the command line documentation for " << it->first << "!" << endl;
      ss << "Tool could not be found at '" << command << "'\n " << command << endl;
	  f << ss.str();
	  cerr << ss.str();
      errors_occured = true;
	  f.close();
	  continue;
 	}
	else
	{
      process.start(String(command + " --help").toQString());
	  process.waitForFinished();

	  std::string lines = QString(process.readAll()).toStdString();
	  if (process.error() != QProcess::UnknownError)
	  {
	    // error while generation cli docu
	    stringstream ss;
	    f << "Errors occurred while generating the command line documentation for " << it->first << "!" << endl;
	    f << "Output was: \n" << lines << endl;
	    f << "Command line was: \n " << command << endl;
	    f << ss.str();
	    cerr << ss.str();
        errors_occured = true;
	    f.close();
	    continue;
	  }
	  else
	  {
	  // write output
	    f << lines;
	  }
	}
    f.close();

    //////
    // get the INI file and convert it into HTML
    //////
    if (it->first == "GenericWrapper")
      continue;                                  // does not support -write_ini without a type
    if (it->first == "TOPPView")
      continue;                            // does not support -write_ini
    if (it->first == "TOPPAS")
      continue;                          // does not support -write_ini
    String tmp_file = File::getTempDirectory() + "/" + File::getUniqueName() + "_" + it->first + ".ini";
    process.start((command + " -write_ini " + tmp_file).toQString());
    process.waitForFinished();
    Param p;
    ParamXMLFile pf;
    pf.load(tmp_file, p);
    File::remove(tmp_file);
    ofstream f_html((String("output/") + prefix + it->first + ".html").c_str());
    convertINI2HTML(p, f_html);
    f_html.close();
  }
  return errors_occured;
}
开发者ID:BioITer,项目名称:OpenMS,代码行数:84,代码来源:TOPPDocumenter.C


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