rclone-api 1.0.17__py2.py3-none-any.whl → 1.0.18__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- rclone_api/process.py +3 -1
- rclone_api/rclone.py +84 -1
- {rclone_api-1.0.17.dist-info → rclone_api-1.0.18.dist-info}/METADATA +1 -1
- {rclone_api-1.0.17.dist-info → rclone_api-1.0.18.dist-info}/RECORD +7 -7
- {rclone_api-1.0.17.dist-info → rclone_api-1.0.18.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.17.dist-info → rclone_api-1.0.18.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.17.dist-info → rclone_api-1.0.18.dist-info}/top_level.txt +0 -0
rclone_api/process.py
CHANGED
@@ -69,8 +69,10 @@ class Process:
|
|
69
69
|
tmpfile = Path(self.tempdir.name) / "rclone.conf"
|
70
70
|
tmpfile.write_text(args.rclone_conf.text, encoding="utf-8")
|
71
71
|
rclone_conf = tmpfile
|
72
|
+
self.needs_cleanup = True
|
72
73
|
else:
|
73
74
|
rclone_conf = args.rclone_conf
|
75
|
+
self.needs_cleanup = False
|
74
76
|
|
75
77
|
assert rclone_conf.exists()
|
76
78
|
|
@@ -85,7 +87,7 @@ class Process:
|
|
85
87
|
self.process = subprocess.Popen(self.cmd, shell=False)
|
86
88
|
|
87
89
|
def cleanup(self) -> None:
|
88
|
-
if self.tempdir:
|
90
|
+
if self.tempdir and self.needs_cleanup:
|
89
91
|
try:
|
90
92
|
self.tempdir.cleanup()
|
91
93
|
except Exception as e:
|
rclone_api/rclone.py
CHANGED
@@ -239,7 +239,13 @@ class Rclone:
|
|
239
239
|
return self._run(cmd_list)
|
240
240
|
|
241
241
|
def mount(
|
242
|
-
self,
|
242
|
+
self,
|
243
|
+
src: Remote | Dir | str,
|
244
|
+
outdir: Path,
|
245
|
+
allow_writes=False,
|
246
|
+
use_links=True,
|
247
|
+
vfs_cache_mode="full",
|
248
|
+
other_cmds: list[str] | None = None,
|
243
249
|
) -> Process:
|
244
250
|
"""Mount a remote or directory to a local path.
|
245
251
|
|
@@ -266,8 +272,85 @@ class Rclone:
|
|
266
272
|
cmd_list.append("--read-only")
|
267
273
|
if use_links:
|
268
274
|
cmd_list.append("--links")
|
275
|
+
if vfs_cache_mode:
|
276
|
+
cmd_list.append("--vfs-cache-mode")
|
277
|
+
cmd_list.append(vfs_cache_mode)
|
278
|
+
if other_cmds:
|
279
|
+
cmd_list += other_cmds
|
269
280
|
proc = self._launch_process(cmd_list)
|
270
281
|
time.sleep(2) # give it a moment to mount
|
271
282
|
if proc.poll() is not None:
|
272
283
|
raise ValueError("Mount process failed to start")
|
273
284
|
return proc
|
285
|
+
|
286
|
+
def mount_webdav(
|
287
|
+
self,
|
288
|
+
url: str,
|
289
|
+
outdir: Path,
|
290
|
+
vfs_cache_mode="full",
|
291
|
+
other_cmds: list[str] | None = None,
|
292
|
+
) -> Process:
|
293
|
+
"""Mount a remote or directory to a local path.
|
294
|
+
|
295
|
+
Args:
|
296
|
+
src: Remote or directory to mount
|
297
|
+
outdir: Local path to mount to
|
298
|
+
|
299
|
+
Returns:
|
300
|
+
CompletedProcess from the mount command execution
|
301
|
+
|
302
|
+
Raises:
|
303
|
+
subprocess.CalledProcessError: If the mount operation fails
|
304
|
+
"""
|
305
|
+
if outdir.exists():
|
306
|
+
is_empty = not list(outdir.iterdir())
|
307
|
+
if not is_empty:
|
308
|
+
raise ValueError(
|
309
|
+
f"Mount directory already exists and is not empty: {outdir}"
|
310
|
+
)
|
311
|
+
outdir.rmdir()
|
312
|
+
|
313
|
+
src_str = url
|
314
|
+
cmd_list: list[str] = ["mount", src_str, str(outdir)]
|
315
|
+
cmd_list.append("--vfs-cache-mode")
|
316
|
+
cmd_list.append(vfs_cache_mode)
|
317
|
+
if other_cmds:
|
318
|
+
cmd_list += other_cmds
|
319
|
+
proc = self._launch_process(cmd_list)
|
320
|
+
# proc = rclone_exec.launch_process(cmd_list)
|
321
|
+
time.sleep(2)
|
322
|
+
if proc.poll() is not None:
|
323
|
+
raise ValueError("Mount process failed to start")
|
324
|
+
return proc
|
325
|
+
|
326
|
+
def serve_webdav(
|
327
|
+
self,
|
328
|
+
src: Remote | Dir | str,
|
329
|
+
user: str,
|
330
|
+
password: str,
|
331
|
+
addr: str = "localhost:2049",
|
332
|
+
allow_other: bool = False,
|
333
|
+
) -> Process:
|
334
|
+
"""Serve a remote or directory via NFS.
|
335
|
+
|
336
|
+
Args:
|
337
|
+
src: Remote or directory to serve
|
338
|
+
addr: Network address and port to serve on (default: localhost:2049)
|
339
|
+
allow_other: Allow other users to access the share
|
340
|
+
|
341
|
+
Returns:
|
342
|
+
Process: The running NFS server process
|
343
|
+
|
344
|
+
Raises:
|
345
|
+
ValueError: If the NFS server fails to start
|
346
|
+
"""
|
347
|
+
src_str = convert_to_str(src)
|
348
|
+
cmd_list: list[str] = ["serve", "webdav", "--addr", addr, src_str]
|
349
|
+
cmd_list.extend(["--user", user, "--pass", password])
|
350
|
+
if allow_other:
|
351
|
+
cmd_list.append("--allow-other")
|
352
|
+
proc = self._launch_process(cmd_list)
|
353
|
+
time.sleep(2) # give it a moment to start
|
354
|
+
if proc.poll() is not None:
|
355
|
+
raise ValueError("NFS serve process failed to start")
|
356
|
+
return proc
|
@@ -7,15 +7,15 @@ rclone_api/dir_listing.py,sha256=8t5Jx9ZVOJPqGKTJbWaES6bjgogUT2bnpbPVWwK1Fcs,112
|
|
7
7
|
rclone_api/exec.py,sha256=9qSOpZo8YRYxv3hOvNr57ApnY2KbjxwT1QNr8OgcLM4,883
|
8
8
|
rclone_api/file.py,sha256=D02iHJW1LhfOiM_R_yPHP8_ApnDiYrkuraVcrV8-qkw,1246
|
9
9
|
rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
|
10
|
-
rclone_api/process.py,sha256=
|
11
|
-
rclone_api/rclone.py,sha256=
|
10
|
+
rclone_api/process.py,sha256=C7vdGEvIKcI4fx-Z702wK1qomzSsFpdke2SQnBHxd-Y,3660
|
11
|
+
rclone_api/rclone.py,sha256=J9KKPH7o_DBx5PlTf3ZJMsbt5MVB5yVwB9FZVuWyA-g,12330
|
12
12
|
rclone_api/remote.py,sha256=c9hlRKBCg1BFB9MCINaQIoCg10qyAkeqiS4brl8ce-8,343
|
13
13
|
rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
|
14
14
|
rclone_api/util.py,sha256=BDRJ2MIceDoKVTjUQBwyhjbA8UwPrZ-0ZSa9xyMJd0E,3343
|
15
15
|
rclone_api/walk.py,sha256=J78-bY2AhNpt2ICsI5LqmXRE7oC6wVDoKoicIoU6XMg,1953
|
16
16
|
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
17
|
-
rclone_api-1.0.
|
18
|
-
rclone_api-1.0.
|
19
|
-
rclone_api-1.0.
|
20
|
-
rclone_api-1.0.
|
21
|
-
rclone_api-1.0.
|
17
|
+
rclone_api-1.0.18.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
18
|
+
rclone_api-1.0.18.dist-info/METADATA,sha256=ZzHKYzibXGOl9jGvCCKf90tGkI2dGJn2ux8R5_-4iIA,4421
|
19
|
+
rclone_api-1.0.18.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
20
|
+
rclone_api-1.0.18.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
21
|
+
rclone_api-1.0.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|