RemoteLinux: Drop some in-class signalling

Not needed since the deploy step and service hierarchy merge.

Change-Id: I644bdeca31caa2182b9d618e5f1ec6865c95f4c8
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-03-22 09:34:34 +01:00
parent a4ed630c7d
commit c6b6e5b0c6
10 changed files with 73 additions and 87 deletions

View File

@@ -58,17 +58,17 @@ private:
process.setCommand(cmd);
QtcProcess *proc = &process;
connect(proc, &QtcProcess::readyReadStandardError, this, [this, proc] {
emit stdErrData(proc->readAllStandardError());
handleStdErrData(proc->readAllStandardError());
});
};
const auto doneHandler = [this](const QtcProcess &) {
if (m_makeDefault)
emit progressMessage(Tr::tr("Application set as the default one."));
addProgressMessage(Tr::tr("Application set as the default one."));
else
emit progressMessage(Tr::tr("Reset the default application."));
addProgressMessage(Tr::tr("Reset the default application."));
};
const auto errorHandler = [this](const QtcProcess &process) {
emit errorMessage(Tr::tr("Remote process failed: %1").arg(process.errorString()));
addErrorMessage(Tr::tr("Remote process failed: %1").arg(process.errorString()));
};
return Group { Process(setupHandler, doneHandler, errorHandler) };
}

View File

@@ -43,7 +43,7 @@ Group QdbStopApplicationStep::deployRecipe()
const auto setupHandler = [this](QtcProcess &process) {
const auto device = DeviceKitAspect::device(target()->kit());
if (!device) {
emit errorMessage(Tr::tr("No device to stop the application on."));
addErrorMessage(Tr::tr("No device to stop the application on."));
return TaskAction::StopWithError;
}
QTC_CHECK(device);
@@ -51,25 +51,25 @@ Group QdbStopApplicationStep::deployRecipe()
process.setWorkingDirectory("/usr/bin");
QtcProcess *proc = &process;
connect(proc, &QtcProcess::readyReadStandardOutput, this, [this, proc] {
emit stdOutData(proc->readAllStandardOutput());
handleStdOutData(proc->readAllStandardOutput());
});
return TaskAction::Continue;
};
const auto doneHandler = [this](const QtcProcess &) {
emit progressMessage(Tr::tr("Stopped the running application."));
addProgressMessage(Tr::tr("Stopped the running application."));
};
const auto errorHandler = [this](const QtcProcess &process) {
const QString errorOutput = process.cleanedStdErr();
const QString failureMessage = Tr::tr("Could not check and possibly stop running application.");
if (process.exitStatus() == QProcess::CrashExit) {
emit errorMessage(failureMessage);
addErrorMessage(failureMessage);
} else if (process.result() != ProcessResult::FinishedWithSuccess) {
emit stdErrData(process.errorString());
handleStdErrData(process.errorString());
} else if (errorOutput.contains("Could not connect: Connection refused")) {
emit progressMessage(Tr::tr("Checked that there is no running application."));
addProgressMessage(Tr::tr("Checked that there is no running application."));
} else if (!errorOutput.isEmpty()) {
emit stdErrData(errorOutput);
emit errorMessage(failureMessage);
handleStdErrData(errorOutput);
addErrorMessage(failureMessage);
}
};
return Group { Process(setupHandler, doneHandler, errorHandler) };

View File

