ui, cli: added proto/grpc versions to cli tool

Display what versions is using the GUI. It'll help to debug issues.

For next releases we may need to check incompatibilities between grpc
and protobuf (#790).
This commit is contained in:
Gustavo Iñiguez Goia 2023-01-06 23:57:15 +01:00
parent 690cea7774
commit ba5208ef02
Failed to generate hash of commit
2 changed files with 20 additions and 5 deletions

View file

@ -22,9 +22,7 @@ if dist_path not in sys.path:
from opensnitch.service import UIService
from opensnitch.config import Config
from opensnitch.utils import Themes
from opensnitch.utils import Utils
import opensnitch.version
from opensnitch.utils import Themes, Utils, Versions
import opensnitch.ui_pb2
from opensnitch.ui_pb2_grpc import add_UIServicer_to_server
@ -47,6 +45,11 @@ def load_translations():
return translator
if __name__ == '__main__':
gui_version, grpcversion, protoversion = Versions.get()
print("\t ~ OpenSnitch GUI -", gui_version, "~")
print("\tprotobuf:", protoversion, "-", "grpc:", grpcversion)
print("-" * 50, "\n")
parser = argparse.ArgumentParser(description='OpenSnitch UI service.', formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("--socket", dest="socket", help='''
Path of the unix socket for the gRPC service (https://github.com/grpc/grpc/blob/master/doc/naming.md).

View file

@ -1,6 +1,6 @@
from PyQt5 import QtCore, QtWidgets, QtGui
from opensnitch.version import version
from opensnitch.version import version as gui_version
from opensnitch.database import Database
from opensnitch.config import Config
from threading import Thread, Event
@ -250,7 +250,7 @@ class QuickHelp():
class Utils():
@staticmethod
def check_versions(daemon_version):
lMayor, lMinor, lPatch = version.split(".")
lMayor, lMinor, lPatch = gui_version.split(".")
rMayor, rMinor, rPatch = daemon_version.split(".")
return lMayor != rMayor or (lMayor == rMayor and lMinor != rMinor)
@ -455,3 +455,15 @@ class Icons():
pass
return icon
class Versions():
@staticmethod
def get():
try:
from google.protobuf import __version__ as proto_version
from grpc import __version__ as grpc_version
return gui_version, grpc_version, proto_version
except:
return "none", "none", "none"