lid-cli 0.4__tar.gz → 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.
- {lid_cli-0.4 → lid_cli-0.5}/PKG-INFO +1 -1
- {lid_cli-0.4 → lid_cli-0.5}/pyproject.toml +1 -1
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/gio.py +33 -7
- {lid_cli-0.4 → lid_cli-0.5}/LICENSES/MIT.txt +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/README.md +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/__init__.py +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/__main__.py +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/cli.py +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/io.py +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/py.typed +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/subprocess.py +0 -0
- {lid_cli-0.4 → lid_cli-0.5}/src/lid/types.py +0 -0
|
@@ -79,11 +79,17 @@ async def mount(kw: str, /, env: types.Environment, runner: AsyncRunner) -> type
|
|
|
79
79
|
log.exception("Failed to mount volume ID `%s`.", mount_id)
|
|
80
80
|
raise types.GioError(f"failed to mount volume with ID`{mount_id}`") from err
|
|
81
81
|
|
|
82
|
+
# Update information to make sure mount information is present.
|
|
83
|
+
volume_info = await _query_matching_volume_info(
|
|
84
|
+
kw, include_details=True, env=env, runner=runner
|
|
85
|
+
)
|
|
86
|
+
volume = _extract_volume(kw, volume_info=volume_info)
|
|
87
|
+
|
|
82
88
|
try:
|
|
83
89
|
mp = await _find_mountpoint(
|
|
84
|
-
volume.data
|
|
90
|
+
_extract_gio_location(volume.data), env=env, runner=runner
|
|
85
91
|
)
|
|
86
|
-
except types.GioError as err:
|
|
92
|
+
except (ValueError, types.GioError) as err:
|
|
87
93
|
log.exception("Found no mount point for `%s`.", name)
|
|
88
94
|
raise types.GioError(f"found no mount point for `{name}`") from err
|
|
89
95
|
|
|
@@ -112,9 +118,9 @@ async def umount(
|
|
|
112
118
|
|
|
113
119
|
try:
|
|
114
120
|
mountpoint = await _find_mountpoint(
|
|
115
|
-
volume.data
|
|
121
|
+
_extract_gio_location(volume.data), env=env, runner=runner
|
|
116
122
|
)
|
|
117
|
-
except types.GioError as err:
|
|
123
|
+
except (ValueError, types.GioError) as err:
|
|
118
124
|
log.exception("Found no mount point for `%s`.", name)
|
|
119
125
|
raise types.GioError(f"found no mount point for `{name}`") from err
|
|
120
126
|
else:
|
|
@@ -196,14 +202,31 @@ def _extract_volume(kw: str, /, volume_info: Sequence[dict[str, Any]]) -> _Volum
|
|
|
196
202
|
raise types.GioError("unsupported gio output structure")
|
|
197
203
|
|
|
198
204
|
|
|
205
|
+
def _extract_gio_location(info: dict[str, Any], /) -> str:
|
|
206
|
+
try:
|
|
207
|
+
mount_info = next(v for k, v in info.items() if k.startswith("Mount"))
|
|
208
|
+
except StopIteration:
|
|
209
|
+
raise ValueError("no mount information found") from None
|
|
210
|
+
if not isinstance(mount_info, dict):
|
|
211
|
+
raise ValueError("invalid mount information found")
|
|
212
|
+
|
|
213
|
+
if (loc := mount_info.get("default_location")) is not None:
|
|
214
|
+
return loc
|
|
215
|
+
mount_name, loc_pattern = mount_info.get("__name__", ""), r"->\s*(?P<loc>.+?)$"
|
|
216
|
+
if (m := re.search(loc_pattern, mount_name)) is not None:
|
|
217
|
+
return m.group("loc")
|
|
218
|
+
|
|
219
|
+
raise ValueError("no mount location found")
|
|
220
|
+
|
|
221
|
+
|
|
199
222
|
async def _find_mountpoint(
|
|
200
|
-
|
|
223
|
+
loc: str, /, env: types.Environment, runner: AsyncRunner
|
|
201
224
|
) -> str:
|
|
202
225
|
try:
|
|
203
226
|
# Requires volume to be mounted.
|
|
204
227
|
# Need to the US locale as the output key are adapted to that setting.
|
|
205
228
|
gio_out = await runner(
|
|
206
|
-
env.gio_bin, "info", "-a", "local",
|
|
229
|
+
env.gio_bin, "info", "-a", "local", loc, env_mods={"LANG": "en_US-UTF-8"}
|
|
207
230
|
)
|
|
208
231
|
except types.SubprocessError as err:
|
|
209
232
|
raise types.GioError(
|
|
@@ -214,7 +237,10 @@ async def _find_mountpoint(
|
|
|
214
237
|
except types.GioError as err:
|
|
215
238
|
raise types.GioError("failed to parse gio output for path discovery") from err
|
|
216
239
|
|
|
217
|
-
|
|
240
|
+
try:
|
|
241
|
+
return gio_out["local path"]
|
|
242
|
+
except KeyError:
|
|
243
|
+
raise types.GioError(f"`{loc}` has no local filesystem path") from None
|
|
218
244
|
|
|
219
245
|
|
|
220
246
|
def _parse_output(text: str, /, header_name: str = "__name__") -> dict[str, Any]:
|
|
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
|