From f603e8412c6768fd62b68bd6a7438c947062c8e3 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sun, 7 Jul 2024 18:47:46 +0200 Subject: [PATCH] Add another connector to snap --- Makefile | 7 +++++++ glances/standalone.py | 10 ++++++---- snap/snapcraft.yaml | 5 +++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b92bf2021..ba4ce94b6 100644 --- a/Makefile +++ b/Makefile @@ -287,6 +287,13 @@ run-browser: ## Start Glances in browser mode (RPC) run-issue: ## Start Glances in issue mode ./venv/bin/python -m glances -C ./conf/glances.conf --issue +run-multipass: ## Install and start Glances in a VM (only available on Ubuntu with multipass already installed) + multipass launch -n glances-on-lts lts + multipass exec glances-on-lts -- sudo snap install glances + multipass exec glances-on-lts -- glances + multipass stop glances-on-lts + multipass delete glances-on-lts + show-version: ## Show Glances version number ./venv/bin/python -m glances -C ./conf/glances.conf -V diff --git a/glances/standalone.py b/glances/standalone.py index ce7620690..37696bb8c 100644 --- a/glances/standalone.py +++ b/glances/standalone.py @@ -140,12 +140,14 @@ def __serve_once(self): """ # Update stats # Start a counter used to compute the time needed - counter = Counter() + counter_update = Counter() self.stats.update() - logger.debug(f'Stats updated duration: {counter.get()} seconds') + logger.debug(f'Stats updated duration: {counter_update.get()} seconds') # Patch for issue1326 to avoid < 0 refresh - adapted_refresh = (self.refresh_time - counter.get()) if (self.refresh_time - counter.get()) > 0 else 0 + adapted_refresh = ( + (self.refresh_time - counter_update.get()) if (self.refresh_time - counter_update.get()) > 0 else 0 + ) # Display stats # and wait refresh_time - counter @@ -179,7 +181,7 @@ def serve_n(self, n=1): def serve_forever(self): """Wrapper to the serve_forever function.""" if self.args.stop_after: - self.serve_n(self.args.stop_after) + self.serve_n(n=self.args.stop_after) else: while self.__serve_once(): pass diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 28aa2fc44..45e5f5743 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: glances -version: '4.1.2+build01' # Put the current stable version+buildXX +version: '4.1.2+build02' # Put the current stable version+buildXX summary: Glances an Eye on your system. A top/htop alternative. description: | @@ -17,7 +17,7 @@ apps: command: bin/glances plugs: # https://snapcraft.io/docs/supported-interfaces - network - - system-observe + - system-observe # This one should give read access to all the system - mount-observe - hardware-observe - log-observe @@ -32,6 +32,7 @@ apps: - power-control - process-control - network-setup-observe + - all-home environment: LANG: C.UTF-8 LC_ALL: C.UTF-8