forked from qt-creator/qt-creator
Docker: Improve DockerApi::canConnect
Replaced Process::start with Process::runBlocking and some general cleanup. Change-Id: I5e2be010b4e6d799d586dbbcd86ca5bf64294ccb Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -38,22 +38,19 @@ bool DockerApi::canConnect()
|
|||||||
{
|
{
|
||||||
Process process;
|
Process process;
|
||||||
FilePath dockerExe = dockerClient();
|
FilePath dockerExe = dockerClient();
|
||||||
if (dockerExe.isEmpty() || !dockerExe.isExecutableFile())
|
if (dockerExe.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
process.setCommand({dockerExe, {"info"}});
|
process.setCommand({dockerExe, {"info"}});
|
||||||
connect(&process, &Process::done, [&process, &result] {
|
process.runBlocking();
|
||||||
|
|
||||||
|
const bool success = process.result() == ProcessResult::FinishedWithSuccess;
|
||||||
|
if (!success)
|
||||||
|
qCWarning(dockerApiLog) << "Failed to connect to docker daemon:" << process.allOutput();
|
||||||
|
else
|
||||||
qCInfo(dockerApiLog) << "'docker info' result:\n" << qPrintable(process.allOutput());
|
qCInfo(dockerApiLog) << "'docker info' result:\n" << qPrintable(process.allOutput());
|
||||||
if (process.result() == ProcessResult::FinishedWithSuccess)
|
|
||||||
result = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
process.start();
|
return process.result() == ProcessResult::FinishedWithSuccess;
|
||||||
process.waitForFinished();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DockerApi::isContainerRunning(const QString &containerId)
|
bool DockerApi::isContainerRunning(const QString &containerId)
|
||||||
|
Reference in New Issue
Block a user