snap-python 0.0.4__tar.gz → 0.0.5__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.
- {snap_python-0.0.4 → snap_python-0.0.5}/PKG-INFO +11 -1
- {snap_python-0.0.4 → snap_python-0.0.5}/README.md +9 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/pyproject.toml +1 -1
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/client.py +8 -2
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/components/snaps.py +7 -1
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/snaps.py +7 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/search.py +7 -5
- {snap_python-0.0.4 → snap_python-0.0.5}/LICENSE +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/__init__.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/components/__init__.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/components/config.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/components/store.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/changes.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/common.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/config.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/__init__.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/categories.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/info.py +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/json/category_by_name_schema.json +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/json/category_schema.json +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/json/snaps_find_schema.json +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/json/snaps_info_schema.json +0 -0
- {snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: snap-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: An api to interact with snapd and snap stores
|
|
5
5
|
Home-page: https://github.com/alexlukens/snap-python
|
|
6
6
|
License: MIT
|
|
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
16
|
Requires-Dist: httpx (>=0.27.2,<0.28.0)
|
|
16
17
|
Requires-Dist: pydantic (>=2.9.2,<3.0.0)
|
|
17
18
|
Requires-Dist: retry (>=0.9.2,<0.10.0)
|
|
@@ -38,6 +39,15 @@ Here is a simple example of how to use snap_python:
|
|
|
38
39
|
# TODO
|
|
39
40
|
```
|
|
40
41
|
|
|
42
|
+
## Create a Release
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git tag -a v0.x.x -m "Release v0.x.x"
|
|
46
|
+
gh release create v0.x.x --title "Release v0.x.x"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The automation will build a wheel and push it to pypi
|
|
50
|
+
|
|
41
51
|
## License
|
|
42
52
|
|
|
43
53
|
This project is licensed under the MIT License. See the LICENSE file for more details.
|
|
@@ -18,6 +18,15 @@ Here is a simple example of how to use snap_python:
|
|
|
18
18
|
# TODO
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
## Create a Release
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git tag -a v0.x.x -m "Release v0.x.x"
|
|
25
|
+
gh release create v0.x.x --title "Release v0.x.x"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The automation will build a wheel and push it to pypi
|
|
29
|
+
|
|
21
30
|
## License
|
|
22
31
|
|
|
23
32
|
This project is licensed under the MIT License. See the LICENSE file for more details.
|
|
@@ -27,6 +27,7 @@ class SnapClient(AbstractSnapsClient):
|
|
|
27
27
|
tcp_location: str = None,
|
|
28
28
|
store_base_url: str = "https://api.snapcraft.io",
|
|
29
29
|
store_headers: dict[str, str] = None,
|
|
30
|
+
prompt_for_authentication: bool = False,
|
|
30
31
|
):
|
|
31
32
|
if tcp_location and snapd_socket_location:
|
|
32
33
|
raise ValueError(
|
|
@@ -40,14 +41,19 @@ class SnapClient(AbstractSnapsClient):
|
|
|
40
41
|
self._transport = httpx.AsyncHTTPTransport(
|
|
41
42
|
uds=snapd_socket_location or SNAPD_SOCKET
|
|
42
43
|
)
|
|
43
|
-
|
|
44
44
|
if store_headers is None:
|
|
45
45
|
store_headers = {"Snap-Device-Series": "16", "X-Ubuntu-Series": "16"}
|
|
46
46
|
|
|
47
|
+
snapd_headers = {}
|
|
48
|
+
if prompt_for_authentication:
|
|
49
|
+
snapd_headers = {"X-Allow-Interaction": "true"}
|
|
50
|
+
|
|
47
51
|
self.version = version
|
|
48
52
|
self.store_base_url = store_base_url
|
|
49
53
|
self.store_headers = store_headers
|
|
50
|
-
self.snapd_client = httpx.AsyncClient(
|
|
54
|
+
self.snapd_client = httpx.AsyncClient(
|
|
55
|
+
transport=self._transport, headers=snapd_headers
|
|
56
|
+
)
|
|
51
57
|
self.snaps = SnapsEndpoints(self)
|
|
52
58
|
self.store = StoreEndpoints(
|
|
53
59
|
base_url=self.store_base_url,
|
|
@@ -60,6 +60,7 @@ class SnapsEndpoints:
|
|
|
60
60
|
snap: str,
|
|
61
61
|
channel: str = "stable",
|
|
62
62
|
classic: bool = False,
|
|
63
|
+
dangerous: bool = False,
|
|
63
64
|
devmode: bool = False,
|
|
64
65
|
ignore_validation: bool = False,
|
|
65
66
|
jailmode: bool = False,
|
|
@@ -76,6 +77,7 @@ class SnapsEndpoints:
|
|
|
76
77
|
snap (str): name of the snap to install
|
|
77
78
|
channel (str, optional): Channel to install. Defaults to "stable".
|
|
78
79
|
classic (bool, optional): Install with classic confinement. Defaults to False.
|
|
80
|
+
dangerous (bool, optional): install the given snap files even if there are no pre-acknowledged signatures for them, meaning they are not verified and could be dangerous if true (optional, implied by devmode). Defaults to False.
|
|
79
81
|
devmode (bool, optional): Install with devmode. Defaults to False.
|
|
80
82
|
ignore_validation (bool, optional): _description_. Defaults to False.
|
|
81
83
|
jailmode (bool, optional): Install snap with jailmode. Defaults to False.
|
|
@@ -93,6 +95,7 @@ class SnapsEndpoints:
|
|
|
93
95
|
"action": "install",
|
|
94
96
|
"channel": channel,
|
|
95
97
|
"classic": classic,
|
|
98
|
+
"dangerous": dangerous,
|
|
96
99
|
"devmode": devmode,
|
|
97
100
|
"ignore_validation": ignore_validation,
|
|
98
101
|
"jailmode": jailmode,
|
|
@@ -103,7 +106,10 @@ class SnapsEndpoints:
|
|
|
103
106
|
# sideload
|
|
104
107
|
if not Path(filename).exists():
|
|
105
108
|
raise FileNotFoundError(f"File {filename} does not exist")
|
|
106
|
-
request_data
|
|
109
|
+
if request_data.get("dangerous") is not True:
|
|
110
|
+
raise ValueError(
|
|
111
|
+
"Cannot sideload snap without dangerous flag set to True"
|
|
112
|
+
)
|
|
107
113
|
raw_response: httpx.Response = await self._client.request(
|
|
108
114
|
"POST",
|
|
109
115
|
f"{self.common_endpoint}",
|
|
@@ -13,10 +13,17 @@ from snap_python.schemas.common import (
|
|
|
13
13
|
from snap_python.schemas.store.categories import Category
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
class SnapHealth(BaseModel):
|
|
17
|
+
status: str
|
|
18
|
+
revision: str
|
|
19
|
+
timestamp: AwareDatetime
|
|
20
|
+
|
|
21
|
+
|
|
16
22
|
class InstalledSnapFields(Revision):
|
|
17
23
|
apps: list[SnapApp] = Field(default_factory=list)
|
|
18
24
|
developer: Optional[str] = None
|
|
19
25
|
devmode: Optional[bool] = None
|
|
26
|
+
health: Optional[SnapHealth] = None
|
|
20
27
|
icon: Optional[str] = None
|
|
21
28
|
id: Optional[str] = Field(
|
|
22
29
|
None, validation_alias=AliasChoices("id", "snap-id"), serialization_alias="id"
|
|
@@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional
|
|
|
3
3
|
from pydantic import AliasChoices, AwareDatetime, BaseModel, ConfigDict, Field
|
|
4
4
|
|
|
5
5
|
from snap_python.schemas.common import Revision
|
|
6
|
-
from snap_python.schemas.snaps import InstalledSnap, StoreSnap, StoreSnapFields
|
|
6
|
+
from snap_python.schemas.snaps import InstalledSnap, Snap, StoreSnap, StoreSnapFields
|
|
7
7
|
|
|
8
8
|
VALID_SEARCH_CATEGORY_FIELDS = [
|
|
9
9
|
"base",
|
|
@@ -99,15 +99,17 @@ class SearchResult(BaseModel):
|
|
|
99
99
|
revision_info[field] = snap_info.pop(field)
|
|
100
100
|
|
|
101
101
|
snap_id = snap_info.pop("id")
|
|
102
|
-
snap_name = snap_info.
|
|
102
|
+
snap_name = snap_info.get("name")
|
|
103
103
|
|
|
104
104
|
# get set of acceptable fields for StoreSnap
|
|
105
|
-
store_snap_fields = StoreSnapFields.model_fields.keys()
|
|
106
|
-
|
|
105
|
+
store_snap_fields = set(StoreSnapFields.model_fields.keys()).union(
|
|
106
|
+
Snap.model_fields.keys()
|
|
107
|
+
)
|
|
108
|
+
store_snap_info = {
|
|
107
109
|
key: value for key, value in snap_info.items() if key in store_snap_fields
|
|
108
110
|
}
|
|
109
111
|
|
|
110
|
-
snap_info = {"snap":
|
|
112
|
+
snap_info = {"snap": store_snap_info, "snap-id": snap_id, "name": snap_name}
|
|
111
113
|
snap_info["revision"] = revision_info
|
|
112
114
|
|
|
113
115
|
return cls.model_validate(snap_info)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/json/category_schema.json
RENAMED
|
File without changes
|
{snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/json/snaps_find_schema.json
RENAMED
|
File without changes
|
{snap_python-0.0.4 → snap_python-0.0.5}/src/snap_python/schemas/store/json/snaps_info_schema.json
RENAMED
|
File without changes
|
|
File without changes
|