bool SvnCommand::Execute(const wxString& command, const wxString& workingDirectory, SvnCommandHandler *handler) { // Dont run 2 commands at the same time if(m_process) { if(handler) { //handler->GetPlugin()->GetShell()->AppendText(svnANOTHER_PROCESS_RUNNING); delete handler; } return false; } ClearAll(); // Wrap the command in the OS Shell wxString cmdShell (command); WrapInShell(cmdShell); m_process = CreateAsyncProcess(this, command, workingDirectory); if ( !m_process ) { return false; } m_workingDirectory = workingDirectory.c_str(); m_command = command.c_str(); m_handler = handler; return true; }
bool SvnCommand::Execute(const wxString &command, const wxString &workingDirectory, SvnCommandHandler *handler, Subversion2 *plugin) { // Dont run 2 commands at the same time if(m_process) { if(handler) { //handler->GetPlugin()->GetShell()->AppendText(svnANOTHER_PROCESS_RUNNING); delete handler; } return false; } ClearAll(); // Wrap the command in the OS Shell wxString cmdShell (command); WrapInShell(cmdShell); // Apply the environment variables before executing the command wxStringMap_t om; om.insert( std::make_pair("LC_ALL", "C")); bool useOverrideMap = m_plugin->GetSettings().GetFlags() & SvnUsePosixLocale; EnvSetter env(m_plugin->GetManager()->GetEnv(), useOverrideMap ? &om : NULL); m_process = CreateAsyncProcess(this, command, IProcessCreateDefault, workingDirectory); if ( !m_process ) { return false; } m_workingDirectory = workingDirectory.c_str(); m_command = command.c_str(); m_handler = handler; return true; }
void SvnConsole::DoProcessNextCommand() { // If another process is running, we try again when the process is termianted if (m_process) { return; } if(m_queue.empty()) return; // Remove the command from the queue SvnConsoleCommand *command = m_queue.front(); m_queue.pop_front(); m_output.Clear(); m_currCmd.clean(); m_currCmd = *command; // Delete it delete command; EnsureVisible(); // Print the command? AppendText(m_currCmd.cmd + wxT("\n")); // Wrap the command in the OS Shell wxString cmdShell (m_currCmd.cmd); // Apply the environment variables before executing the command wxStringMap_t om; om.insert( std::make_pair( "LC_ALL", "C" ) ); bool useOverrideMap = m_plugin->GetSettings().GetFlags() & SvnUsePosixLocale; EnvSetter env(m_plugin->GetManager()->GetEnv(), useOverrideMap ? &om : NULL); m_process = CreateAsyncProcess(this, cmdShell, IProcessCreateWithHiddenConsole, m_currCmd.workingDirectory); if (!m_process) { AppendText(_("Failed to launch Subversion client.\n")); return; } m_sci->SetFocus(); }
bool FGSimulator::setupProcess() { QMutexLocker locker(&lock); // Copy FlightGear generic protocol configuration file to the FG protocol directory // NOTE: Not working on Windows 7, if FG is installed in the "Program Files", // likelly due to permissions. The file should be manually copied to data/Protocol/opfgprotocol.xml // QFile xmlFile(":/flightgear/genericprotocol/opfgprotocol.xml"); // xmlFile.open(QIODevice::ReadOnly | QIODevice::Text); // QString xml = xmlFile.readAll(); // xmlFile.close(); // QFile xmlFileOut(pathData + "/Protocol/opfgprotocol.xml"); // xmlFileOut.open(QIODevice::WriteOnly | QIODevice::Text); // xmlFileOut.write(xml.toAscii()); // xmlFileOut.close(); Qt::HANDLE mainThread = QThread::currentThreadId(); qDebug() << "setupProcess Thread: " << mainThread; simProcess = new QProcess(); simProcess->setReadChannelMode(QProcess::MergedChannels); connect(simProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyRead())); // Note: Only tested on windows 7 #if defined(Q_WS_WIN) QString cmdShell("c:/windows/system32/cmd.exe"); #else QString cmdShell("bash"); #endif // Start shell (Note: Could not start FG directly on Windows, only through terminal!) simProcess->start(cmdShell); if (simProcess->waitForStarted() == false) { emit processOutput("Error:" + simProcess->errorString()); return false; } // Setup arguments // Note: The input generic protocol is set to update at a much higher rate than the actual updates are sent by the GCS. // If this is not done then a lag will be introduced by FlightGear, likelly because the receive socket buffer builds up during startup. QString args("--fg-root=\"" + settings.dataPath + "\" " + "--timeofday=noon " + "--httpd=5400 " + "--enable-hud " + "--in-air " + "--altitude=3000 " + "--vc=100 " + "--log-level=alert " + "--generic=socket,out,20," + settings.hostAddress + "," + QString::number(settings.inPort) + ",udp,opfgprotocol"); if (settings.manualControlEnabled) { // <--[BCH] What does this do? Why does it depend on ManualControl? args.append(" --generic=socket,in,400," + settings.remoteAddress + "," + QString::number(settings.outPort) + ",udp,opfgprotocol"); } // Start FlightGear - only if checkbox is selected in HITL options page if (settings.startSim) { QString cmd("\"" + settings.binPath + "\" " + args + "\n"); simProcess->write(cmd.toAscii()); } else { emit processOutput("Start Flightgear from the command line with the following arguments: \n\n" + args + "\n\n" + "You can optionally run Flightgear from a networked computer.\n" + "Make sure the computer running Flightgear can can ping your local interface adapter. ie." + settings.hostAddress + "\n" "Remote computer must have the correct OpenPilot protocol installed."); } udpCounterGCSsend = 0; return true; }