charmlibs-snap 0.8.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.
- charmlibs_snap-0.8.0/.gitignore +176 -0
- charmlibs_snap-0.8.0/CHANGELOG.md +15 -0
- charmlibs_snap-0.8.0/PKG-INFO +29 -0
- charmlibs_snap-0.8.0/README.md +11 -0
- charmlibs_snap-0.8.0/pyproject.toml +57 -0
- charmlibs_snap-0.8.0/src/charmlibs/snap/__init__.py +98 -0
- charmlibs_snap-0.8.0/src/charmlibs/snap/_snap.py +1335 -0
- charmlibs_snap-0.8.0/src/charmlibs/snap/_version.py +15 -0
- charmlibs_snap-0.8.0/src/charmlibs/snap/py.typed +0 -0
- charmlibs_snap-0.8.0/tests/functional/test_snap.py +350 -0
- charmlibs_snap-0.8.0/tests/unit/fake_snapd.py +188 -0
- charmlibs_snap-0.8.0/tests/unit/installed_snaps_response.json +89 -0
- charmlibs_snap-0.8.0/tests/unit/snap_information_response.json +78 -0
- charmlibs_snap-0.8.0/tests/unit/test_snap.py +1256 -0
- charmlibs_snap-0.8.0/uv.lock +266 -0
|
@@ -0,0 +1,176 @@
|
|
|
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
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# 0.8.0 - 10 December 2025
|
|
2
|
+
|
|
3
|
+
Release with Python 3.8 support. This is a 0.X release which does not guarantee extended support. Changes from the 1.0 release are purely `typing` related. This release is otherwise identical to the 1.0.1 release.
|
|
4
|
+
|
|
5
|
+
# 1.0.1 - 4 November 2025
|
|
6
|
+
|
|
7
|
+
Update the type annotation of `log`'s `num_lines` parameter to indicate that `'all'` is accepted.
|
|
8
|
+
|
|
9
|
+
# 1.0.0.post0 - 14 October 2025
|
|
10
|
+
|
|
11
|
+
Update project URLs.
|
|
12
|
+
|
|
13
|
+
# 1.0.0 - 23 September 2025
|
|
14
|
+
|
|
15
|
+
Initial release of migrated `operator_libs_linux.v2.snap` library (patch version 14).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: charmlibs-snap
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: The charmlibs.snap package.
|
|
5
|
+
Project-URL: Documentation, https://documentation.ubuntu.com/charmlibs/reference/charmlibs/snap/
|
|
6
|
+
Project-URL: Repository, https://github.com/canonical/charmlibs
|
|
7
|
+
Project-URL: Issues, https://github.com/canonical/charmlibs/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/canonical/charmlibs/blob/20.04-maintenance/snap/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.8
|
|
16
|
+
Requires-Dist: opentelemetry-api
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# charmlibs-snap
|
|
20
|
+
|
|
21
|
+
The `snap` library.
|
|
22
|
+
|
|
23
|
+
To install, add `charmlibs-snap` to your Python dependencies. Then in your Python code, import as:
|
|
24
|
+
|
|
25
|
+
```py
|
|
26
|
+
from charmlibs import snap
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
See the [reference documentation](https://documentation.ubuntu.com/charmlibs/reference/charmlibs/snap) for more.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# charmlibs-snap
|
|
2
|
+
|
|
3
|
+
The `snap` library.
|
|
4
|
+
|
|
5
|
+
To install, add `charmlibs-snap` to your Python dependencies. Then in your Python code, import as:
|
|
6
|
+
|
|
7
|
+
```py
|
|
8
|
+
from charmlibs import snap
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
See the [reference documentation](https://documentation.ubuntu.com/charmlibs/reference/charmlibs/snap) for more.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "charmlibs-snap"
|
|
3
|
+
description = "The charmlibs.snap package."
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
requires-python = ">=3.8"
|
|
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
|
+
"opentelemetry-api",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[dependency-groups]
|
|
22
|
+
lint = [ # installed for `just lint snap` (unit, functional, and integration are also installed)
|
|
23
|
+
"typing_extensions",
|
|
24
|
+
]
|
|
25
|
+
unit = []
|
|
26
|
+
functional = []
|
|
27
|
+
integration = []
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
"Documentation" = "https://documentation.ubuntu.com/charmlibs/reference/charmlibs/snap/"
|
|
31
|
+
"Repository" = "https://github.com/canonical/charmlibs"
|
|
32
|
+
"Issues" = "https://github.com/canonical/charmlibs/issues"
|
|
33
|
+
"Changelog" = "https://github.com/canonical/charmlibs/blob/20.04-maintenance/snap/CHANGELOG.md"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["hatchling"]
|
|
37
|
+
build-backend = "hatchling.build"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.wheel]
|
|
40
|
+
packages = ["src/charmlibs"]
|
|
41
|
+
|
|
42
|
+
[tool.hatch.version]
|
|
43
|
+
path = "src/charmlibs/snap/_version.py"
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
extend = "../pyproject.toml"
|
|
47
|
+
src = ["src", "tests/unit", "tests/functional", "tests/integration"] # correctly sort local imports in tests
|
|
48
|
+
|
|
49
|
+
[tool.pyright]
|
|
50
|
+
extends = "../pyproject.toml"
|
|
51
|
+
include = ["src", "tests"]
|
|
52
|
+
pythonVersion = "3.8" # check no python > 3.8 features are used
|
|
53
|
+
|
|
54
|
+
[tool.charmlibs.functional]
|
|
55
|
+
ubuntu = ["22.04", "24.04"] # ubuntu versions to run functional tests with, e.g. "24.04" (defaults to just "latest")
|
|
56
|
+
pebble = [] # pebble versions to run functional tests with, e.g. "v1.0.0", "master" (defaults to no pebble versions)
|
|
57
|
+
sudo = true # whether to run functional tests with sudo (defaults to false)
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
"""Representations of the system's Snaps, and abstractions around managing them.
|
|
16
|
+
|
|
17
|
+
The ``snap`` package provides convenience methods for listing, installing, refreshing, and removing
|
|
18
|
+
Snap packages, in addition to setting and getting configuration options for them.
|
|
19
|
+
|
|
20
|
+
In the ``snap`` package, ``SnapCache`` creates a ``dict``-like mapping of ``Snap`` objects when
|
|
21
|
+
instantiated. Installed snaps are fully populated, and available snaps are lazily-loaded upon
|
|
22
|
+
request. This module relies on an installed and running ``snapd`` daemon to perform operations over
|
|
23
|
+
the ``snapd`` HTTP API.
|
|
24
|
+
|
|
25
|
+
``SnapCache`` objects can be used to install or modify nnap packages by name in a manner similar to
|
|
26
|
+
using the ``snap`` command from the commandline.
|
|
27
|
+
|
|
28
|
+
An example of adding Juju to the system with ``SnapCache`` and setting a config value::
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
cache = snap.SnapCache()
|
|
32
|
+
juju = cache["juju"]
|
|
33
|
+
|
|
34
|
+
if not juju.present:
|
|
35
|
+
juju.ensure(snap.SnapState.Latest, channel="beta")
|
|
36
|
+
juju.set({"some.key": "value", "some.key2": "value2"})
|
|
37
|
+
except snap.SnapError as e:
|
|
38
|
+
logger.error("An exception occurred when installing charmcraft. Reason: %s", e.message)
|
|
39
|
+
|
|
40
|
+
In addition, the ``snap`` module provides "bare" methods which can act on Snap packages as
|
|
41
|
+
simple function calls. :meth:`add`, :meth:`remove`, and :meth:`ensure` are provided, as
|
|
42
|
+
well as :meth:`add_local` for installing directly from a local ``.snap`` file. These return
|
|
43
|
+
``Snap`` objects.
|
|
44
|
+
|
|
45
|
+
As an example of installing several Snaps and checking details::
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
nextcloud, charmcraft = snap.add(["nextcloud", "charmcraft"])
|
|
49
|
+
if nextcloud.get("mode") != "production":
|
|
50
|
+
nextcloud.set({"mode": "production"})
|
|
51
|
+
except snap.SnapError as e:
|
|
52
|
+
logger.error("An exception occurred when installing snaps. Reason: %s" % e.message)
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
from ._snap import (
|
|
56
|
+
Error,
|
|
57
|
+
JSONAble,
|
|
58
|
+
JSONType,
|
|
59
|
+
MetaCache,
|
|
60
|
+
Snap,
|
|
61
|
+
SnapAPIError,
|
|
62
|
+
SnapCache,
|
|
63
|
+
SnapClient,
|
|
64
|
+
SnapError,
|
|
65
|
+
SnapNotFoundError,
|
|
66
|
+
SnapService,
|
|
67
|
+
SnapServiceDict,
|
|
68
|
+
SnapState,
|
|
69
|
+
add,
|
|
70
|
+
ansi_filter,
|
|
71
|
+
ensure,
|
|
72
|
+
hold_refresh,
|
|
73
|
+
install_local,
|
|
74
|
+
remove,
|
|
75
|
+
)
|
|
76
|
+
from ._version import __version__ as __version__
|
|
77
|
+
|
|
78
|
+
__all__ = [
|
|
79
|
+
'Error',
|
|
80
|
+
'JSONAble',
|
|
81
|
+
'JSONType',
|
|
82
|
+
'MetaCache',
|
|
83
|
+
'Snap',
|
|
84
|
+
'SnapAPIError',
|
|
85
|
+
'SnapCache',
|
|
86
|
+
'SnapClient',
|
|
87
|
+
'SnapError',
|
|
88
|
+
'SnapNotFoundError',
|
|
89
|
+
'SnapService',
|
|
90
|
+
'SnapServiceDict',
|
|
91
|
+
'SnapState',
|
|
92
|
+
'add',
|
|
93
|
+
'ansi_filter',
|
|
94
|
+
'ensure',
|
|
95
|
+
'hold_refresh',
|
|
96
|
+
'install_local',
|
|
97
|
+
'remove',
|
|
98
|
+
]
|