@@ -40,19 +40,8 @@ public:
using namespace Internal;
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, Id id)
: BuildStep(bsl, id), d(new Internal::AbstractRemoteLinuxDeployStepPrivate)
{
connect(this, &AbstractRemoteLinuxDeployStep::errorMessage,
this, &AbstractRemoteLinuxDeployStep::handleErrorMessage);
connect(this, &AbstractRemoteLinuxDeployStep::progressMessage,
this, &AbstractRemoteLinuxDeployStep::handleProgressMessage);
connect(this, &AbstractRemoteLinuxDeployStep::warningMessage,
this, &AbstractRemoteLinuxDeployStep::handleWarningMessage);
connect(this, &AbstractRemoteLinuxDeployStep::stdOutData,
this, &AbstractRemoteLinuxDeployStep::handleStdOutData);
connect(this, &AbstractRemoteLinuxDeployStep::stdErrData,
this, &AbstractRemoteLinuxDeployStep::handleStdErrData);
}
: BuildStep(bsl, id), d(new AbstractRemoteLinuxDeployStepPrivate)
{}
AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep()
{
@@ -88,13 +77,13 @@ void AbstractRemoteLinuxDeployStep::start()
const CheckResult check = isDeploymentPossible();
if (!check) {
emit errorMessage(check.errorMessage());
addErrorMessage(check.errorMessage());
handleFinished();
return;
}
if (!isDeploymentNecessary()) {
emit progressMessage(Tr::tr("No deployment action necessary. Skipping."));
addProgressMessage(Tr::tr("No deployment action necessary. Skipping."));
handleFinished();
return;
}
@@ -190,19 +179,19 @@ void AbstractRemoteLinuxDeployStep::doCancel()
stop();
}
void AbstractRemoteLinuxDeployStep::handleProgressMessage(const QString &message)
void AbstractRemoteLinuxDeployStep::addProgressMessage(const QString &message)
{
emit addOutput(message, OutputFormat::NormalMessage);
}
void AbstractRemoteLinuxDeployStep::handleErrorMessage(const QString &message)
void AbstractRemoteLinuxDeployStep::addErrorMessage(const QString &message)
{
emit addOutput(message, OutputFormat::ErrorMessage);
emit addTask(DeploymentTask(Task::Error, message), 1); // TODO correct?
d->hasError = true;
}
void AbstractRemoteLinuxDeployStep::handleWarningMessage(const QString &message)
void AbstractRemoteLinuxDeployStep::addWarningMessage(const QString &message)
{
emit addOutput(message, OutputFormat::ErrorMessage);
emit addTask(DeploymentTask(Task::Warning, message), 1); // TODO correct?
@@ -214,6 +203,7 @@ void AbstractRemoteLinuxDeployStep::handleFinished()
emit addOutput(Tr::tr("Deploy step failed."), OutputFormat::ErrorMessage);
else
emit addOutput(Tr::tr("Deploy step finished."), OutputFormat::NormalMessage);
emit finished(!d->hasError);
}

View File

@@ -58,12 +58,8 @@ public:
virtual CheckResult isDeploymentPossible() const;
signals:
void errorMessage(const QString &message);
void progressMessage(const QString &message);
void warningMessage(const QString &message);
void stdOutData(const QString &data);
void stdErrData(const QString &data);
void handleStdOutData(const QString &data);
void handleStdErrData(const QString &data);
protected:
bool fromMap(const QVariantMap &map) override;
@@ -81,14 +77,13 @@ protected:
bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile,
const QDateTime &remoteTimestamp) const;
private:
void handleProgressMessage(const QString &message);
void handleErrorMessage(const QString &message);
void handleWarningMessage(const QString &message);
void handleFinished();
void handleStdOutData(const QString &data);
void handleStdErrData(const QString &data);
void addProgressMessage(const QString &message);
void addErrorMessage(const QString &message);
void addWarningMessage(const QString &message);
void handleFinished();
private:
virtual bool isDeploymentNecessary() const;
virtual Utils::Tasking::Group deployRecipe();

View File

