charmlibs-systemd 1.0.0__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,184 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .coverage-*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+ .report/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ #uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ #poetry.lock
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ #pdm.lock
115
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
116
+ # in version control.
117
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
118
+ .pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
123
+ __pypackages__/
124
+
125
+ # Celery stuff
126
+ celerybeat-schedule
127
+ celerybeat.pid
128
+
129
+ # SageMath parsed files
130
+ *.sage.py
131
+
132
+ # Environments
133
+ .env
134
+ .venv
135
+ env/
136
+ venv/
137
+ ENV/
138
+ env.bak/
139
+ venv.bak/
140
+
141
+ # Spyder project settings
142
+ .spyderproject
143
+ .spyproject
144
+
145
+ # Rope project settings
146
+ .ropeproject
147
+
148
+ # mkdocs documentation
149
+ /site
150
+
151
+ # mypy
152
+ .mypy_cache/
153
+ .dmypy.json
154
+ dmypy.json
155
+
156
+ # Pyre type checker
157
+ .pyre/
158
+
159
+ # pytype static type analyzer
160
+ .pytype/
161
+
162
+ # Cython debug symbols
163
+ cython_debug/
164
+
165
+ # PyCharm
166
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
169
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
170
+ .idea/
171
+
172
+ # PyPI configuration file
173
+ .pypirc
174
+
175
+ # packed charms
176
+ .packed
177
+
178
+ # temporary directory for packing charms
179
+ .tmp
180
+
181
+ # uv.lock from example libraries as we don't commit these
182
+ .example/**/uv.lock
183
+ .tutorial/**/uv.lock
184
+ interfaces/.example/**/uv.lock
@@ -0,0 +1,4 @@
1
+ # 1.0.0 - 19 November 2025
2
+
3
+ Initial release of migrated `operator_libs_linux.v1.systemd` library (patch version 4)
4
+ with minor modifications to statisfy new linter rules.
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: charmlibs-systemd
3
+ Version: 1.0.0
4
+ Summary: The charmlibs.systemd package.
5
+ Project-URL: Repository, https://github.com/canonical/charmlibs
6
+ Project-URL: Issues, https://github.com/canonical/charmlibs/issues
7
+ Project-URL: Documentation, https://documentation.ubuntu.com/charmlibs/reference/charmlibs/systemd/
8
+ Project-URL: Changelog, https://github.com/canonical/charmlibs/blob/main/systemd/CHANGELOG.md
9
+ Author: The Charm Tech team at Canonical
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+
18
+ # charmlibs.systemd
19
+
20
+ The `systemd` library.
21
+
22
+ To install, add `charmlibs-systemd` to your Python dependencies. Then in your Python code, import as:
23
+
24
+ ```py
25
+ from charmlibs import systemd
26
+ ```
27
+
28
+ See the [reference documentation](https://documentation.ubuntu.com/charmlibs/reference/charmlibs/systemd) for more.
@@ -0,0 +1,11 @@
1
+ # charmlibs.systemd
2
+
3
+ The `systemd` library.
4
+
5
+ To install, add `charmlibs-systemd` to your Python dependencies. Then in your Python code, import as:
6
+
7
+ ```py
8
+ from charmlibs import systemd
9
+ ```
10
+
11
+ See the [reference documentation](https://documentation.ubuntu.com/charmlibs/reference/charmlibs/systemd) for more.
@@ -0,0 +1,66 @@
1
+ [project]
2
+ name = "charmlibs-systemd"
3
+ description = "The charmlibs.systemd package."
4
+ readme = "README.md"
5
+ requires-python = ">=3.10"
6
+ authors = [
7
+ {name="The Charm Tech team at Canonical"},
8
+ ]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "License :: OSI Approved :: Apache Software License",
12
+ "Intended Audience :: Developers",
13
+ "Operating System :: POSIX :: Linux",
14
+ "Development Status :: 5 - Production/Stable",
15
+ ]
16
+ dynamic = ["version"]
17
+ dependencies = []
18
+
19
+ [dependency-groups]
20
+ lint = []
21
+ unit = [
22
+ "ops[testing]",
23
+ ]
24
+ functional = []
25
+ integration = []
26
+
27
+ [project.urls]
28
+ "Repository" = "https://github.com/canonical/charmlibs"
29
+ "Issues" = "https://github.com/canonical/charmlibs/issues"
30
+ "Documentation" = "https://documentation.ubuntu.com/charmlibs/reference/charmlibs/systemd/"
31
+ "Changelog" = "https://github.com/canonical/charmlibs/blob/main/systemd/CHANGELOG.md"
32
+
33
+ [build-system]
34
+ requires = ["hatchling"]
35
+ build-backend = "hatchling.build"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/charmlibs"]
39
+
40
+ [tool.hatch.version]
41
+ path = "src/charmlibs/systemd/_version.py"
42
+
43
+ [tool.ruff]
44
+ extend = "../pyproject.toml"
45
+ src = ["src", "tests/unit", "tests/functional", "tests/integration"] # correctly sort local imports in tests
46
+
47
+ [tool.ruff.lint.extend-per-file-ignores]
48
+ # add additional per-file-ignores here to avoid overriding repo-level config
49
+ "tests/**/*" = [
50
+ # "E501", # line too long
51
+ ]
52
+
53
+ [tool.pyright]
54
+ extends = "../pyproject.toml"
55
+ include = ["src", "tests"]
56
+ pythonVersion = "3.10" # check no python > 3.10 features are used
57
+
58
+ [tool.charmlibs.functional]
59
+ ubuntu = [] # ubuntu versions to run functional tests with, e.g. "24.04" (defaults to just "latest")
60
+ pebble = [] # pebble versions to run functional tests with, e.g. "v1.0.0", "master" (defaults to no pebble versions)
61
+ sudo = true # whether to run functional tests with sudo (defaults to false)
62
+
63
+ [tool.charmlibs.integration]
64
+ # tags to run integration tests with (defaults to running once with no tag, i.e. tags = [''])
65
+ # Available in CI in tests/integration/pack.sh and integration tests as CHARMLIBS_TAG
66
+ tags = [] # Not used by the pack.sh and integration tests generated by the template
@@ -0,0 +1,65 @@
1
+ # Copyright 2025 Canonical Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Abstractions for stopping, starting and managing system services via systemd.
16
+
17
+ For the most part, we transparently provide an interface to a commonly used selection of
18
+ systemd commands, with a few shortcuts baked in. For example, :func:`service_pause` and
19
+ :func:`service_resume` will run the mask/unmask and enable/disable invocations.
20
+
21
+ Example usage
22
+ -------------
23
+
24
+ .. code-block:: python
25
+
26
+ from charmlibs import systemd
27
+
28
+ # Start a service
29
+ if not systemd.service_running("mysql"):
30
+ success = systemd.service_start("mysql")
31
+
32
+ # Attempt to reload a service, restarting if necessary
33
+ success = systemd.service_reload("nginx", restart_on_failure=True)
34
+ """
35
+
36
+ from ._systemd import (
37
+ SystemdError,
38
+ daemon_reload,
39
+ service_disable,
40
+ service_enable,
41
+ service_failed,
42
+ service_pause,
43
+ service_reload,
44
+ service_restart,
45
+ service_resume,
46
+ service_running,
47
+ service_start,
48
+ service_stop,
49
+ )
50
+ from ._version import __version__ as __version__
51
+
52
+ __all__ = [
53
+ 'SystemdError',
54
+ 'daemon_reload',
55
+ 'service_disable',
56
+ 'service_enable',
57
+ 'service_failed',
58
+ 'service_pause',
59
+ 'service_reload',
60
+ 'service_restart',
61
+ 'service_resume',
62
+ 'service_running',
63
+ 'service_start',
64
+ 'service_stop',
65
+ ]
@@ -0,0 +1,241 @@
1
+ # Copyright 2025 Canonical Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Manage services controlled by systemd."""
16
+
17
+ import logging
18
+ import subprocess
19
+
20
+ _logger = logging.getLogger(__name__)
21
+
22
+
23
+ class SystemdError(Exception):
24
+ """Custom exception for systemd related errors."""
25
+
26
+
27
+ def _systemctl(*args: str, check: bool = False) -> int:
28
+ """Call a `systemctl` command with logging enabled.
29
+
30
+ Args:
31
+ args: Arguments to pass to the `systemctl` command.
32
+ check: If set to `True`, raise an error if the command exits with a non-zero exit code.
33
+
34
+ Returns:
35
+ Returncode of `systemctl` command execution.
36
+
37
+ Raises:
38
+ SystemdError:
39
+ Raised if the called command fails and check is set to `True`.
40
+ """
41
+ cmd = ['systemctl', *args]
42
+ _logger.debug('running command %s', cmd)
43
+ try:
44
+ result = subprocess.run(cmd, capture_output=True, text=True, check=check)
45
+ except subprocess.CalledProcessError as e:
46
+ raise SystemdError(
47
+ f'Command {cmd} failed with returncode {e.returncode}. systemctl output:\n'
48
+ + f'stdout: {e.stdout}\n'
49
+ + f'stderr: {e.stderr}'
50
+ ) from None
51
+
52
+ _logger.debug(
53
+ "command '%s' completed with:\nexit code: %s\nstdout: %s\nstderr: %s",
54
+ ' '.join(cmd),
55
+ result.returncode,
56
+ result.stdout,
57
+ result.stderr,
58
+ )
59
+ return result.returncode
60
+
61
+
62
+ def service_running(service_name: str) -> bool:
63
+ """Report whether a system service is running.
64
+
65
+ Args:
66
+ service_name: The name of the service to check.
67
+
68
+ Returns:
69
+ True if service is running/active; False if not.
70
+ """
71
+ # If returncode is 0, this means that is service is active.
72
+ return _systemctl('--quiet', 'is-active', service_name) == 0
73
+
74
+
75
+ def service_failed(service_name: str) -> bool:
76
+ """Report whether a system service has failed.
77
+
78
+ Args:
79
+ service_name: The name of the service to check.
80
+
81
+ Returns:
82
+ True if service is marked as failed; False if not.
83
+ """
84
+ # If returncode is 0, this means that the service has failed.
85
+ return _systemctl('--quiet', 'is-failed', service_name) == 0
86
+
87
+
88
+ def service_start(*args: str) -> bool:
89
+ """Start a system service.
90
+
91
+ Args:
92
+ *args: Arguments to pass to `systemctl start` (normally the service name).
93
+
94
+ Returns:
95
+ On success, this function returns True for historical reasons.
96
+
97
+ Raises:
98
+ SystemdError: Raised if `systemctl start ...` returns a non-zero returncode.
99
+ """
100
+ return _systemctl('start', *args, check=True) == 0
101
+
102
+
103
+ def service_stop(*args: str) -> bool:
104
+ """Stop a system service.
105
+
106
+ Args:
107
+ *args: Arguments to pass to `systemctl stop` (normally the service name).
108
+
109
+ Returns:
110
+ On success, this function returns True for historical reasons.
111
+
112
+ Raises:
113
+ SystemdError: Raised if `systemctl stop ...` returns a non-zero returncode.
114
+ """
115
+ return _systemctl('stop', *args, check=True) == 0
116
+
117
+
118
+ def service_restart(*args: str) -> bool:
119
+ """Restart a system service.
120
+
121
+ Args:
122
+ *args: Arguments to pass to `systemctl restart` (normally the service name).
123
+
124
+ Returns:
125
+ On success, this function returns True for historical reasons.
126
+
127
+ Raises:
128
+ SystemdError: Raised if `systemctl restart ...` returns a non-zero returncode.
129
+ """
130
+ return _systemctl('restart', *args, check=True) == 0
131
+
132
+
133
+ def service_enable(*args: str) -> bool:
134
+ """Enable a system service.
135
+
136
+ Args:
137
+ *args: Arguments to pass to `systemctl enable` (normally the service name).
138
+
139
+ Returns:
140
+ On success, this function returns True for historical reasons.
141
+
142
+ Raises:
143
+ SystemdError: Raised if `systemctl enable ...` returns a non-zero returncode.
144
+ """
145
+ return _systemctl('enable', *args, check=True) == 0
146
+
147
+
148
+ def service_disable(*args: str) -> bool:
149
+ """Disable a system service.
150
+
151
+ Args:
152
+ *args: Arguments to pass to `systemctl disable` (normally the service name).
153
+
154
+ Returns:
155
+ On success, this function returns True for historical reasons.
156
+
157
+ Raises:
158
+ SystemdError: Raised if `systemctl disable ...` returns a non-zero returncode.
159
+ """
160
+ return _systemctl('disable', *args, check=True) == 0
161
+
162
+
163
+ def service_reload(service_name: str, restart_on_failure: bool = False) -> bool:
164
+ """Reload a system service, optionally falling back to restart if reload fails.
165
+
166
+ Args:
167
+ service_name: The name of the service to reload.
168
+ restart_on_failure:
169
+ Boolean indicating whether to fall back to a restart if the reload fails.
170
+
171
+ Returns:
172
+ On success, this function returns True for historical reasons.
173
+
174
+ Raises:
175
+ SystemdError: Raised if `systemctl reload|restart ...` returns a non-zero returncode.
176
+ """
177
+ try:
178
+ return _systemctl('reload', service_name, check=True) == 0
179
+ except SystemdError:
180
+ if restart_on_failure:
181
+ return service_restart(service_name)
182
+ else:
183
+ raise
184
+
185
+
186
+ def service_pause(service_name: str) -> bool:
187
+ """Pause a system service.
188
+
189
+ Stops the service and prevents the service from starting again at boot.
190
+
191
+ Args:
192
+ service_name: The name of the service to pause.
193
+
194
+ Returns:
195
+ On success, this function returns True for historical reasons.
196
+
197
+ Raises:
198
+ SystemdError: Raised if service is still running after being paused by systemctl.
199
+ """
200
+ _systemctl('disable', '--now', service_name)
201
+ _systemctl('mask', service_name)
202
+
203
+ if service_running(service_name):
204
+ raise SystemdError(f'Attempted to pause {service_name!r}, but it is still running.')
205
+
206
+ return True
207
+
208
+
209
+ def service_resume(service_name: str) -> bool:
210
+ """Resume a system service.
211
+
212
+ Re-enable starting the service again at boot. Start the service.
213
+
214
+ Args:
215
+ service_name: The name of the service to resume.
216
+
217
+ Returns:
218
+ On success, this function returns True for historical reasons.
219
+
220
+ Raises:
221
+ SystemdError: Raised if service is not running after being resumed by systemctl.
222
+ """
223
+ _systemctl('unmask', service_name)
224
+ _systemctl('enable', '--now', service_name)
225
+
226
+ if not service_running(service_name):
227
+ raise SystemdError(f'Attempted to resume {service_name!r}, but it is not running.')
228
+
229
+ return True
230
+
231
+
232
+ def daemon_reload() -> bool:
233
+ """Reload systemd manager configuration.
234
+
235
+ Returns:
236
+ On success, this function returns True for historical reasons.
237
+
238
+ Raises:
239
+ SystemdError: Raised if `systemctl daemon-reload` returns a non-zero returncode.
240
+ """
241
+ return _systemctl('daemon-reload', check=True) == 0
@@ -0,0 +1,15 @@
1
+ # Copyright 2025 Canonical Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ __version__ = '1.0.0'
File without changes
@@ -0,0 +1,111 @@
1
+ # Copyright 2025 Canonical Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Functional tests for the `systemd` charm library."""
16
+
17
+ import logging
18
+ from subprocess import check_output
19
+
20
+ from charmlibs import systemd
21
+
22
+ logger = logging.getLogger(__name__)
23
+
24
+
25
+ def test_service() -> None:
26
+ def create_service(name: str, start_command: str):
27
+ """Create a custom service."""
28
+ content = f"""[Unit]
29
+ Description=Test Service
30
+ After=multi-user.target
31
+
32
+ [Service]
33
+ ExecStart=/usr/bin/bash -c "{start_command}"
34
+ Type=simple
35
+
36
+ [Install]
37
+ WantedBy=multi-user.target
38
+ """
39
+
40
+ with open(f'/etc/systemd/system/{name}', 'w+') as f:
41
+ f.writelines([f'{line.strip()}\n' for line in content.split('\n')])
42
+
43
+ systemd.service_restart(name)
44
+
45
+ # Cron is pre-installed in the lxc images we are using.
46
+ assert systemd.service_running('cron')
47
+ # Foo is made up, and should not be running.
48
+ assert not systemd.service_running('foo')
49
+
50
+ # test custom service with correct command
51
+ create_service('test.service', 'while true; do echo; sleep 1; done')
52
+ assert systemd.service_running('test.service')
53
+ systemd.service_stop('test.service')
54
+
55
+ # test failed status
56
+ create_service('test.service', 'bad command')
57
+ assert systemd.service_failed('test.service')
58
+
59
+
60
+ def test_pause_and_resume() -> None:
61
+ # Verify that we can disable and re-enable a service.
62
+ assert systemd.service_pause('cron')
63
+ assert not systemd.service_running('cron')
64
+ assert systemd.service_resume('cron')
65
+ assert systemd.service_running('cron')
66
+
67
+
68
+ def test_restart():
69
+ # Verify that we seem to be able to restart a service.
70
+ assert systemd.service_restart('cron')
71
+
72
+
73
+ def test_stop_and_start() -> None:
74
+ # Verify that we can stop and start a service.
75
+ assert systemd.service_stop('cron')
76
+ assert not systemd.service_running('cron')
77
+ assert systemd.service_start('cron')
78
+ assert systemd.service_running('cron')
79
+
80
+
81
+ def test_reload() -> None:
82
+ # Verify that we can reload services that support reload.
83
+ try:
84
+ systemd.service_reload('cron')
85
+ except systemd.SystemdError:
86
+ pass
87
+ else:
88
+ raise AssertionError("cron does not support reload, but we didn't raise and error.")
89
+ assert systemd.service_reload('apparmor')
90
+
91
+ # The following is observed behavior. Not sure how happy I am about it.
92
+ assert systemd.service_reload('cron', restart_on_failure=True)
93
+
94
+
95
+ def test_daemon_reload() -> None:
96
+ # Verify that we can reload the systemd manager configuration.
97
+
98
+ def needs_reload(svc: str):
99
+ """Check if a given service has changed, and requires a daemon-reload."""
100
+ output = check_output(['systemctl', 'show', svc, '--property=NeedDaemonReload'])
101
+ return output.decode().strip() == 'NeedDaemonReload=yes'
102
+
103
+ # Edit a unit file such that a reload would be required
104
+ with open('/lib/systemd/system/cron.service', 'r+') as f:
105
+ content = f.read()
106
+ content.replace('Restart=on-failure', 'Restart=never')
107
+ f.write(content)
108
+
109
+ assert needs_reload('cron')
110
+ assert systemd.daemon_reload()
111
+ assert not needs_reload('cron')
@@ -0,0 +1,53 @@
1
+ # Copyright 2025 Canonical Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Fixtures for unit tests, typically mocking out parts of the external system."""
16
+
17
+ import subprocess
18
+ from collections.abc import Iterable
19
+ from typing import Any
20
+ from unittest.mock import MagicMock, Mock
21
+
22
+ import pytest
23
+
24
+
25
+ class MakeMock:
26
+ def __init__(self, monkeypatch: pytest.MonkeyPatch) -> None:
27
+ self.monkeypatch = monkeypatch
28
+
29
+ def __call__(
30
+ self, returncodes: Iterable[int], check: bool = False
31
+ ) -> tuple[MagicMock, dict[str, Any]]:
32
+ side_effects: list[Any] = []
33
+ for code in returncodes:
34
+ if code != 0 and check:
35
+ side_effects.append(subprocess.CalledProcessError(code, cmd='systemctl fail'))
36
+ else:
37
+ mock_result = Mock()
38
+ mock_result.returncode = code
39
+ mock_result.stdout = ''
40
+ mock_result.stderr = ''
41
+ mock_result.check = check
42
+ side_effects.append(mock_result)
43
+
44
+ mock_run = MagicMock()
45
+ mock_run.side_effect = side_effects
46
+ self.monkeypatch.setattr(subprocess, 'run', mock_run)
47
+
48
+ return mock_run, {'capture_output': True, 'text': True, 'check': check}
49
+
50
+
51
+ @pytest.fixture(scope='function')
52
+ def make_mock(monkeypatch: pytest.MonkeyPatch) -> MakeMock:
53
+ return MakeMock(monkeypatch)
@@ -0,0 +1,194 @@
1
+ # Copyright 2025 Canonical Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Unit tests for the `systemd` charm library."""
16
+
17
+ from unittest.mock import call
18
+
19
+ import pytest
20
+
21
+ from charmlibs import systemd
22
+ from conftest import MakeMock
23
+
24
+
25
+ def test_daemon_reload(make_mock: MakeMock) -> None:
26
+ mock_run, kwargs = make_mock([0, 1], check=True)
27
+
28
+ systemd.daemon_reload()
29
+ mock_run.assert_called_with(['systemctl', 'daemon-reload'], **kwargs)
30
+
31
+ # Failed to reload systemd configuration.
32
+ with pytest.raises(systemd.SystemdError):
33
+ systemd.daemon_reload()
34
+ mock_run.assert_called_with(['systemctl', 'daemon-reload'], **kwargs)
35
+
36
+
37
+ def test_service_running(make_mock: MakeMock) -> None:
38
+ mock_run, kwargs = make_mock([0, 3])
39
+
40
+ result = systemd.service_running('mysql')
41
+ mock_run.assert_called_with(['systemctl', '--quiet', 'is-active', 'mysql'], **kwargs)
42
+ assert result is True
43
+
44
+ result = systemd.service_running('mysql')
45
+ mock_run.assert_called_with(['systemctl', '--quiet', 'is-active', 'mysql'], **kwargs)
46
+ assert result is False
47
+
48
+
49
+ def test_service_failed(make_mock: MakeMock) -> None:
50
+ mock_run, kwargs = make_mock([0, 1])
51
+
52
+ result = systemd.service_failed('mysql')
53
+ mock_run.assert_called_with(['systemctl', '--quiet', 'is-failed', 'mysql'], **kwargs)
54
+ assert result
55
+
56
+ result = systemd.service_failed('mysql')
57
+ mock_run.assert_called_with(
58
+ [
59
+ 'systemctl',
60
+ '--quiet',
61
+ 'is-failed',
62
+ 'mysql',
63
+ ],
64
+ **kwargs,
65
+ )
66
+ assert result is False
67
+
68
+
69
+ def test_service_start(make_mock: MakeMock) -> None:
70
+ mock_run, kwargs = make_mock([0, 1], check=True)
71
+
72
+ systemd.service_start('mysql')
73
+ mock_run.assert_called_with(['systemctl', 'start', 'mysql'], **kwargs)
74
+
75
+ with pytest.raises(systemd.SystemdError):
76
+ systemd.service_start('mysql')
77
+ mock_run.assert_called_with(['systemctl', 'start', 'mysql'], **kwargs)
78
+
79
+
80
+ def test_service_stop(make_mock: MakeMock) -> None:
81
+ mock_run, kwargs = make_mock([0, 1], check=True)
82
+
83
+ systemd.service_stop('mysql')
84
+ mock_run.assert_called_with(['systemctl', 'stop', 'mysql'], **kwargs)
85
+
86
+ with pytest.raises(systemd.SystemdError):
87
+ systemd.service_stop('mysql')
88
+ mock_run.assert_called_with(['systemctl', 'stop', 'mysql'], **kwargs)
89
+
90
+
91
+ def test_service_restart(make_mock: MakeMock) -> None:
92
+ mock_run, kwargs = make_mock([0, 1], check=True)
93
+
94
+ systemd.service_restart('mysql')
95
+ mock_run.assert_called_with(['systemctl', 'restart', 'mysql'], **kwargs)
96
+
97
+ with pytest.raises(systemd.SystemdError):
98
+ systemd.service_restart('mysql')
99
+ mock_run.assert_called_with(['systemctl', 'restart', 'mysql'], **kwargs)
100
+
101
+
102
+ def test_service_enable(make_mock: MakeMock) -> None:
103
+ mock_run, kwargs = make_mock([0, 1], check=True)
104
+
105
+ systemd.service_enable('slurmd')
106
+ mock_run.assert_called_with(['systemctl', 'enable', 'slurmd'], **kwargs)
107
+
108
+ with pytest.raises(systemd.SystemdError):
109
+ systemd.service_enable('slurmd')
110
+ mock_run.assert_called_with(['systemctl', 'enable', 'slurmd'], **kwargs)
111
+
112
+
113
+ def test_service_disable(make_mock: MakeMock) -> None:
114
+ mock_run, kwargs = make_mock([0, 1], check=True)
115
+
116
+ systemd.service_disable('slurmd')
117
+ mock_run.assert_called_with(['systemctl', 'disable', 'slurmd'], **kwargs)
118
+
119
+ with pytest.raises(systemd.SystemdError):
120
+ systemd.service_disable('slurmd')
121
+ mock_run.assert_called_with(['systemctl', 'disable', 'slurmd'], **kwargs)
122
+
123
+
124
+ def test_service_reload(make_mock: MakeMock) -> None:
125
+ # We reload successfully.
126
+ mock_run, kwargs = make_mock([0], check=True)
127
+ systemd.service_reload('mysql')
128
+ mock_run.assert_called_with(['systemctl', 'reload', 'mysql'], **kwargs)
129
+
130
+ # We can't reload, so we restart
131
+ mock_run, kwargs = make_mock([1, 0], check=True)
132
+ systemd.service_reload('mysql', restart_on_failure=True)
133
+ mock_run.assert_has_calls([
134
+ call(['systemctl', 'reload', 'mysql'], **kwargs),
135
+ call(['systemctl', 'restart', 'mysql'], **kwargs),
136
+ ])
137
+
138
+ # We should only restart if requested.
139
+ mock_run, kwargs = make_mock([1, 0], check=True)
140
+ with pytest.raises(systemd.SystemdError):
141
+ systemd.service_reload('mysql')
142
+ mock_run.assert_called_with(['systemctl', 'reload', 'mysql'], **kwargs)
143
+
144
+ # ... and if we fail at both, we should fail.
145
+ mock_run, kwargs = make_mock([1, 1], check=True)
146
+ with pytest.raises(systemd.SystemdError):
147
+ systemd.service_reload('mysql', restart_on_failure=True)
148
+ mock_run.assert_has_calls([
149
+ call(['systemctl', 'reload', 'mysql'], **kwargs),
150
+ call(['systemctl', 'restart', 'mysql'], **kwargs),
151
+ ])
152
+
153
+
154
+ def test_service_pause(make_mock: MakeMock) -> None:
155
+ # Test pause
156
+ mock_run, kwargs = make_mock([0, 0, 3])
157
+
158
+ systemd.service_pause('mysql')
159
+ mock_run.assert_has_calls([
160
+ call(['systemctl', 'disable', '--now', 'mysql'], **kwargs),
161
+ call(['systemctl', 'mask', 'mysql'], **kwargs),
162
+ call(['systemctl', '--quiet', 'is-active', 'mysql'], **kwargs),
163
+ ])
164
+
165
+ # Could not stop service!
166
+ mock_run, kwargs = make_mock([0, 0, 0])
167
+ with pytest.raises(systemd.SystemdError):
168
+ systemd.service_pause('mysql')
169
+ mock_run.assert_has_calls([
170
+ call(['systemctl', 'disable', '--now', 'mysql'], **kwargs),
171
+ call(['systemctl', 'mask', 'mysql'], **kwargs),
172
+ call(['systemctl', '--quiet', 'is-active', 'mysql'], **kwargs),
173
+ ])
174
+
175
+
176
+ def test_service_resume(make_mock: MakeMock) -> None:
177
+ # Resume service.
178
+ mock_run, kwargs = make_mock([0, 0, 0])
179
+ systemd.service_resume('mysql')
180
+ mock_run.assert_has_calls([
181
+ call(['systemctl', 'unmask', 'mysql'], **kwargs),
182
+ call(['systemctl', 'enable', '--now', 'mysql'], **kwargs),
183
+ call(['systemctl', '--quiet', 'is-active', 'mysql'], **kwargs),
184
+ ])
185
+
186
+ # Failed to resume service.
187
+ mock_run, kwargs = make_mock([0, 0, 3])
188
+ with pytest.raises(systemd.SystemdError):
189
+ systemd.service_resume('mysql')
190
+ mock_run.assert_has_calls([
191
+ call(['systemctl', 'unmask', 'mysql'], **kwargs),
192
+ call(['systemctl', 'enable', '--now', 'mysql'], **kwargs),
193
+ call(['systemctl', '--quiet', 'is-active', 'mysql'], **kwargs),
194
+ ])
@@ -0,0 +1,168 @@
1
+ version = 1
2
+ revision = 3
3
+ requires-python = ">=3.10"
4
+
5
+ [[package]]
6
+ name = "charmlibs-systemd"
7
+ source = { editable = "." }
8
+
9
+ [package.dev-dependencies]
10
+ unit = [
11
+ { name = "ops", extra = ["testing"] },
12
+ ]
13
+
14
+ [package.metadata]
15
+
16
+ [package.metadata.requires-dev]
17
+ functional = []
18
+ integration = []
19
+ lint = []
20
+ unit = [{ name = "ops", extras = ["testing"] }]
21
+
22
+ [[package]]
23
+ name = "importlib-metadata"
24
+ version = "8.7.0"
25
+ source = { registry = "https://pypi.org/simple" }
26
+ dependencies = [
27
+ { name = "zipp" },
28
+ ]
29
+ sdist = { url = "https://files.pythonhosted.org/packages/76/66/650a33bd90f786193e4de4b3ad86ea60b53c89b669a5c7be931fac31cdb0/importlib_metadata-8.7.0.tar.gz", hash = "sha256:d13b81ad223b890aa16c5471f2ac3056cf76c5f10f82d6f9292f0b415f389000", size = 56641, upload-time = "2025-04-27T15:29:01.736Z" }
30
+ wheels = [
31
+ { url = "https://files.pythonhosted.org/packages/20/b0/36bd937216ec521246249be3bf9855081de4c5e06a0c9b4219dbeda50373/importlib_metadata-8.7.0-py3-none-any.whl", hash = "sha256:e5dd1551894c77868a30651cef00984d50e1002d06942a7101d34870c5f02afd", size = 27656, upload-time = "2025-04-27T15:29:00.214Z" },
32
+ ]
33
+
34
+ [[package]]
35
+ name = "opentelemetry-api"
36
+ version = "1.38.0"
37
+ source = { registry = "https://pypi.org/simple" }
38
+ dependencies = [
39
+ { name = "importlib-metadata" },
40
+ { name = "typing-extensions" },
41
+ ]
42
+ sdist = { url = "https://files.pythonhosted.org/packages/08/d8/0f354c375628e048bd0570645b310797299754730079853095bf000fba69/opentelemetry_api-1.38.0.tar.gz", hash = "sha256:f4c193b5e8acb0912b06ac5b16321908dd0843d75049c091487322284a3eea12", size = 65242, upload-time = "2025-10-16T08:35:50.25Z" }
43
+ wheels = [
44
+ { url = "https://files.pythonhosted.org/packages/ae/a2/d86e01c28300bd41bab8f18afd613676e2bd63515417b77636fc1add426f/opentelemetry_api-1.38.0-py3-none-any.whl", hash = "sha256:2891b0197f47124454ab9f0cf58f3be33faca394457ac3e09daba13ff50aa582", size = 65947, upload-time = "2025-10-16T08:35:30.23Z" },
45
+ ]
46
+
47
+ [[package]]
48
+ name = "ops"
49
+ version = "3.3.1"
50
+ source = { registry = "https://pypi.org/simple" }
51
+ dependencies = [
52
+ { name = "opentelemetry-api" },
53
+ { name = "pyyaml" },
54
+ { name = "websocket-client" },
55
+ ]
56
+ sdist = { url = "https://files.pythonhosted.org/packages/3f/cd/bbd4263b53bb19e87f995b05ef93f565fa4edcb90bacacec615d47c56568/ops-3.3.1.tar.gz", hash = "sha256:8dec621c32a31365d040eaf05960c0e65a2ffbcdbfa91107e03b1ee9d4d26034", size = 541783, upload-time = "2025-10-16T01:46:25.431Z" }
57
+ wheels = [
58
+ { url = "https://files.pythonhosted.org/packages/fd/97/c1e5447c3c0d86cab16cad802e1bb58613b2396b7184797af2e4484c2014/ops-3.3.1-py3-none-any.whl", hash = "sha256:38229bb1cc6d9c2aa4dff4495f3e33af928dbd1070e8c5d8b697dfb32dcd89a8", size = 191338, upload-time = "2025-10-16T01:46:20.038Z" },
59
+ ]
60
+
61
+ [package.optional-dependencies]
62
+ testing = [
63
+ { name = "ops-scenario" },
64
+ ]
65
+
66
+ [[package]]
67
+ name = "ops-scenario"
68
+ version = "8.3.1"
69
+ source = { registry = "https://pypi.org/simple" }
70
+ dependencies = [
71
+ { name = "ops" },
72
+ { name = "pyyaml" },
73
+ ]
74
+ sdist = { url = "https://files.pythonhosted.org/packages/92/94/cf17208427d43f9136b0fb61ca75ac937b88ac66cb0a3fe126bbffbde677/ops_scenario-8.3.1.tar.gz", hash = "sha256:553cd1ee30f161edd110e217a01505a9778baf778c039d810e0cfbd6101b855b", size = 110260, upload-time = "2025-10-16T01:46:27.097Z" }
75
+ wheels = [
76
+ { url = "https://files.pythonhosted.org/packages/17/dd/da2bcb1a164c4c9c8690c689305b15c3f988166db44add5084c4dc04ad04/ops_scenario-8.3.1-py3-none-any.whl", hash = "sha256:bf8404387cd8c22cd0b45c996ca7c12e84b6c603edc8b056e85234fc3d270941", size = 64403, upload-time = "2025-10-16T01:46:22.082Z" },
77
+ ]
78
+
79
+ [[package]]
80
+ name = "pyyaml"
81
+ version = "6.0.3"
82
+ source = { registry = "https://pypi.org/simple" }
83
+ sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" }
84
+ wheels = [
85
+ { url = "https://files.pythonhosted.org/packages/f4/a0/39350dd17dd6d6c6507025c0e53aef67a9293a6d37d3511f23ea510d5800/pyyaml-6.0.3-cp310-cp310-macosx_10_13_x86_64.whl", hash = "sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b", size = 184227, upload-time = "2025-09-25T21:31:46.04Z" },
86
+ { url = "https://files.pythonhosted.org/packages/05/14/52d505b5c59ce73244f59c7a50ecf47093ce4765f116cdb98286a71eeca2/pyyaml-6.0.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956", size = 174019, upload-time = "2025-09-25T21:31:47.706Z" },
87
+ { url = "https://files.pythonhosted.org/packages/43/f7/0e6a5ae5599c838c696adb4e6330a59f463265bfa1e116cfd1fbb0abaaae/pyyaml-6.0.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8", size = 740646, upload-time = "2025-09-25T21:31:49.21Z" },
88
+ { url = "https://files.pythonhosted.org/packages/2f/3a/61b9db1d28f00f8fd0ae760459a5c4bf1b941baf714e207b6eb0657d2578/pyyaml-6.0.3-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198", size = 840793, upload-time = "2025-09-25T21:31:50.735Z" },
89
+ { url = "https://files.pythonhosted.org/packages/7a/1e/7acc4f0e74c4b3d9531e24739e0ab832a5edf40e64fbae1a9c01941cabd7/pyyaml-6.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b", size = 770293, upload-time = "2025-09-25T21:31:51.828Z" },
90
+ { url = "https://files.pythonhosted.org/packages/8b/ef/abd085f06853af0cd59fa5f913d61a8eab65d7639ff2a658d18a25d6a89d/pyyaml-6.0.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0", size = 732872, upload-time = "2025-09-25T21:31:53.282Z" },
91
+ { url = "https://files.pythonhosted.org/packages/1f/15/2bc9c8faf6450a8b3c9fc5448ed869c599c0a74ba2669772b1f3a0040180/pyyaml-6.0.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69", size = 758828, upload-time = "2025-09-25T21:31:54.807Z" },
92
+ { url = "https://files.pythonhosted.org/packages/a3/00/531e92e88c00f4333ce359e50c19b8d1de9fe8d581b1534e35ccfbc5f393/pyyaml-6.0.3-cp310-cp310-win32.whl", hash = "sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e", size = 142415, upload-time = "2025-09-25T21:31:55.885Z" },
93
+ { url = "https://files.pythonhosted.org/packages/2a/fa/926c003379b19fca39dd4634818b00dec6c62d87faf628d1394e137354d4/pyyaml-6.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c", size = 158561, upload-time = "2025-09-25T21:31:57.406Z" },
94
+ { url = "https://files.pythonhosted.org/packages/6d/16/a95b6757765b7b031c9374925bb718d55e0a9ba8a1b6a12d25962ea44347/pyyaml-6.0.3-cp311-cp311-macosx_10_13_x86_64.whl", hash = "sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e", size = 185826, upload-time = "2025-09-25T21:31:58.655Z" },
95
+ { url = "https://files.pythonhosted.org/packages/16/19/13de8e4377ed53079ee996e1ab0a9c33ec2faf808a4647b7b4c0d46dd239/pyyaml-6.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824", size = 175577, upload-time = "2025-09-25T21:32:00.088Z" },
96
+ { url = "https://files.pythonhosted.org/packages/0c/62/d2eb46264d4b157dae1275b573017abec435397aa59cbcdab6fc978a8af4/pyyaml-6.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c", size = 775556, upload-time = "2025-09-25T21:32:01.31Z" },
97
+ { url = "https://files.pythonhosted.org/packages/10/cb/16c3f2cf3266edd25aaa00d6c4350381c8b012ed6f5276675b9eba8d9ff4/pyyaml-6.0.3-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00", size = 882114, upload-time = "2025-09-25T21:32:03.376Z" },
98
+ { url = "https://files.pythonhosted.org/packages/71/60/917329f640924b18ff085ab889a11c763e0b573da888e8404ff486657602/pyyaml-6.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d", size = 806638, upload-time = "2025-09-25T21:32:04.553Z" },
99
+ { url = "https://files.pythonhosted.org/packages/dd/6f/529b0f316a9fd167281a6c3826b5583e6192dba792dd55e3203d3f8e655a/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a", size = 767463, upload-time = "2025-09-25T21:32:06.152Z" },
100
+ { url = "https://files.pythonhosted.org/packages/f2/6a/b627b4e0c1dd03718543519ffb2f1deea4a1e6d42fbab8021936a4d22589/pyyaml-6.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4", size = 794986, upload-time = "2025-09-25T21:32:07.367Z" },
101
+ { url = "https://files.pythonhosted.org/packages/45/91/47a6e1c42d9ee337c4839208f30d9f09caa9f720ec7582917b264defc875/pyyaml-6.0.3-cp311-cp311-win32.whl", hash = "sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b", size = 142543, upload-time = "2025-09-25T21:32:08.95Z" },
102
+ { url = "https://files.pythonhosted.org/packages/da/e3/ea007450a105ae919a72393cb06f122f288ef60bba2dc64b26e2646fa315/pyyaml-6.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf", size = 158763, upload-time = "2025-09-25T21:32:09.96Z" },
103
+ { url = "https://files.pythonhosted.org/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196", size = 182063, upload-time = "2025-09-25T21:32:11.445Z" },
104
+ { url = "https://files.pythonhosted.org/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0", size = 173973, upload-time = "2025-09-25T21:32:12.492Z" },
105
+ { url = "https://files.pythonhosted.org/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28", size = 775116, upload-time = "2025-09-25T21:32:13.652Z" },
106
+ { url = "https://files.pythonhosted.org/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c", size = 844011, upload-time = "2025-09-25T21:32:15.21Z" },
107
+ { url = "https://files.pythonhosted.org/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc", size = 807870, upload-time = "2025-09-25T21:32:16.431Z" },
108
+ { url = "https://files.pythonhosted.org/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e", size = 761089, upload-time = "2025-09-25T21:32:17.56Z" },
109
+ { url = "https://files.pythonhosted.org/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea", size = 790181, upload-time = "2025-09-25T21:32:18.834Z" },
110
+ { url = "https://files.pythonhosted.org/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5", size = 137658, upload-time = "2025-09-25T21:32:20.209Z" },
111
+ { url = "https://files.pythonhosted.org/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b", size = 154003, upload-time = "2025-09-25T21:32:21.167Z" },
112
+ { url = "https://files.pythonhosted.org/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd", size = 140344, upload-time = "2025-09-25T21:32:22.617Z" },
113
+ { url = "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8", size = 181669, upload-time = "2025-09-25T21:32:23.673Z" },
114
+ { url = "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", size = 173252, upload-time = "2025-09-25T21:32:25.149Z" },
115
+ { url = "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c", size = 767081, upload-time = "2025-09-25T21:32:26.575Z" },
116
+ { url = "https://files.pythonhosted.org/packages/49/1e/a55ca81e949270d5d4432fbbd19dfea5321eda7c41a849d443dc92fd1ff7/pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5", size = 841159, upload-time = "2025-09-25T21:32:27.727Z" },
117
+ { url = "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6", size = 801626, upload-time = "2025-09-25T21:32:28.878Z" },
118
+ { url = "https://files.pythonhosted.org/packages/f9/11/ba845c23988798f40e52ba45f34849aa8a1f2d4af4b798588010792ebad6/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6", size = 753613, upload-time = "2025-09-25T21:32:30.178Z" },
119
+ { url = "https://files.pythonhosted.org/packages/3d/e0/7966e1a7bfc0a45bf0a7fb6b98ea03fc9b8d84fa7f2229e9659680b69ee3/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be", size = 794115, upload-time = "2025-09-25T21:32:31.353Z" },
120
+ { url = "https://files.pythonhosted.org/packages/de/94/980b50a6531b3019e45ddeada0626d45fa85cbe22300844a7983285bed3b/pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26", size = 137427, upload-time = "2025-09-25T21:32:32.58Z" },
121
+ { url = "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c", size = 154090, upload-time = "2025-09-25T21:32:33.659Z" },
122
+ { url = "https://files.pythonhosted.org/packages/73/e8/2bdf3ca2090f68bb3d75b44da7bbc71843b19c9f2b9cb9b0f4ab7a5a4329/pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb", size = 140246, upload-time = "2025-09-25T21:32:34.663Z" },
123
+ { url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" },
124
+ { url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" },
125
+ { url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" },
126
+ { url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" },
127
+ { url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" },
128
+ { url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" },
129
+ { url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" },
130
+ { url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" },
131
+ { url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" },
132
+ { url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" },
133
+ { url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" },
134
+ { url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" },
135
+ { url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" },
136
+ { url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" },
137
+ { url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" },
138
+ { url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" },
139
+ { url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" },
140
+ { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" },
141
+ ]
142
+
143
+ [[package]]
144
+ name = "typing-extensions"
145
+ version = "4.15.0"
146
+ source = { registry = "https://pypi.org/simple" }
147
+ sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" }
148
+ wheels = [
149
+ { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },
150
+ ]
151
+
152
+ [[package]]
153
+ name = "websocket-client"
154
+ version = "1.9.0"
155
+ source = { registry = "https://pypi.org/simple" }
156
+ sdist = { url = "https://files.pythonhosted.org/packages/2c/41/aa4bf9664e4cda14c3b39865b12251e8e7d239f4cd0e3cc1b6c2ccde25c1/websocket_client-1.9.0.tar.gz", hash = "sha256:9e813624b6eb619999a97dc7958469217c3176312b3a16a4bd1bc7e08a46ec98", size = 70576, upload-time = "2025-10-07T21:16:36.495Z" }
157
+ wheels = [
158
+ { url = "https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl", hash = "sha256:af248a825037ef591efbf6ed20cc5faa03d3b47b9e5a2230a529eeee1c1fc3ef", size = 82616, upload-time = "2025-10-07T21:16:34.951Z" },
159
+ ]
160
+
161
+ [[package]]
162
+ name = "zipp"
163
+ version = "3.23.0"
164
+ source = { registry = "https://pypi.org/simple" }
165
+ sdist = { url = "https://files.pythonhosted.org/packages/e3/02/0f2892c661036d50ede074e376733dca2ae7c6eb617489437771209d4180/zipp-3.23.0.tar.gz", hash = "sha256:a07157588a12518c9d4034df3fbbee09c814741a33ff63c05fa29d26a2404166", size = 25547, upload-time = "2025-06-08T17:06:39.4Z" }
166
+ wheels = [
167
+ { url = "https://files.pythonhosted.org/packages/2e/54/647ade08bf0db230bfea292f893923872fd20be6ac6f53b2b936ba839d75/zipp-3.23.0-py3-none-any.whl", hash = "sha256:071652d6115ed432f5ce1d34c336c0adfd6a884660d1e9712a256d3d3bd4b14e", size = 10276, upload-time = "2025-06-08T17:06:38.034Z" },
168
+ ]