From c47d3d362e27bc7f03cae2b1e7fbf086f8d2f34b Mon Sep 17 00:00:00 2001 From: David Slusser Date: Wed, 27 Dec 2023 18:37:29 -0800 Subject: [PATCH 1/4] fixing stale process handling --- docs/source/version_history.rst | 2 ++ src/djangoaddicts/hostutils/views/gui.py | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docs/source/version_history.rst b/docs/source/version_history.rst index f5408fd..78a40a5 100644 --- a/docs/source/version_history.rst +++ b/docs/source/version_history.rst @@ -15,3 +15,5 @@ Version History "0.0.5", "removing ajax view; using only htmx" "0.0.6", "updating templates for latest Bootstrap" "0.0.7", "adding isort; adding badges to readme" + "0.0.8", "fixed modal trigger on host process card" + "0.0.9", "fixed stale process handling in host process view" diff --git a/src/djangoaddicts/hostutils/views/gui.py b/src/djangoaddicts/hostutils/views/gui.py index 4e1a16d..ef546c4 100644 --- a/src/djangoaddicts/hostutils/views/gui.py +++ b/src/djangoaddicts/hostutils/views/gui.py @@ -139,16 +139,23 @@ def get(self, request, *args, **kwargs): context["title"] = self.title context["now"] = datetime.datetime.now() context["subtitle"] = psutil.os.uname()[1] - process_list = list(psutil.process_iter()) - context["process_list"] = process_list counts = { - "running": len([i for i in process_list if i.status() == "running"]), - "sleeping": len([i for i in process_list if i.status() == "sleeping"]), - "idle": len([i for i in process_list if i.status() == "idle"]), - "stopped": len([i for i in process_list if i.status() == "stopped"]), - "zombie": len([i for i in process_list if i.status() == "zombie"]), - "dead": len([i for i in process_list if i.status() == "dead"]), + "running": 0, + "sleeping": 0, + "idle": 0, + "stopped": 0, + "zombie": 0, + "dead": 0, + "disk-sleep": 0 } + process_list = list(psutil.process_iter()) + context["process_list"] = process_list + for process in process_list: + try: + counts[process.status()] += 1 + except psutil.NoSuchProcess: + continue + context["counts"] = counts filter_form = {} filter_form["form"] = HostProcessFilterForm(request.GET or None) From 4ccc74feaca70e55e6e25c4d1e74881c132b5aab Mon Sep 17 00:00:00 2001 From: David Slusser Date: Sat, 30 Dec 2023 15:21:03 -0800 Subject: [PATCH 2/4] updating process capture; updating modal button and trigger --- docs/source/version_history.rst | 2 +- pyproject.toml | 2 +- .../templates/hostutils/bs5/detail/cpu.html | 2 +- .../templates/hostutils/bs5/detail/disk.html | 2 +- .../hostutils/bs5/detail/network.html | 2 +- src/djangoaddicts/hostutils/views/gui.py | 26 ++---- src/djangoaddicts/hostutils/views/htmx.py | 65 ++++++-------- tests/unit/test_gui.py | 17 ++++ tests/unit/test_htmx.py | 88 +++++++++---------- 9 files changed, 98 insertions(+), 108 deletions(-) diff --git a/docs/source/version_history.rst b/docs/source/version_history.rst index 78a40a5..9dc348b 100644 --- a/docs/source/version_history.rst +++ b/docs/source/version_history.rst @@ -16,4 +16,4 @@ Version History "0.0.6", "updating templates for latest Bootstrap" "0.0.7", "adding isort; adding badges to readme" "0.0.8", "fixed modal trigger on host process card" - "0.0.9", "fixed stale process handling in host process view" + "0.0.9", "fixed stale process handling in host process view; updated modals" diff --git a/pyproject.toml b/pyproject.toml index 058fa80..da81842 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,7 @@ ignore_missing_imports = true # https://docs.pytest.org/en/6.2.x/customize.html#pyproject-toml [tool.pytest.ini_options] -addopts = "-s -v -x --strict-markers -m 'not extra' --doctest-modules" +#addopts = "-s -v -x --strict-markers -m 'not extra' --doctest-modules" filterwarnings = [ "ignore::UserWarning", ] diff --git a/src/djangoaddicts/hostutils/templates/hostutils/bs5/detail/cpu.html b/src/djangoaddicts/hostutils/templates/hostutils/bs5/detail/cpu.html index 46284aa..8c9c309 100644 --- a/src/djangoaddicts/hostutils/templates/hostutils/bs5/detail/cpu.html +++ b/src/djangoaddicts/hostutils/templates/hostutils/bs5/detail/cpu.html @@ -168,7 +168,7 @@