@@ -67,26 +67,26 @@ CheckResult CustomCommandDeployStep::isDeploymentPossible() const
Group CustomCommandDeployStep::deployRecipe()
{
const auto setupHandler = [this](QtcProcess &process) {
emit progressMessage(Tr::tr("Starting remote command \"%1\"...").arg(m_commandLine));
addProgressMessage(Tr::tr("Starting remote command \"%1\"...").arg(m_commandLine));
process.setCommand({deviceConfiguration()->filePath("/bin/sh"),
{"-c", m_commandLine}});
QtcProcess *proc = &process;
connect(proc, &QtcProcess::readyReadStandardOutput, this, [this, proc] {
emit stdOutData(proc->readAllStandardOutput());
handleStdOutData(proc->readAllStandardOutput());
});
connect(proc, &QtcProcess::readyReadStandardError, this, [this, proc] {
emit stdErrData(proc->readAllStandardError());
handleStdErrData(proc->readAllStandardError());
});
};
const auto doneHandler = [this](const QtcProcess &) {
emit progressMessage(Tr::tr("Remote command finished successfully."));
addProgressMessage(Tr::tr("Remote command finished successfully."));
};
const auto errorHandler = [this](const QtcProcess &process) {
if (process.error() != QProcess::UnknownError
|| process.exitStatus() != QProcess::NormalExit) {
emit errorMessage(Tr::tr("Remote process failed: %1").arg(process.errorString()));
addErrorMessage(Tr::tr("Remote process failed: %1").arg(process.errorString()));
} else if (process.exitCode() != 0) {
emit errorMessage(Tr::tr("Remote process finished with exit code %1.")
addErrorMessage(Tr::tr("Remote process finished with exit code %1.")
.arg(process.exitCode()));
}
};

View File

@@ -103,7 +103,7 @@ QDateTime GenericDirectUploadStepPrivate::timestampFromStat(const DeployableFile
succeeded = true;
}
if (!succeeded) {
emit q->warningMessage(Tr::tr("Failed to retrieve remote timestamp for file \"%1\". "
q->addWarningMessage(Tr::tr("Failed to retrieve remote timestamp for file \"%1\". "
"Incremental deployment will not work. Error message was: %2")
.arg(file.remoteFilePath(), error));
return {};
@@ -112,18 +112,18 @@ QDateTime GenericDirectUploadStepPrivate::timestampFromStat(const DeployableFile
const QString warningString(Tr::tr("Unexpected stat output for remote file \"%1\": %2")
.arg(file.remoteFilePath()).arg(QString::fromUtf8(output)));
if (!output.startsWith(file.remoteFilePath().toUtf8())) {
emit q->warningMessage(warningString);
q->addWarningMessage(warningString);
return {};
}
const QByteArrayList columns = output.mid(file.remoteFilePath().toUtf8().size() + 1).split(' ');
if (columns.size() < 14) { // Normal Linux stat: 16 columns in total, busybox stat: 15 columns
emit q->warningMessage(warningString);
q->addWarningMessage(warningString);
return {};
}
bool isNumber;
const qint64 secsSinceEpoch = columns.at(11).toLongLong(&isNumber);
if (!isNumber) {
emit q->warningMessage(warningString);
q->addWarningMessage(warningString);
return {};
}
return QDateTime::fromSecsSinceEpoch(secsSinceEpoch);
@@ -166,37 +166,37 @@ TaskItem GenericDirectUploadStepPrivate::uploadTask(const TreeStorage<UploadStor
{
const auto setupHandler = [this, storage](FileTransfer &transfer) {
if (storage->filesToUpload.isEmpty()) {
emit q->progressMessage(Tr::tr("No files need to be uploaded."));
q->addProgressMessage(Tr::tr("No files need to be uploaded."));
return TaskAction::StopWithDone;
}
emit q->progressMessage(Tr::tr("%n file(s) need to be uploaded.", "",
storage->filesToUpload.size()));
q->addProgressMessage(Tr::tr("%n file(s) need to be uploaded.", "",
storage->filesToUpload.size()));
FilesToTransfer files;
for (const DeployableFile &file : std::as_const(storage->filesToUpload)) {
if (!file.localFilePath().exists()) {
const QString message = Tr::tr("Local file \"%1\" does not exist.")
.arg(file.localFilePath().toUserOutput());
if (m_ignoreMissingFiles) {
emit q->warningMessage(message);
q->addWarningMessage(message);
continue;
}
emit q->errorMessage(message);
q->addErrorMessage(message);
return TaskAction::StopWithError;
}
files.append({file.localFilePath(),
q->deviceConfiguration()->filePath(file.remoteFilePath())});
}
if (files.isEmpty()) {
emit q->progressMessage(Tr::tr("No files need to be uploaded."));
q->addProgressMessage(Tr::tr("No files need to be uploaded."));
return TaskAction::StopWithDone;
}
transfer.setFilesToTransfer(files);
QObject::connect(&transfer, &FileTransfer::progress,
q, &GenericDirectUploadStep::progressMessage);
q, &GenericDirectUploadStep::addProgressMessage);
return TaskAction::Continue;
};
const auto errorHandler = [this](const FileTransfer &transfer) {
emit q->errorMessage(transfer.resultData().m_errorString);
q->addErrorMessage(transfer.resultData().m_errorString);
};
return Transfer(setupHandler, {}, errorHandler);
@@ -211,11 +211,11 @@ TaskItem GenericDirectUploadStepPrivate::chmodTask(const DeployableFile &file)
const auto errorHandler = [=](const QtcProcess &process) {
const QString error = process.errorString();
if (!error.isEmpty()) {
emit q->warningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
.arg(file.remoteFilePath(), error));
q->addWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
.arg(file.remoteFilePath(), error));
} else if (process.exitCode() != 0) {
emit q->warningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
.arg(file.remoteFilePath(), process.cleanedStdErr()));
q->addWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
.arg(file.remoteFilePath(), process.cleanedStdErr()));
}
};
return Process(setupHandler, {}, errorHandler);
@@ -271,7 +271,7 @@ Group GenericDirectUploadStep::deployRecipe()
saveDeploymentTimeStamp(file, timestamp);
};
const auto doneHandler = [this] {
emit progressMessage(Tr::tr("All files successfully deployed."));
addProgressMessage(Tr::tr("All files successfully deployed."));
};
const TreeStorage<UploadStorage> storage;

View File

@@ -25,6 +25,7 @@ public:
static QString displayName();
private:
friend class GenericDirectUploadStepPrivate;
class GenericDirectUploadStepPrivate *d;
};

View File

@@ -47,14 +47,14 @@ Group KillAppStep::deployRecipe()
{
const auto setupHandler = [this](DeviceProcessKiller &killer) {
killer.setProcessPath(m_remoteExecutable);
emit progressMessage(Tr::tr("Trying to kill \"%1\" on remote device...")
.arg(m_remoteExecutable.path()));
addProgressMessage(Tr::tr("Trying to kill \"%1\" on remote device...")
.arg(m_remoteExecutable.path()));
};
const auto doneHandler = [this](const DeviceProcessKiller &) {
emit progressMessage(Tr::tr("Remote application killed."));
addProgressMessage(Tr::tr("Remote application killed."));
};
const auto errorHandler = [this](const DeviceProcessKiller &) {
emit progressMessage(Tr::tr("Failed to kill remote application. "
addProgressMessage(Tr::tr("Failed to kill remote application. "
"Assuming it was not running."));
};
return Group { Killer(setupHandler, doneHandler, errorHandler) };

View File

@@ -86,7 +86,7 @@ TaskItem RsyncDeployStep::mkdirTask()
process.setCommand({deviceConfiguration()->filePath("mkdir"),
QStringList("-p") + remoteDirs});
connect(&process, &QtcProcess::readyReadStandardError, this, [this, proc = &process] {
emit stdErrData(QString::fromLocal8Bit(proc->readAllRawStandardError()));
handleStdErrData(QString::fromLocal8Bit(proc->readAllRawStandardError()));
});
};
const auto errorHandler = [this](const QtcProcess &process) {
@@ -97,8 +97,8 @@ TaskItem RsyncDeployStep::mkdirTask()
finalMessage += '\n';
finalMessage += stdErr;
}
emit errorMessage(Tr::tr("Deploy via rsync: failed to create remote directories:")
+ '\n' + finalMessage);
addErrorMessage(Tr::tr("Deploy via rsync: failed to create remote directories:")
+ '\n' + finalMessage);
};
return Process(setupHandler, {}, errorHandler);
}
@@ -110,17 +110,17 @@ TaskItem RsyncDeployStep::transferTask()
transfer.setRsyncFlags(m_flags);
transfer.setFilesToTransfer(m_files);
connect(&transfer, &FileTransfer::progress,
this, &AbstractRemoteLinuxDeployStep::stdOutData);
this, &AbstractRemoteLinuxDeployStep::handleStdOutData);
};
const auto errorHandler = [this](const FileTransfer &transfer) {
const ProcessResultData result = transfer.resultData();
if (result.m_error == QProcess::FailedToStart) {
emit errorMessage(Tr::tr("rsync failed to start: %1").arg(result.m_errorString));
addErrorMessage(Tr::tr("rsync failed to start: %1").arg(result.m_errorString));
} else if (result.m_exitStatus == QProcess::CrashExit) {
emit errorMessage(Tr::tr("rsync crashed."));
addErrorMessage(Tr::tr("rsync crashed."));
} else if (result.m_exitCode != 0) {
emit errorMessage(Tr::tr("rsync failed with exit code %1.").arg(result.m_exitCode)
+ "\n" + result.m_errorString);
addErrorMessage(Tr::tr("rsync failed with exit code %1.").arg(result.m_exitCode)
+ "\n" + result.m_errorString);
}
};
return Transfer(setupHandler, {}, errorHandler);

