rclone-api 1.0.21__py2.py3-none-any.whl → 1.0.23__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- rclone_api/cmd/list_files.py +27 -0
- rclone_api/rclone.py +3 -8
- rclone_api/util.py +15 -0
- {rclone_api-1.0.21.dist-info → rclone_api-1.0.23.dist-info}/METADATA +1 -1
- {rclone_api-1.0.21.dist-info → rclone_api-1.0.23.dist-info}/RECORD +9 -7
- rclone_api-1.0.23.dist-info/entry_points.txt +2 -0
- {rclone_api-1.0.21.dist-info → rclone_api-1.0.23.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.21.dist-info → rclone_api-1.0.23.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.21.dist-info → rclone_api-1.0.23.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
import argparse
|
2
|
+
from pathlib import Path
|
3
|
+
|
4
|
+
from rclone_api import Rclone
|
5
|
+
|
6
|
+
|
7
|
+
def list_files(rclone: Rclone, path: str):
|
8
|
+
"""List files in a remote path."""
|
9
|
+
for dirlisting in rclone.walk(path):
|
10
|
+
for file in dirlisting.files:
|
11
|
+
print(file.path)
|
12
|
+
|
13
|
+
|
14
|
+
def _parse_args() -> argparse.Namespace:
|
15
|
+
parser = argparse.ArgumentParser(description="List files in a remote path.")
|
16
|
+
parser.add_argument("--config", help="Path to rclone config file", required=True)
|
17
|
+
parser.add_argument("path", help="Remote path to list")
|
18
|
+
return parser.parse_args()
|
19
|
+
|
20
|
+
|
21
|
+
def main() -> int:
|
22
|
+
"""Main entry point."""
|
23
|
+
args = _parse_args()
|
24
|
+
path = args.path
|
25
|
+
rclone = Rclone(Path(args.config))
|
26
|
+
list_files(rclone, path)
|
27
|
+
return 0
|
rclone_api/rclone.py
CHANGED
@@ -19,7 +19,7 @@ from rclone_api.file import File
|
|
19
19
|
from rclone_api.process import Process
|
20
20
|
from rclone_api.remote import Remote
|
21
21
|
from rclone_api.rpath import RPath
|
22
|
-
from rclone_api.util import get_rclone_exe, to_path
|
22
|
+
from rclone_api.util import get_rclone_exe, to_path, wait_for_mount
|
23
23
|
from rclone_api.walk import walk
|
24
24
|
|
25
25
|
|
@@ -291,9 +291,7 @@ class Rclone:
|
|
291
291
|
if other_cmds:
|
292
292
|
cmd_list += other_cmds
|
293
293
|
proc = self._launch_process(cmd_list)
|
294
|
-
|
295
|
-
if proc.poll() is not None:
|
296
|
-
raise ValueError("Mount process failed to start")
|
294
|
+
wait_for_mount(outdir, proc)
|
297
295
|
return proc
|
298
296
|
|
299
297
|
def mount_webdav(
|
@@ -330,10 +328,7 @@ class Rclone:
|
|
330
328
|
if other_cmds:
|
331
329
|
cmd_list += other_cmds
|
332
330
|
proc = self._launch_process(cmd_list)
|
333
|
-
|
334
|
-
time.sleep(2)
|
335
|
-
if proc.poll() is not None:
|
336
|
-
raise ValueError("Mount process failed to start")
|
331
|
+
wait_for_mount(outdir, proc)
|
337
332
|
return proc
|
338
333
|
|
339
334
|
def serve_webdav(
|
rclone_api/util.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import os
|
2
2
|
import shutil
|
3
3
|
import subprocess
|
4
|
+
import time
|
4
5
|
from pathlib import Path
|
5
6
|
from tempfile import TemporaryDirectory
|
6
7
|
from typing import Any
|
@@ -112,3 +113,17 @@ def rclone_execute(
|
|
112
113
|
tempdir.cleanup()
|
113
114
|
except Exception as e:
|
114
115
|
print(f"Error cleaning up tempdir: {e}")
|
116
|
+
|
117
|
+
|
118
|
+
def wait_for_mount(path: Path, mount_process: Any, timeout: int = 60) -> None:
|
119
|
+
from rclone_api.process import Process
|
120
|
+
|
121
|
+
assert isinstance(mount_process, Process)
|
122
|
+
expire_time = time.time() + timeout
|
123
|
+
while time.time() < expire_time:
|
124
|
+
rtn = mount_process.poll()
|
125
|
+
if rtn is not None:
|
126
|
+
raise subprocess.CalledProcessError(rtn, mount_process.cmd)
|
127
|
+
if path.exists():
|
128
|
+
return
|
129
|
+
raise TimeoutError(f"Path {path} did not exist after {timeout} seconds")
|
@@ -8,14 +8,16 @@ 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
10
|
rclone_api/process.py,sha256=iVA8_qtJFgHtg92Yb4W7xv9jnyds_7kAdKeSiGCBIZ0,3952
|
11
|
-
rclone_api/rclone.py,sha256=
|
11
|
+
rclone_api/rclone.py,sha256=RBlEi7M8Jpgt8oJcV-2VrhF-iVAtGlpfBJ7YXGjPS_s,12649
|
12
12
|
rclone_api/remote.py,sha256=c9hlRKBCg1BFB9MCINaQIoCg10qyAkeqiS4brl8ce-8,343
|
13
13
|
rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
|
14
|
-
rclone_api/util.py,sha256=
|
14
|
+
rclone_api/util.py,sha256=AWTImA1liCMw52wtS-Gs8Abz96diQ39x6Tx56mvbrEo,3860
|
15
15
|
rclone_api/walk.py,sha256=kca0t1GAnF6FLclN01G8NG__Qe-ggodLtAbQSHyVPng,2968
|
16
16
|
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
17
|
-
rclone_api
|
18
|
-
rclone_api-1.0.
|
19
|
-
rclone_api-1.0.
|
20
|
-
rclone_api-1.0.
|
21
|
-
rclone_api-1.0.
|
17
|
+
rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
|
18
|
+
rclone_api-1.0.23.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
19
|
+
rclone_api-1.0.23.dist-info/METADATA,sha256=UWJf59LRcykpcIWrMtB0mZi_75RvEMXjI48U1bWhGwE,4454
|
20
|
+
rclone_api-1.0.23.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
21
|
+
rclone_api-1.0.23.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
|
22
|
+
rclone_api-1.0.23.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
23
|
+
rclone_api-1.0.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|