forked from qt-creator/qt-creator
Utils: Remove CommandLine argument from QtcProcess::run{,Blocking}
Makes run() more similar to what start() looks like. Also add some asserts to make sure run() and related functions are only called on SyncronousProcesses, as these are currently the only ones where this works. Change-Id: Idee6076c3f40a484db5c17f5bb348698cc83d220 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -281,7 +281,8 @@ Interpreter::Interpreter(const FilePath &python, const QString &defaultName, boo
|
||||
SynchronousProcess pythonProcess;
|
||||
pythonProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||
pythonProcess.setTimeoutS(1);
|
||||
pythonProcess.runBlocking({python, {"--version"}});
|
||||
pythonProcess.setCommand({python, {"--version"}});
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.result() == QtcProcess::Finished)
|
||||
name = pythonProcess.stdOut().trimmed();
|
||||
if (name.isEmpty())
|
||||
|
||||
@@ -86,8 +86,8 @@ static QString pythonName(const FilePath &pythonPath)
|
||||
if (name.isEmpty()) {
|
||||
SynchronousProcess pythonProcess;
|
||||
pythonProcess.setTimeoutS(2);
|
||||
const CommandLine pythonVersionCommand(pythonPath, {"--version"});
|
||||
pythonProcess.runBlocking(pythonVersionCommand);
|
||||
pythonProcess.setCommand({pythonPath, {"--version"}});
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.result() != QtcProcess::Finished)
|
||||
return {};
|
||||
name = pythonProcess.allOutput().trimmed();
|
||||
@@ -109,7 +109,8 @@ FilePath getPylsModulePath(CommandLine pylsCommand)
|
||||
Environment env = pythonProcess.environment();
|
||||
env.set("PYTHONVERBOSE", "x");
|
||||
pythonProcess.setEnvironment(env);
|
||||
pythonProcess.runBlocking(pylsCommand);
|
||||
pythonProcess.setCommand(pylsCommand);
|
||||
pythonProcess.runBlocking();
|
||||
|
||||
static const QString pylsInitPattern = "(.*)"
|
||||
+ QRegularExpression::escape(
|
||||
@@ -159,12 +160,13 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
|
||||
}
|
||||
|
||||
SynchronousProcess pythonProcess;
|
||||
pythonProcess.runBlocking(pythonLShelpCommand);
|
||||
pythonProcess.setCommand(pythonLShelpCommand);
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.allOutput().contains("Python Language Server"))
|
||||
return {PythonLanguageServerState::AlreadyInstalled, modulePath};
|
||||
|
||||
const CommandLine pythonPipVersionCommand(python, {"-m", "pip", "-V"});
|
||||
pythonProcess.runBlocking(pythonPipVersionCommand);
|
||||
pythonProcess.setCommand({python, {"-m", "pip", "-V"}});
|
||||
pythonProcess.runBlocking();
|
||||
if (pythonProcess.allOutput().startsWith("pip "))
|
||||
return {PythonLanguageServerState::CanBeInstalled, FilePath()};
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user