From 90ad9024861641b5535eaa6d2dd302e3f04559ea Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 17 May 2021 12:02:42 +0200 Subject: 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 --- src/plugins/python/pythonutils.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/plugins/python/pythonutils.cpp') diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 60639492c6..d693c2597b 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -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 -- cgit v1.2.1