Commit 5094fe20 authored by Christian Kandeler's avatar Christian Kandeler

RemoteLinux: Make environment reader check for exit code from env.

A non-existing command may not always result in a "FailedToStart" error,
but can also lead to "normal" finish with a non-zero exit code (from the
shell), which means that people whose remote system is missing the "env"
command currently get no feedback at all when pressing the "Fetch"
button. (Independent of this, the exit code should always be checked
anyway.)

Change-Id: I1387897436825c18e7df2d03d5ee3870ff6b70f5
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent add39a58
......@@ -90,30 +90,37 @@ void RemoteLinuxEnvironmentReader::handleCurrentDeviceConfigChanged()
setFinished();
}
void RemoteLinuxEnvironmentReader::remoteProcessFinished(int exitCode)
void RemoteLinuxEnvironmentReader::remoteProcessFinished(int exitStatus)
{
Q_ASSERT(exitCode == QSsh::SshRemoteProcess::FailedToStart
|| exitCode == QSsh::SshRemoteProcess::CrashExit
|| exitCode == QSsh::SshRemoteProcess::NormalExit);
Q_ASSERT(exitStatus == QSsh::SshRemoteProcess::FailedToStart
|| exitStatus == QSsh::SshRemoteProcess::CrashExit
|| exitStatus == QSsh::SshRemoteProcess::NormalExit);
if (m_stop)
return;
disconnect(m_remoteProcessRunner, 0, this, 0);
m_env.clear();
if (exitCode == QSsh::SshRemoteProcess::NormalExit) {
QString errorMessage;
if (exitStatus != QSsh::SshRemoteProcess::NormalExit) {
errorMessage = m_remoteProcessRunner->processErrorString();
} else if (m_remoteProcessRunner->processExitCode() != 0) {
errorMessage = tr("Process exited with code %1.")
.arg(m_remoteProcessRunner->processExitCode());
}
if (!errorMessage.isEmpty()) {
errorMessage = tr("Error running 'env': %1").arg(errorMessage);
const QString remoteStderr
= QString::fromUtf8(m_remoteProcessRunner->readAllStandardError()).trimmed();
if (!remoteStderr.isEmpty())
errorMessage += tr("\nRemote stderr was: '%1'").arg(remoteStderr);
emit error(errorMessage);
} else {
QString remoteOutput = QString::fromUtf8(m_remoteProcessRunner->readAllStandardOutput());
if (!remoteOutput.isEmpty()) {
m_env = Utils::Environment(remoteOutput.split(QLatin1Char('\n'),
QString::SkipEmptyParts), Utils::OsTypeLinux);
}
} else {
QString errorMsg = tr("Error running remote process: %1")
.arg(m_remoteProcessRunner->processErrorString());
QString remoteStderr = QString::fromUtf8(m_remoteProcessRunner->readAllStandardError());
if (!remoteStderr.isEmpty())
errorMsg += tr("\nRemote stderr was: '%1'").arg(remoteStderr);
emit error(errorMsg);
}
setFinished();
}
......
......@@ -64,7 +64,7 @@ private slots:
void handleConnectionFailure();
void handleCurrentDeviceConfigChanged();
void remoteProcessFinished(int exitCode);
void remoteProcessFinished(int exitStatus);
private:
void setFinished();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment