--- a/Preferences/ProgramsDialog.py Mon Nov 13 20:20:06 2017 +0100 +++ b/Preferences/ProgramsDialog.py Tue Nov 14 19:13:28 2017 +0100 @@ -15,6 +15,7 @@ import os import re +import sys from PyQt5.QtCore import pyqtSlot, Qt, QProcess from PyQt5.QtGui import QCursor @@ -214,6 +215,13 @@ exe += ".exe" self.__createProgramEntry( self.tr("Protobuf Compiler"), exe, '--version', 'libprotoc', -1) + # 5c. grpc + exe = Preferences.getProtobuf("grpcPython") + if not exe: + exe = sys.executable + self.__createProgramEntry( + self.tr("grpc Compiler"), exe, '--version', 'libprotoc', -1, + exeModule=['-m', 'grpc_tools.protoc']) # 6. do the spell checking entry try: @@ -253,6 +261,8 @@ pm = e5App().getObject("PluginManager") for info in pm.getPluginExeDisplayData(): if info["programEntry"]: + if "exeModule" not in info: + info["exeModule"] = None self.__createProgramEntry( info["header"], info["exe"], @@ -261,6 +271,7 @@ versionPosition=info["versionPosition"], version=info["version"], versionCleanup=info["versionCleanup"], + exeModule=info["exeModule"], ) else: self.__createEntry( @@ -277,14 +288,15 @@ def __createProgramEntry(self, description, exe, versionCommand="", versionStartsWith="", versionPosition=0, version="", - versionCleanup=None, versionRe=None): + versionCleanup=None, versionRe=None, + exeModule=None): """ Private method to generate a program entry. @param description descriptive text (string) @param exe name of the executable program (string) @param versionCommand command line switch to get the version info - (string) if this is empty, the given version will be shown. + (str). If this is empty, the given version will be shown. @param versionStartsWith start of line identifying version info (string) @param versionPosition index of part containing the version info @@ -294,6 +306,9 @@ start and stop for the version string (tuple of integers) @keyparam versionRe regexp to determine the line identifying version info (string). Takes precedence over versionStartsWith. + @keyparam exeModule list of command line parameters to execute a module + with the program given in exe (e.g. to execute a Python module) + (list of str) @return version string of detected or given version (string) """ itmList = self.programsList.findItems( @@ -320,7 +335,11 @@ versionPosition: proc = QProcess() proc.setProcessChannelMode(QProcess.MergedChannels) - proc.start(exe, [versionCommand]) + if exeModule: + args = exeModule[:] + [versionCommand] + else: + args = [versionCommand] + proc.start(exe, args) finished = proc.waitForFinished(10000) if finished: output = str(proc.readAllStandardOutput(), @@ -345,7 +364,12 @@ version = self.tr("(unknown)") else: version = self.tr("(not executable)") - QTreeWidgetItem(itm, [exe, version]) + if exeModule: + QTreeWidgetItem(itm, [ + "{0} {1}".format(exe, " ".join(exeModule)), + version]) + else: + QTreeWidgetItem(itm, [exe, version]) itm.setExpanded(True) else: itm.setText(1, self.tr("(not found)"))