summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2023-10-29 10:23:29 +0100
committernicolargo <nicolas@nicolargo.com>2023-10-29 10:23:29 +0100
commit3a23d1693b0dcc908fb535012f03862237ca5191 (patch)
tree820c8ac2b9e3645cd54cbf4e637c31b0aa5392d7
parent28570e8704f6620b088db8600d38d4af0525d61f (diff)
Disable UI if an error occurs and if an export module is enabled #2589
-rw-r--r--glances/outputs/glances_curses.py17
-rw-r--r--glances/standalone.py4
2 files changed, 17 insertions, 4 deletions
diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py
index e078e9b1..ea6da7cd 100644
--- a/glances/outputs/glances_curses.py
+++ b/glances/outputs/glances_curses.py
@@ -139,10 +139,19 @@ class _GlancesCurses(object):
self.space_between_line = 2
# Init the curses screen
- self.screen = curses.initscr()
- if not self.screen:
- logger.critical("Cannot init the curses library.\n")
- sys.exit(1)
+ try:
+ self.screen = curses.initscr()
+ if not self.screen:
+ logger.critical("Cannot init the curses library.\n")
+ sys.exit(1)
+ except Exception as e:
+ if args.export:
+ logger.info("Cannot init the curses library, quiet mode on and export.")
+ args.quiet = True
+ return
+ else:
+ logger.critical("Cannot init the curses library ({})".format(e))
+ sys.exit(1)
# Load the 'outputs' section of the configuration file
# - Init the theme (default is black)
diff --git a/glances/standalone.py b/glances/standalone.py
index 8ea5400a..a1e62e59 100644
--- a/glances/standalone.py
+++ b/glances/standalone.py
@@ -105,6 +105,10 @@ class GlancesStandalone(object):
# Init screen
self.screen = GlancesCursesStandalone(config=config, args=args)
+ # If an error occur during the screen init, continue if export option is set
+ # It is done in the screen.init function
+ self._quiet = args.quiet
+
# Check the latest Glances version
self.outdated = Outdated(config=config, args=args)