コード例 #1
0
ファイル: myprocess.cpp プロジェクト: slyshykO/qgit
void MyProcess::on_finished(int exitCode, QProcess::ExitStatus exitStatus) {
	// Checking exingStatus is not reliable under Windows where if the
	// process was terminated with TerminateProcess() from another
	// application its value is still NormalExit
	//
	// Checking exit code for a failing command is unreliable too, as
	// exmple 'git status' returns 1 also without errors.
	//
	// On Windows exit code seems reliable in case of a command wrapped
	// in Window shell interpreter.
	//
	// So to detect a failing command we check also if stderr is not empty.
	QString errorDesc(readAllStandardError());

	isErrorExit =   (exitStatus != QProcess::NormalExit)
	             || (exitCode != 0 && isWinShell)
	             || !errorDesc.isEmpty()
	             ||  canceling;

	if (!canceling) { // no more noise after cancel

		if (receiver)
			emit eof();

		if (isErrorExit)
			sendErrorMsg(false, errorDesc);
	}
	busy = false;
	if (async)
		deleteLater();
}
コード例 #2
0
ファイル: shx.cpp プロジェクト: ForNeVeR/leechcraft
	void Plugin::handleFinished ()
	{
		auto proc = qobject_cast<QProcess*> (sender ());
		proc->deleteLater ();

		const auto entryObj = Process2Entry_.take (proc);
		if (!entryObj)
		{
			qWarning () << Q_FUNC_INFO
					<< "no entry for process"
					<< proc;
			return;
		}
#ifdef Q_OS_WIN32
		auto out = QString::fromUtf16 (reinterpret_cast<const ushort*> (proc->readAllStandardOutput ().constData ()));
#else
		auto out = QString::fromUtf8 (proc->readAllStandardOutput ());
#endif
		const auto& err = proc->readAllStandardError ();

		if (!err.isEmpty ())
#ifdef Q_OS_WIN32
			out.prepend (tr ("Error: %1").arg (QString::fromUtf16 (reinterpret_cast<const ushort*> (err.constData ()))) + "\n");
#else
			out.prepend (tr ("Error: %1").arg (QString::fromUtf8 (err)) + "\n");
#endif

		const auto entry = qobject_cast<ICLEntry*> (entryObj);
		AzothProxy_->OpenChat (entry->GetEntryID (),
				entry->GetParentAccount ()->GetAccountID (),
				out);
	}
コード例 #3
0
ファイル: shx.cpp プロジェクト: mirok0/leechcraft
	void Plugin::handleFinished ()
	{
		auto proc = qobject_cast<QProcess*> (sender ());
		proc->deleteLater ();

		if (!Process2Chat_.contains (proc))
		{
			qWarning () << Q_FUNC_INFO
					<< "no chat for process"
					<< proc;
			return;
		}
#ifdef Q_OS_WIN32
		auto out = QString::fromUtf16 (reinterpret_cast<const ushort*> (proc->readAllStandardOutput ().constData ()));
#else
		auto out = QString::fromUtf8 (proc->readAllStandardOutput ());
#endif
		const auto& err = proc->readAllStandardError ();

		if (!err.isEmpty ())
#ifdef Q_OS_WIN32
			out.prepend (tr ("Error: %1").arg (QString::fromUtf16 (reinterpret_cast<const ushort*> (err.constData ()))) + "\n");
#else
			out.prepend (tr ("Error: %1").arg (QString::fromUtf8 (err)) + "\n");
#endif

		QMetaObject::invokeMethod (Process2Chat_.take (proc),
				"prepareMessageText",
				Q_ARG (QString, out));
	}
コード例 #4
0
ファイル: myprocess.cpp プロジェクト: slyshykO/qgit
void MyProcess::on_readyReadStandardError() {
	if (canceling)
		return;

	if (receiver)
		emit procDataReady(readAllStandardError()); // redirect to stdout
	else
		dbs("ASSERT in myReadFromStderr: NULL receiver");
}
コード例 #5
0
ファイル: frontend.cpp プロジェクト: AlexanderStein/kscope4
/**
 * Reads data written on the standard error by the controlled process.
 * This is a private slot called attached to the readyReadStderr() signal of
 * the controlled process, which means that it is called whenever data is
 * ready to be read from the process' stream.
 * The method reads whatever data is queued, and sends it to be interpreted
 * by parseStderr().
 */
