From 24a4b12ac4f3c8c538654969767a6db62c018092 Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 23 Mar 2021 21:21:00 +0100 Subject: [PATCH] frontends: use new EXIT_BACKEND_NOT_FOUND exit code: - new EXIT_BACKEND_NOT_FOUND (5) is used when frontend can't find backend with the bridge. It differs from EXIT_BRIDGE_ERROR (3) which is used when something went wrong when connecting to backend. - use this exit code in quick app and in jp --- sat/core/constants.py | 1 + sat_frontends/jp/base.py | 4 +++- sat_frontends/quick_frontend/quick_app.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sat/core/constants.py b/sat/core/constants.py index 80c21895..acd41d4d 100644 --- a/sat/core/constants.py +++ b/sat/core/constants.py @@ -381,6 +381,7 @@ class Const(object): EXIT_BAD_ARG = 2 # arguments given by user are bad EXIT_BRIDGE_ERROR = 3 # can't connect to bridge EXIT_BRIDGE_ERRBACK = 4 # something went wrong when calling a bridge method + EXIT_BACKEND_NOT_FOUND = 5 # can't find backend with this bride EXIT_NOT_FOUND = 16 # an item required by a command was not found EXIT_DATA_ERROR = 17 # data needed for a command is invalid EXIT_MISSING_FEATURE = 18 # a needed plugin or feature is not available diff --git a/sat_frontends/jp/base.py b/sat_frontends/jp/base.py index 6da9c8e7..7342badb 100644 --- a/sat_frontends/jp/base.py +++ b/sat_frontends/jp/base.py @@ -649,11 +649,13 @@ class LiberviaCli: except Exception as e: if isinstance(e, exceptions.BridgeExceptionNoService): print((_("Can't connect to SàT backend, are you sure it's launched ?"))) + self.quit(C.EXIT_BACKEND_NOT_FOUND, raise_exc=False) elif isinstance(e, exceptions.BridgeInitError): print((_("Can't init bridge"))) + self.quit(C.EXIT_BRIDGE_ERROR, raise_exc=False) else: print((_(f"Error while initialising bridge: {e}"))) - self.quit(C.EXIT_BRIDGE_ERROR, raise_exc=False) + self.quit(C.EXIT_BRIDGE_ERROR, raise_exc=False) return self.version = await self.bridge.getVersion() self._bridgeConnected() diff --git a/sat_frontends/quick_frontend/quick_app.py b/sat_frontends/quick_frontend/quick_app.py index 82391b3e..9750a053 100644 --- a/sat_frontends/quick_frontend/quick_app.py +++ b/sat_frontends/quick_frontend/quick_app.py @@ -368,10 +368,10 @@ class QuickApp(object): def _bridgeEb(self, failure): if isinstance(failure, exceptions.BridgeExceptionNoService): print((_("Can't connect to SàT backend, are you sure it's launched ?"))) - sys.exit(1) + sys.exit(C.EXIT_BACKEND_NOT_FOUND) elif isinstance(failure, exceptions.BridgeInitError): print((_("Can't init bridge"))) - sys.exit(1) + sys.exit(C.EXIT_BRIDGE_ERROR) else: print((_("Error while initialising bridge: {}".format(failure))))