rclone-api 1.0.30__py2.py3-none-any.whl → 1.0.31__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rclone-api might be problematic. Click here for more details.
- rclone_api/rclone.py +40 -2
- rclone_api/util.py +7 -5
- {rclone_api-1.0.30.dist-info → rclone_api-1.0.31.dist-info}/METADATA +1 -1
- {rclone_api-1.0.30.dist-info → rclone_api-1.0.31.dist-info}/RECORD +8 -8
- {rclone_api-1.0.30.dist-info → rclone_api-1.0.31.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.30.dist-info → rclone_api-1.0.31.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.30.dist-info → rclone_api-1.0.31.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.0.30.dist-info → rclone_api-1.0.31.dist-info}/top_level.txt +0 -0
rclone_api/rclone.py
CHANGED
@@ -9,6 +9,7 @@ from concurrent.futures import ThreadPoolExecutor
|
|
9
9
|
from enum import Enum
|
10
10
|
from fnmatch import fnmatch
|
11
11
|
from pathlib import Path
|
12
|
+
from tempfile import TemporaryDirectory
|
12
13
|
from typing import Generator
|
13
14
|
|
14
15
|
from rclone_api import Dir
|
@@ -228,8 +229,45 @@ class Rclone:
|
|
228
229
|
) -> subprocess.CompletedProcess:
|
229
230
|
"""Delete a directory"""
|
230
231
|
payload: list[str] = convert_to_filestr_list(files)
|
231
|
-
|
232
|
-
|
232
|
+
|
233
|
+
datalists: dict[str, list[str]] = {}
|
234
|
+
|
235
|
+
for f in payload:
|
236
|
+
remote, path = f.split(":", 1)
|
237
|
+
if "/" in path:
|
238
|
+
bucket, path = path.split("/", 1)
|
239
|
+
remote = f"{remote}:{bucket}"
|
240
|
+
else:
|
241
|
+
remote = f"{remote}:"
|
242
|
+
if remote not in datalists:
|
243
|
+
datalists[remote] = []
|
244
|
+
datalists[remote].append(path)
|
245
|
+
|
246
|
+
out: subprocess.CompletedProcess | None = None
|
247
|
+
|
248
|
+
for remote, files in datalists.items():
|
249
|
+
with TemporaryDirectory() as tmpdir:
|
250
|
+
include_files_txt = Path(tmpdir) / "include_files.txt"
|
251
|
+
include_files_txt.write_text("\n".join(files), encoding="utf-8")
|
252
|
+
|
253
|
+
print(include_files_txt)
|
254
|
+
cmd_list: list[str] = [
|
255
|
+
"delete",
|
256
|
+
remote,
|
257
|
+
"--files-from",
|
258
|
+
str(include_files_txt),
|
259
|
+
"--checkers",
|
260
|
+
"1000",
|
261
|
+
"--transfers",
|
262
|
+
"1000",
|
263
|
+
]
|
264
|
+
out = self._run(cmd_list)
|
265
|
+
if out.returncode != 0:
|
266
|
+
print(out)
|
267
|
+
raise ValueError(f"Error deleting files: {out.stderr}")
|
268
|
+
|
269
|
+
assert out is not None
|
270
|
+
return out
|
233
271
|
|
234
272
|
def exists(self, path: Dir | Remote | str | File) -> bool:
|
235
273
|
"""Check if a file or directory exists."""
|
rclone_api/util.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2
2
|
import shutil
|
3
3
|
import subprocess
|
4
4
|
import time
|
5
|
+
import warnings
|
5
6
|
from pathlib import Path
|
6
7
|
from tempfile import TemporaryDirectory
|
7
8
|
from typing import Any
|
@@ -96,16 +97,17 @@ def rclone_execute(
|
|
96
97
|
cmd_str = subprocess.list2cmdline(cmd)
|
97
98
|
print(f"Running: {cmd_str}")
|
98
99
|
cp = subprocess.run(
|
99
|
-
cmd, capture_output=True, encoding="utf-8", check=
|
100
|
+
cmd, capture_output=True, encoding="utf-8", check=False, shell=False
|
100
101
|
)
|
101
102
|
if cp.returncode != 0:
|
102
103
|
cmd_str = subprocess.list2cmdline(cmd)
|
103
|
-
|
104
|
+
warnings.warn(
|
104
105
|
f"Error running: {cmd_str}, returncode: {cp.returncode}\n{cp.stdout}\n{cp.stderr}"
|
105
106
|
)
|
106
|
-
|
107
|
-
|
108
|
-
|
107
|
+
if check:
|
108
|
+
raise subprocess.CalledProcessError(
|
109
|
+
cp.returncode, cmd, cp.stdout, cp.stderr
|
110
|
+
)
|
109
111
|
return cp
|
110
112
|
finally:
|
111
113
|
if tempdir:
|
@@ -9,16 +9,16 @@ rclone_api/exec.py,sha256=HWmnU2Jwb-3EttSbAJSaLloYA7YI2mHTzRJ5VEri9aM,941
|
|
9
9
|
rclone_api/file.py,sha256=D02iHJW1LhfOiM_R_yPHP8_ApnDiYrkuraVcrV8-qkw,1246
|
10
10
|
rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
|
11
11
|
rclone_api/process.py,sha256=RrMfTe0bndmJ6gBK67ioqNvCstJ8aTC8RlGX1XBLlcw,4191
|
12
|
-
rclone_api/rclone.py,sha256=
|
12
|
+
rclone_api/rclone.py,sha256=AHxdI_X-MwO1x74YCjocdNmhyOOhQHXIrlsB5lGhpjM,17897
|
13
13
|
rclone_api/remote.py,sha256=c9hlRKBCg1BFB9MCINaQIoCg10qyAkeqiS4brl8ce-8,343
|
14
14
|
rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
|
15
|
-
rclone_api/util.py,sha256=
|
15
|
+
rclone_api/util.py,sha256=sUjH5NmsawmNbPMY7V6hD8vFJXCwbl44XM1kuij3tA0,3918
|
16
16
|
rclone_api/walk.py,sha256=kca0t1GAnF6FLclN01G8NG__Qe-ggodLtAbQSHyVPng,2968
|
17
17
|
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
18
18
|
rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
|
19
|
-
rclone_api-1.0.
|
20
|
-
rclone_api-1.0.
|
21
|
-
rclone_api-1.0.
|
22
|
-
rclone_api-1.0.
|
23
|
-
rclone_api-1.0.
|
24
|
-
rclone_api-1.0.
|
19
|
+
rclone_api-1.0.31.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
20
|
+
rclone_api-1.0.31.dist-info/METADATA,sha256=-VZg53oPrt0McTNAkhx4XZqIQAux2psCcBty7a2hFzE,4488
|
21
|
+
rclone_api-1.0.31.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
22
|
+
rclone_api-1.0.31.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
|
23
|
+
rclone_api-1.0.31.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
24
|
+
rclone_api-1.0.31.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|