Skip to content

Commit

Permalink
ui, cli: added proto/grpc versions to cli tool
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
gustavo-iniguez-goya committed Jan 6, 2023
1 parent 690cea7 commit ba5208e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
9 changes: 6 additions & 3 deletions ui/bin/opensnitch-ui
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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).
Expand Down
16 changes: 14 additions & 2 deletions ui/opensnitch/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -250,7 +250,7 @@ def show(help_str):
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)

Expand Down Expand Up @@ -455,3 +455,15 @@ def new(icon_name):
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"

0 comments on commit ba5208e

Please sign in to comment.