void Frontend::slotReadStderr()
{
	QString sBuf;
	QByteArray ba = readAllStandardError();

	// Do nothing if waiting for process to die
	if (m_bKilled)
		return;

	sBuf.fromLatin1(ba.data(), ba.length());
	parseStderr(sBuf);
}
コード例 #6
0
ファイル: pluginprocess.cpp プロジェクト: pdautry/PTRS
void PluginProcess::SLOT_FINISHED(int exitCode, QProcess::ExitStatus exitStatus)
{   LOG_DEBUG(QString("SLOT_FINISHED(%1,%2) called.").arg(exitCode).arg(exitStatus));
    switch (exitStatus) {
    case QProcess::NormalExit:
        if(exitCode == 0)
        {
            _calculation->Slot_computed(QUrl::fromPercentEncoding(readAllStandardOutput()).toUtf8());
        }
        else
        {   LOG_ERROR(QString("Process crashed (exit_code=%1).").arg(exitCode));
            // crash calculation
            _calculation->Slot_crashed(readAllStandardError());
        }
        break;
    case QProcess::CrashExit:
        LOG_ERROR(QString("Process crashed (exit_code=%1).").arg(exitCode));
        // crash calculation
        _calculation->Slot_crashed(readAllStandardError());
        break;
    }
}
コード例 #7
0
ファイル: myprocess.cpp プロジェクト: rhaschke/qgit
void MyProcess::on_readyReadStandardError() {

	if (canceling)
		return;

	if (receiver) {
		QByteArray err = readAllStandardError();
		accError += err;
		emit procDataReady(err); // redirect to stdout
	} else
		dbs("ASSERT in myReadFromStderr: NULL receiver");
}
コード例 #8
0
/*
  Filter the error output from the uploader to make it
  more useful to the user.
*/
void Uploader::filterError( )
{
  QString err(readAllStandardError());
  if(err.startsWith("can't find boot agent"))
  {
    mainWindow->printOutputError(tr("Error - couldn't find an unprogrammed board to upload to."));
    mainWindow->printOutputError(tr("  Make sure you've erased and unplugged/replugged your board."));
  }
  else
    qDebug("upload err: %s", qPrintable(err));
  //mainWindow->printOutputError(readAllStandardError());
}
コード例 #9
0
ファイル: myprocess.cpp プロジェクト: slyshykO/qgit
void MyProcess::sendErrorMsg(bool notStarted, SCRef err) {
	if (!errorReportingEnabled)
		return;

	QString errorDesc(readAllStandardError());
	errorDesc.prepend(err);

	if (notStarted)
        errorDesc = QString::fromLatin1("Unable to start the process!");

	const QString cmd(arguments.join(" ")); // hide any QUOTE_CHAR or related stuff
	MainExecErrorEvent* e = new MainExecErrorEvent(cmd, errorDesc);
	QApplication::postEvent(guiObject, e);
}
コード例 #10
0
ファイル: ipprocess.cpp プロジェクト: tailored/qiptables
QString IpProcess::executeSynchronous(const QString &program, const QStringList &arguments)
{
    QString empty("");
    QString result("");

    printCmdLine(program, arguments);

    if (arguments.count() > 0)
    {
        start(program, arguments);
    }
    else
    {
        start(program);
    }

    if (! waitForStarted())
        return empty;

    closeWriteChannel();

    int secondsToWait = 30;
    if (! waitForFinished(secondsToWait * 1000))
        return empty;

    // exit code of zero means command completed ok
    // and that output is from stdout - error output is on stderrs
    if ( (exitCode() == 0) && (errStr.isEmpty()) )
    {
        result = QString(QString(readAllStandardOutput()));
    }
    else
    {
        result = QString(QString(readAllStandardError()));
    }

    if (result.isEmpty())
    {
        // result = parseErrorCode();
    }

    // Send the result of executing the command
    emit cmdOutput(program, arguments, exitCode(), result);

    return QString(result);
}
コード例 #11
0
void Kleo::SymCryptRunProcessBase::slotReadyReadStandardError() {
  mStderr += readAllStandardError();
}
コード例 #12
0
ファイル: action.cpp プロジェクト: Mic92/CopyQ
void Action::actionErrorOutput()
{
    m_errstr += QString::fromLocal8Bit( readAllStandardError() );
}
コード例 #13
0
bool ExportSpreadsheet::exportSpreadsheet(const analysisdriver::SimpleProject& project)
{
    //Make sure a QApplication exists
    openstudio::Application::instance().application();

    //get the project's directory
    openstudio::path projectPath = project.projectDir();

    LOG_FREE(Debug, "ExportSpreadsheet", "Starting export of projectPath:" << toString(projectPath));

    openstudio::path rubyPath;
#if defined(Q_OS_WIN)
    rubyPath = getOpenStudioEmbeddedRubyPath() / toPath("bin/ruby.exe");
#else
    rubyPath = "ruby";
#endif

    openstudio::path rubyIncludePath = getOpenStudioRubyIncludePath();
    if (!boost::filesystem::exists(rubyIncludePath)) {
        LOG_FREE(Error, "ExportSpreadsheet", "Ruby include path '" << rubyIncludePath << "' cannot be found.");
        return false;
    }

    openstudio::path scriptPath = getOpenStudioRubyScriptsPath() / openstudio::toPath("openstudio/analysisdriver/ExportToSpreadsheet.rb");
    if (!boost::filesystem::exists(scriptPath)) {
        LOG_FREE(Error, "ExportSpreadsheet", "ExportToSpreadsheet script '" << scriptPath << "' cannot be found.");
        return false;
    }

    QStringList args;
    args << "-I";
    args << openstudio::toQString(rubyIncludePath);
    args << openstudio::toQString(scriptPath);
    args << openstudio::toQString(projectPath);

    auto p = new QProcess();
    p->start(toQString(rubyPath), args);

    if (!p->waitForStarted(30000)) {
        p->terminate();
        p->deleteLater();
        LOG_FREE(Error, "ExportSpreadsheet", "Process failed to start");
        return false;
    }

    if (!p->waitForFinished(300000)) {
        p->terminate();
        p->deleteLater();
        LOG_FREE(Error, "ExportSpreadsheet", "Process failed to complete");
        return false;
    }

    QByteArray error = p->readAllStandardError();
    std::string errorString = toString(QString(error));
    LOG_FREE(Debug, "ExportSpreadsheet", "StandardError:" << std::endl << errorString);
    QByteArray output = p->readAllStandardOutput();
    std::string outputString = toString(QString(output));
    LOG_FREE(Debug, "ExportSpreadsheet", "StandardOutput:" << std::endl << outputString);

    // remove previous export
    openstudio::path exportPath = projectPath / toPath("analysis_spreadsheet_export");
    openstudio::path modelMeasuresCSV = exportPath / toPath("spreadsheet_model_measures_export.csv");
    openstudio::path energyplusMeasuresCSV = exportPath / toPath("spreadsheet_energyplus_measures_export.csv");
    openstudio::path reportingMeasuresCSV = exportPath / toPath("spreadsheet_reporting_measures_export.csv");
    openstudio::path outputsCSV = exportPath / toPath("spreadsheet_outputs_export.csv");

    bool result = ((p->exitStatus() == QProcess::NormalExit) &&
                   boost::filesystem::exists(modelMeasuresCSV) &&
                   boost::filesystem::exists(energyplusMeasuresCSV) &&
                   boost::filesystem::exists(reportingMeasuresCSV) &&
                   boost::filesystem::exists(outputsCSV));

    p->deleteLater();
    return result;
}