View File

@@ -84,15 +84,15 @@ TaskItem TarPackageDeployStep::uploadTask()
const FilesToTransfer files {{m_packageFilePath,
deviceConfiguration()->filePath(remoteFilePath())}};
transfer.setFilesToTransfer(files);
connect(&transfer, &FileTransfer::progress, this, &TarPackageDeployStep::progressMessage);
emit progressMessage(Tr::tr("Uploading package to device..."));
connect(&transfer, &FileTransfer::progress, this, &TarPackageDeployStep::addProgressMessage);
addProgressMessage(Tr::tr("Uploading package to device..."));
};
const auto doneHandler = [this](const FileTransfer &) {
emit progressMessage(Tr::tr("Successfully uploaded package file."));
addProgressMessage(Tr::tr("Successfully uploaded package file."));
};
const auto errorHandler = [this](const FileTransfer &transfer) {
const ProcessResultData result = transfer.resultData();
emit errorMessage(result.m_errorString);
addErrorMessage(result.m_errorString);
};
return Transfer(setupHandler, doneHandler, errorHandler);
}
@@ -105,19 +105,19 @@ TaskItem TarPackageDeployStep::installTask()
process.setCommand({deviceConfiguration()->filePath("/bin/sh"), {"-c", cmdLine}});
QtcProcess *proc = &process;
connect(proc, &QtcProcess::readyReadStandardOutput, this, [this, proc] {
emit stdOutData(proc->readAllStandardOutput());
handleStdOutData(proc->readAllStandardOutput());
});
connect(proc, &QtcProcess::readyReadStandardError, this, [this, proc] {
emit stdErrData(proc->readAllStandardError());
handleStdErrData(proc->readAllStandardError());
});
emit progressMessage(Tr::tr("Installing package to device..."));
addProgressMessage(Tr::tr("Installing package to device..."));
};
const auto doneHandler = [this](const QtcProcess &) {
saveDeploymentTimeStamp(DeployableFile(m_packageFilePath, {}), {});
emit progressMessage(Tr::tr("Successfully installed package file."));
addProgressMessage(Tr::tr("Successfully installed package file."));
};
const auto errorHandler = [this](const QtcProcess &process) {
emit errorMessage(Tr::tr("Installing package failed.") + process.errorString());
addErrorMessage(Tr::tr("Installing package failed.") + process.errorString());
};
return Process(setupHandler, doneHandler, errorHandler);
}