datasette-psutil 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: datasette-psutil
3
+ Version: 0.2.1
4
+ Summary: Datasette plugin adding a /-/psutil debugging endpoint
5
+ Author: Simon Willison
6
+ License-Expression: Apache-2.0
7
+ Requires-Dist: datasette>=0.50
8
+ Requires-Dist: psutil>=6.0
9
+ Requires-Dist: pytest ; extra == 'test'
10
+ Requires-Dist: pytest-asyncio ; extra == 'test'
11
+ Requires-Python: >=3.11
12
+ Project-URL: Homepage, https://github.com/simonw/datasette-psutil
13
+ Project-URL: Issues, https://github.com/simonw/datasette-psutil/issues
14
+ Project-URL: CI, https://github.com/simonw/datasette-psutil/actions
15
+ Project-URL: Changelog, https://github.com/simonw/datasette-psutil/releases
16
+ Provides-Extra: test
17
+ Description-Content-Type: text/markdown
18
+
19
+ # datasette-psutil
20
+
21
+ [![PyPI](https://img.shields.io/pypi/v/datasette-psutil.svg)](https://pypi.org/project/datasette-psutil/)
22
+ [![Changelog](https://img.shields.io/github/v/release/simonw/datasette-psutil?include_prereleases&label=changelog)](https://github.com/simonw/datasette-psutil/releases)
23
+ [![Tests](https://github.com/simonw/datasette-psutil/workflows/Test/badge.svg)](https://github.com/simonw/datasette-psutil/actions?query=workflow%3ATest)
24
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-psutil/blob/main/LICENSE)
25
+
26
+ Datasette plugin adding a `/-/psutil` debugging endpoint
27
+
28
+ ## Installation
29
+
30
+ Install this plugin in the same environment as Datasette.
31
+
32
+ $ pip install datasette-psutil
33
+
34
+ ## Usage
35
+
36
+ Visit `/-/psutil` on your Datasette instance to see various information provided by [psutil](https://psutil.readthedocs.io/).
37
+
38
+ ## Demo
39
+
40
+ https://latest-with-plugins.datasette.io/-/psutil is a live demo of this plugin, hosted on Google Cloud Run.
@@ -0,0 +1,22 @@
1
+ # datasette-psutil
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/datasette-psutil.svg)](https://pypi.org/project/datasette-psutil/)
4
+ [![Changelog](https://img.shields.io/github/v/release/simonw/datasette-psutil?include_prereleases&label=changelog)](https://github.com/simonw/datasette-psutil/releases)
5
+ [![Tests](https://github.com/simonw/datasette-psutil/workflows/Test/badge.svg)](https://github.com/simonw/datasette-psutil/actions?query=workflow%3ATest)
6
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-psutil/blob/main/LICENSE)
7
+
8
+ Datasette plugin adding a `/-/psutil` debugging endpoint
9
+
10
+ ## Installation
11
+
12
+ Install this plugin in the same environment as Datasette.
13
+
14
+ $ pip install datasette-psutil
15
+
16
+ ## Usage
17
+
18
+ Visit `/-/psutil` on your Datasette instance to see various information provided by [psutil](https://psutil.readthedocs.io/).
19
+
20
+ ## Demo
21
+
22
+ https://latest-with-plugins.datasette.io/-/psutil is a live demo of this plugin, hosted on Google Cloud Run.
@@ -0,0 +1,36 @@
1
+ import psutil
2
+ from datasette import hookimpl
3
+ from datasette.utils.asgi import Response
4
+
5
+
6
+ async def show_psutil():
7
+ lines = []
8
+
9
+ def info(code):
10
+ lines.append(code)
11
+ try:
12
+ result = eval(code, {"process": process, "psutil": psutil,})
13
+ except Exception as e:
14
+ result = [e]
15
+ if not isinstance(result, list):
16
+ result = [result]
17
+ lines.extend(" " + repr(r) for r in result)
18
+ lines.append("")
19
+
20
+ process = psutil.Process()
21
+ info("process.open_files()")
22
+ info("process.net_connections()")
23
+ info("process.memory_info()")
24
+ info("process.cmdline()")
25
+ info("process.parents()")
26
+ info("process.threads()")
27
+ info("psutil.getloadavg()")
28
+ info("psutil.cpu_times(True)")
29
+ info("psutil.virtual_memory()")
30
+ info("list(psutil.process_iter())")
31
+ return Response.text("\n".join(lines))
32
+
33
+
34
+ @hookimpl
35
+ def register_routes():
36
+ return [("^/-/psutil$", show_psutil)]
@@ -0,0 +1,46 @@
1
+ [project]
2
+ name = "datasette-psutil"
3
+ version = "0.2.1"
4
+ description = "Datasette plugin adding a /-/psutil debugging endpoint"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ requires-python = ">=3.11"
8
+ dependencies = [
9
+ "datasette>=0.50",
10
+ "psutil>=6.0",
11
+ ]
12
+
13
+ [[project.authors]]
14
+ name = "Simon Willison"
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/simonw/datasette-psutil"
18
+ Issues = "https://github.com/simonw/datasette-psutil/issues"
19
+ CI = "https://github.com/simonw/datasette-psutil/actions"
20
+ Changelog = "https://github.com/simonw/datasette-psutil/releases"
21
+
22
+ [project.optional-dependencies]
23
+ test = [
24
+ "pytest",
25
+ "pytest-asyncio",
26
+ ]
27
+
28
+ [project.entry-points.datasette]
29
+ psutil = "datasette_psutil"
30
+
31
+ [dependency-groups]
32
+ dev = [
33
+ "pytest",
34
+ "pytest-asyncio",
35
+ ]
36
+
37
+ [build-system]
38
+ requires = ["uv_build>=0.11.0,<0.14.0"]
39
+ build-backend = "uv_build"
40
+
41
+ [tool.uv.build-backend]
42
+ module-root = ""
43
+ source-include = ["tests/**"]
44
+
45
+ [tool.pytest.ini_options]
46
+ asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "datasette-psutil"
3
+ version = "0.2.1"
4
+ description = "Datasette plugin adding a /-/psutil debugging endpoint"
5
+ readme = "README.md"
6
+ authors = [{name = "Simon Willison"}]
7
+ license = "Apache-2.0"
8
+ requires-python = ">=3.11"
9
+ dependencies = ["datasette>=0.50", "psutil>=6.0"]
10
+
11
+ [project.urls]
12
+ Homepage = "https://github.com/simonw/datasette-psutil"
13
+ Issues = "https://github.com/simonw/datasette-psutil/issues"
14
+ CI = "https://github.com/simonw/datasette-psutil/actions"
15
+ Changelog = "https://github.com/simonw/datasette-psutil/releases"
16
+
17
+ [project.optional-dependencies]
18
+ test = ["pytest", "pytest-asyncio"]
19
+
20
+ [project.entry-points.datasette]
21
+ psutil = "datasette_psutil"
22
+
23
+ [dependency-groups]
24
+ dev = ["pytest", "pytest-asyncio"]
25
+
26
+ [build-system]
27
+ requires = ["uv_build>=0.11.0,<0.14.0"]
28
+ build-backend = "uv_build"
29
+
30
+ [tool.uv.build-backend]
31
+ module-root = ""
32
+ source-include = ["tests/**"]
33
+
34
+ [tool.pytest.ini_options]
35
+ asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1,22 @@
1
+ from datasette.app import Datasette
2
+ import pytest
3
+
4
+
5
+ @pytest.mark.asyncio
6
+ async def test_datasette_psutil():
7
+ ds = Datasette([], memory=True)
8
+ response = await ds.client.get("/-/psutil")
9
+ assert response.status_code == 200
10
+ for fragment in (
11
+ "process.open_files()",
12
+ "process.net_connections()",
13
+ "process.memory_info()",
14
+ "process.cmdline()",
15
+ "process.parents()",
16
+ "process.threads()",
17
+ "psutil.getloadavg()",
18
+ "psutil.cpu_times(True)",
19
+ "psutil.virtual_memory()",
20
+ "list(psutil.process_iter())",
21
+ ):
22
+ assert fragment in response.text