rclone-api 1.0.37__tar.gz → 1.0.39__tar.gz
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-1.0.37 → rclone_api-1.0.39}/PKG-INFO +1 -1
- {rclone_api-1.0.37 → rclone_api-1.0.39}/pyproject.toml +1 -1
- rclone_api-1.0.39/src/rclone_api/completed_process.py +21 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/rclone.py +30 -14
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api.egg-info/PKG-INFO +1 -1
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api.egg-info/SOURCES.txt +1 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.aiderignore +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.github/workflows/lint.yml +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.github/workflows/push_macos.yml +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.github/workflows/push_ubuntu.yml +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.github/workflows/push_win.yml +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.gitignore +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.pylintrc +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.vscode/launch.json +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.vscode/settings.json +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/.vscode/tasks.json +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/LICENSE +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/MANIFEST.in +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/README.md +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/clean +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/install +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/lint +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/requirements.testing.txt +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/setup.cfg +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/setup.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/__init__.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/assets/example.txt +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/cli.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/cmd/list_files.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/config.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/convert.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/deprecated.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/diff.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/dir.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/dir_listing.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/exec.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/file.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/filelist.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/process.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/remote.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/rpath.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/util.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api/walk.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api.egg-info/dependency_links.txt +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api.egg-info/entry_points.txt +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api.egg-info/requires.txt +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/src/rclone_api.egg-info/top_level.txt +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/test +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_cmd_list_files.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_copy.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_diff.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_is_synced.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_ls.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_mount.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_mount_s3.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_mount_webdav.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_obscure.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_remotes.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_serve_webdav.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tests/test_walk.py +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/tox.ini +0 -0
- {rclone_api-1.0.37 → rclone_api-1.0.39}/upload_package.sh +0 -0
@@ -0,0 +1,21 @@
|
|
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])
|
16
|
+
|
17
|
+
def failed(self) -> list[subprocess.CompletedProcess]:
|
18
|
+
return [p for p in self.completed if p.returncode != 0]
|
19
|
+
|
20
|
+
def successes(self) -> list[subprocess.CompletedProcess]:
|
21
|
+
return [p for p in self.completed if p.returncode == 0]
|
@@ -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
|
@@ -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,27 +247,34 @@ 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,
|
260
|
-
|
262
|
+
self,
|
263
|
+
files: str | File | list[str] | list[File],
|
264
|
+
check=True,
|
265
|
+
rmdirs=False,
|
266
|
+
other_args: list[str] | None = None,
|
267
|
+
) -> CompletedProcess:
|
261
268
|
"""Delete a directory"""
|
262
269
|
payload: list[str] = convert_to_filestr_list(files)
|
263
270
|
if len(payload) == 0:
|
264
|
-
|
271
|
+
cp = subprocess.CompletedProcess(
|
265
272
|
args=["rclone", "delete", "--files-from", "[]"],
|
266
273
|
returncode=0,
|
267
274
|
stdout="",
|
268
275
|
stderr="",
|
269
276
|
)
|
277
|
+
return CompletedProcess.from_subprocess(cp)
|
270
278
|
|
271
279
|
datalists: dict[str, list[str]] = partition_files(payload)
|
272
280
|
out: subprocess.CompletedProcess | None = None
|
@@ -289,6 +297,10 @@ class Rclone:
|
|
289
297
|
"--transfers",
|
290
298
|
"1000",
|
291
299
|
]
|
300
|
+
if rmdirs:
|
301
|
+
cmd_list.append("--rmdirs")
|
302
|
+
if other_args:
|
303
|
+
cmd_list += other_args
|
292
304
|
out = self._run(cmd_list)
|
293
305
|
completed_processes.append(out)
|
294
306
|
if out.returncode != 0:
|
@@ -299,13 +311,14 @@ class Rclone:
|
|
299
311
|
warnings.warn(f"Error deleting files: {out}")
|
300
312
|
|
301
313
|
assert out is not None
|
302
|
-
return
|
314
|
+
return CompletedProcess(completed_processes)
|
303
315
|
|
304
316
|
@deprecated("delete_files")
|
305
317
|
def deletefiles(
|
306
318
|
self, files: str | File | list[str] | list[File]
|
307
|
-
) ->
|
308
|
-
|
319
|
+
) -> CompletedProcess:
|
320
|
+
out = self.delete_files(files)
|
321
|
+
return out
|
309
322
|
|
310
323
|
def exists(self, path: Dir | Remote | str | File) -> bool:
|
311
324
|
"""Check if a file or directory exists."""
|
@@ -331,7 +344,7 @@ class Rclone:
|
|
331
344
|
|
332
345
|
def copy_dir(
|
333
346
|
self, src: str | Dir, dst: str | Dir, args: list[str] | None = None
|
334
|
-
) ->
|
347
|
+
) -> CompletedProcess:
|
335
348
|
"""Copy a directory from source to destination."""
|
336
349
|
# convert src to str, also dst
|
337
350
|
src = convert_to_str(src)
|
@@ -339,16 +352,19 @@ class Rclone:
|
|
339
352
|
cmd_list: list[str] = ["copy", src, dst]
|
340
353
|
if args is not None:
|
341
354
|
cmd_list += args
|
342
|
-
|
355
|
+
cp = self._run(cmd_list)
|
356
|
+
return CompletedProcess.from_subprocess(cp)
|
343
357
|
|
344
358
|
def copy_remote(
|
345
359
|
self, src: Remote, dst: Remote, args: list[str] | None = None
|
346
|
-
) ->
|
360
|
+
) -> CompletedProcess:
|
347
361
|
"""Copy a remote to another remote."""
|
348
362
|
cmd_list: list[str] = ["copy", str(src), str(dst)]
|
349
363
|
if args is not None:
|
350
364
|
cmd_list += args
|
351
|
-
return self._run(cmd_list)
|
365
|
+
# return self._run(cmd_list)
|
366
|
+
cp = self._run(cmd_list)
|
367
|
+
return CompletedProcess.from_subprocess(cp)
|
352
368
|
|
353
369
|
def mount(
|
354
370
|
self,
|
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
|
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
|
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
|
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
|
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
|
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
|
File without changes
|
File without changes
|