rclone-api 1.0.36__py2.py3-none-any.whl → 1.0.38__py2.py3-none-any.whl
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.
- rclone_api/completed_process.py +15 -0
- rclone_api/diff.py +0 -1
- rclone_api/rclone.py +32 -18
- {rclone_api-1.0.36.dist-info → rclone_api-1.0.38.dist-info}/METADATA +1 -1
- {rclone_api-1.0.36.dist-info → rclone_api-1.0.38.dist-info}/RECORD +9 -8
- {rclone_api-1.0.36.dist-info → rclone_api-1.0.38.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.36.dist-info → rclone_api-1.0.38.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.36.dist-info → rclone_api-1.0.38.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.0.36.dist-info → rclone_api-1.0.38.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
import subprocess
|
2
|
+
from dataclasses import dataclass
|
3
|
+
|
4
|
+
|
5
|
+
@dataclass
|
6
|
+
class CompletedProcess:
|
7
|
+
completed: list[subprocess.CompletedProcess]
|
8
|
+
|
9
|
+
@property
|
10
|
+
def ok(self) -> bool:
|
11
|
+
return all([p.returncode == 0 for p in self.completed])
|
12
|
+
|
13
|
+
@staticmethod
|
14
|
+
def from_subprocess(process: subprocess.CompletedProcess) -> "CompletedProcess":
|
15
|
+
return CompletedProcess(completed=[process])
|
rclone_api/diff.py
CHANGED
rclone_api/rclone.py
CHANGED
@@ -12,6 +12,7 @@ from tempfile import TemporaryDirectory
|
|
12
12
|
from typing import Generator
|
13
13
|
|
14
14
|
from rclone_api import Dir
|
15
|
+
from rclone_api.completed_process import CompletedProcess
|
15
16
|
from rclone_api.config import Config
|
16
17
|
from rclone_api.convert import convert_to_filestr_list, convert_to_str
|
17
18
|
from rclone_api.deprecated import deprecated
|
@@ -216,7 +217,7 @@ class Rclone:
|
|
216
217
|
include_files_txt = Path(tmpdir) / "include_files.txt"
|
217
218
|
include_files_txt.write_text("\n".join(files), encoding="utf-8")
|
218
219
|
|
219
|
-
print(include_files_txt)
|
220
|
+
# print(include_files_txt)
|
220
221
|
cmd_list: list[str] = [
|
221
222
|
"delete",
|
222
223
|
remote,
|
@@ -234,7 +235,7 @@ class Rclone:
|
|
234
235
|
|
235
236
|
assert out is not None
|
236
237
|
|
237
|
-
def copy(self, src: Dir | str, dst: Dir | str) ->
|
238
|
+
def copy(self, src: Dir | str, dst: Dir | str) -> CompletedProcess:
|
238
239
|
"""Copy files from source to destination.
|
239
240
|
|
240
241
|
Args:
|
@@ -246,37 +247,42 @@ class Rclone:
|
|
246
247
|
src_dir = convert_to_str(src)
|
247
248
|
dst_dir = convert_to_str(dst)
|
248
249
|
cmd_list: list[str] = ["copy", src_dir, dst_dir]
|
249
|
-
|
250
|
+
cp = self._run(cmd_list)
|
251
|
+
return CompletedProcess.from_subprocess(cp)
|
250
252
|
|
251
|
-
def purge(self, path: Dir | str) ->
|
253
|
+
def purge(self, path: Dir | str) -> CompletedProcess:
|
252
254
|
"""Purge a directory"""
|
253
255
|
# path should always be a string
|
254
256
|
path = path if isinstance(path, str) else str(path.path)
|
255
257
|
cmd_list: list[str] = ["purge", str(path)]
|
256
|
-
|
258
|
+
cp = self._run(cmd_list)
|
259
|
+
return CompletedProcess.from_subprocess(cp)
|
257
260
|
|
258
261
|
def delete_files(
|
259
|
-
self, files: str | File | list[str] | list[File]
|
260
|
-
) ->
|
262
|
+
self, files: str | File | list[str] | list[File], check=True
|
263
|
+
) -> CompletedProcess:
|
261
264
|
"""Delete a directory"""
|
262
265
|
payload: list[str] = convert_to_filestr_list(files)
|
263
266
|
if len(payload) == 0:
|
264
|
-
|
267
|
+
cp = subprocess.CompletedProcess(
|
265
268
|
args=["rclone", "delete", "--files-from", "[]"],
|
266
269
|
returncode=0,
|
267
270
|
stdout="",
|
268
271
|
stderr="",
|
269
272
|
)
|
273
|
+
return CompletedProcess.from_subprocess(cp)
|
270
274
|
|
271
275
|
datalists: dict[str, list[str]] = partition_files(payload)
|
272
276
|
out: subprocess.CompletedProcess | None = None
|
273
277
|
|
278
|
+
completed_processes: list[subprocess.CompletedProcess] = []
|
279
|
+
|
274
280
|
for remote, files in datalists.items():
|
275
281
|
with TemporaryDirectory() as tmpdir:
|
276
282
|
include_files_txt = Path(tmpdir) / "include_files.txt"
|
277
283
|
include_files_txt.write_text("\n".join(files), encoding="utf-8")
|
278
284
|
|
279
|
-
print(include_files_txt)
|
285
|
+
# print(include_files_txt)
|
280
286
|
cmd_list: list[str] = [
|
281
287
|
"delete",
|
282
288
|
remote,
|
@@ -288,18 +294,23 @@ class Rclone:
|
|
288
294
|
"1000",
|
289
295
|
]
|
290
296
|
out = self._run(cmd_list)
|
297
|
+
completed_processes.append(out)
|
291
298
|
if out.returncode != 0:
|
292
|
-
|
293
|
-
|
299
|
+
if check:
|
300
|
+
completed_processes.append(out)
|
301
|
+
raise ValueError(f"Error deleting files: {out}")
|
302
|
+
else:
|
303
|
+
warnings.warn(f"Error deleting files: {out}")
|
294
304
|
|
295
305
|
assert out is not None
|
296
|
-
return
|
306
|
+
return CompletedProcess(completed_processes)
|
297
307
|
|
298
308
|
@deprecated("delete_files")
|
299
309
|
def deletefiles(
|
300
310
|
self, files: str | File | list[str] | list[File]
|
301
|
-
) ->
|
302
|
-
|
311
|
+
) -> CompletedProcess:
|
312
|
+
out = self.delete_files(files)
|
313
|
+
return out
|
303
314
|
|
304
315
|
def exists(self, path: Dir | Remote | str | File) -> bool:
|
305
316
|
"""Check if a file or directory exists."""
|
@@ -325,7 +336,7 @@ class Rclone:
|
|
325
336
|
|
326
337
|
def copy_dir(
|
327
338
|
self, src: str | Dir, dst: str | Dir, args: list[str] | None = None
|
328
|
-
) ->
|
339
|
+
) -> CompletedProcess:
|
329
340
|
"""Copy a directory from source to destination."""
|
330
341
|
# convert src to str, also dst
|
331
342
|
src = convert_to_str(src)
|
@@ -333,16 +344,19 @@ class Rclone:
|
|
333
344
|
cmd_list: list[str] = ["copy", src, dst]
|
334
345
|
if args is not None:
|
335
346
|
cmd_list += args
|
336
|
-
|
347
|
+
cp = self._run(cmd_list)
|
348
|
+
return CompletedProcess.from_subprocess(cp)
|
337
349
|
|
338
350
|
def copy_remote(
|
339
351
|
self, src: Remote, dst: Remote, args: list[str] | None = None
|
340
|
-
) ->
|
352
|
+
) -> CompletedProcess:
|
341
353
|
"""Copy a remote to another remote."""
|
342
354
|
cmd_list: list[str] = ["copy", str(src), str(dst)]
|
343
355
|
if args is not None:
|
344
356
|
cmd_list += args
|
345
|
-
return self._run(cmd_list)
|
357
|
+
# return self._run(cmd_list)
|
358
|
+
cp = self._run(cmd_list)
|
359
|
+
return CompletedProcess.from_subprocess(cp)
|
346
360
|
|
347
361
|
def mount(
|
348
362
|
self,
|
@@ -1,25 +1,26 @@
|
|
1
1
|
rclone_api/__init__.py,sha256=L_ulzYG9WmQqmrVANt-Omi1FJUQVTkXA7SVZx9QH_9M,457
|
2
2
|
rclone_api/cli.py,sha256=dibfAZIh0kXWsBbfp3onKLjyZXo54mTzDjUdzJlDlWo,231
|
3
|
+
rclone_api/completed_process.py,sha256=rMi94LmnLOSp18u_9yOwcOaR89clb6VbGGB6fROri5Y,400
|
3
4
|
rclone_api/config.py,sha256=tP6cU9DnCCEIRc_KP9HPur1jFLLg2QGFSxNwFm6_MVw,118
|
4
5
|
rclone_api/convert.py,sha256=Mx9Qo7zhkOedJd8LdhPvNGHp8znJzOk4f_2KWnoGc78,1012
|
5
6
|
rclone_api/deprecated.py,sha256=qWKpnZdYcBK7YQZKuVoWWXDwi-uqiAtbjgPcci_efow,590
|
6
|
-
rclone_api/diff.py,sha256=
|
7
|
+
rclone_api/diff.py,sha256=ELUQD1Mv8qaoAav13sEE-iKynFph70rQHj7-a4Z1pyo,4137
|
7
8
|
rclone_api/dir.py,sha256=vV-bcI2ESijmwF5rPID5WO2K7soAfZa35wv4KRh_GIo,2154
|
8
9
|
rclone_api/dir_listing.py,sha256=9Qqf2SUswrOEkyqmaH23V51I18X6ePiXb9B1vUwRF5o,1571
|
9
10
|
rclone_api/exec.py,sha256=HWmnU2Jwb-3EttSbAJSaLloYA7YI2mHTzRJ5VEri9aM,941
|
10
11
|
rclone_api/file.py,sha256=D02iHJW1LhfOiM_R_yPHP8_ApnDiYrkuraVcrV8-qkw,1246
|
11
12
|
rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
|
12
13
|
rclone_api/process.py,sha256=RrMfTe0bndmJ6gBK67ioqNvCstJ8aTC8RlGX1XBLlcw,4191
|
13
|
-
rclone_api/rclone.py,sha256=
|
14
|
+
rclone_api/rclone.py,sha256=kJpg53UXIejOMOtAYbZsuOoLjcRtLInCFeNE8qeYa9g,19668
|
14
15
|
rclone_api/remote.py,sha256=c9hlRKBCg1BFB9MCINaQIoCg10qyAkeqiS4brl8ce-8,343
|
15
16
|
rclone_api/rpath.py,sha256=8ZA_1wxWtskwcy0I8V2VbjKDmzPkiWd8Q2JQSvh-sYE,2586
|
16
17
|
rclone_api/util.py,sha256=N1n2Fxt-pU_xKwQdwXM3zAThBHG0zwDQY30s0iQao-0,4374
|
17
18
|
rclone_api/walk.py,sha256=kca0t1GAnF6FLclN01G8NG__Qe-ggodLtAbQSHyVPng,2968
|
18
19
|
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
19
20
|
rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
|
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.
|
25
|
-
rclone_api-1.0.
|
21
|
+
rclone_api-1.0.38.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
22
|
+
rclone_api-1.0.38.dist-info/METADATA,sha256=7-dInoLl-1llsaZKtlEDchDOVAov7_Q9zV-ny0QQ0cI,4489
|
23
|
+
rclone_api-1.0.38.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
24
|
+
rclone_api-1.0.38.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
|
25
|
+
rclone_api-1.0.38.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
26
|
+
rclone_api-1.0.38.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|