rclone-api 1.4.33__py2.py3-none-any.whl → 1.5.1__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/__init__.py +504 -96
- rclone_api/install.py +92 -0
- rclone_api/util.py +315 -307
- rclone_api-1.5.1.dist-info/METADATA +945 -0
- {rclone_api-1.4.33.dist-info → rclone_api-1.5.1.dist-info}/RECORD +9 -8
- rclone_api-1.4.33.dist-info/METADATA +0 -572
- {rclone_api-1.4.33.dist-info → rclone_api-1.5.1.dist-info}/LICENSE +0 -0
- {rclone_api-1.4.33.dist-info → rclone_api-1.5.1.dist-info}/WHEEL +0 -0
- {rclone_api-1.4.33.dist-info → rclone_api-1.5.1.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.4.33.dist-info → rclone_api-1.5.1.dist-info}/top_level.txt +0 -0
rclone_api/__init__.py
CHANGED
@@ -1,49 +1,105 @@
|
|
1
|
-
|
1
|
+
"""
|
2
|
+
Rclone API - Python interface for the Rclone command-line tool.
|
2
3
|
|
4
|
+
This package provides a high-level API for interacting with Rclone,
|
5
|
+
allowing file operations across various cloud storage providers.
|
6
|
+
The API wraps the rclone command-line tool, providing a Pythonic interface
|
7
|
+
for common operations like copying, listing, and managing remote storage.
|
8
|
+
"""
|
9
|
+
|
10
|
+
# Import core components and utilities
|
3
11
|
from datetime import datetime
|
4
12
|
from pathlib import Path
|
5
13
|
from typing import Generator
|
6
14
|
|
15
|
+
# Import logging utilities
|
7
16
|
from rclone_api import log
|
8
17
|
|
18
|
+
# Import data structures and models
|
9
19
|
from .completed_process import CompletedProcess
|
10
|
-
from .config import Config, Parsed, Section
|
11
|
-
from .diff import DiffItem, DiffOption, DiffType
|
12
|
-
from .dir import Dir
|
13
|
-
from .dir_listing import DirListing
|
14
|
-
from .file import File, FileItem
|
15
|
-
from .file_stream import FilesStream
|
16
|
-
from .filelist import FileList
|
17
|
-
from .http_server import HttpFetcher, HttpServer, Range
|
18
|
-
|
19
|
-
# Import
|
20
|
+
from .config import Config, Parsed, Section # Configuration handling
|
21
|
+
from .diff import DiffItem, DiffOption, DiffType # File comparison utilities
|
22
|
+
from .dir import Dir # Directory representation
|
23
|
+
from .dir_listing import DirListing # Directory contents representation
|
24
|
+
from .file import File, FileItem # File representation
|
25
|
+
from .file_stream import FilesStream # Streaming file listings
|
26
|
+
from .filelist import FileList # File list utilities
|
27
|
+
from .http_server import HttpFetcher, HttpServer, Range # HTTP serving capabilities
|
28
|
+
|
29
|
+
# Import logging configuration utilities
|
20
30
|
from .log import configure_logging, setup_default_logging
|
21
|
-
from .mount import Mount
|
22
|
-
from .process import Process
|
23
|
-
from .remote import Remote
|
24
|
-
from .rpath import RPath
|
25
|
-
from .s3.types import MultiUploadResult
|
26
|
-
from .types import
|
27
|
-
|
31
|
+
from .mount import Mount # Mount remote filesystems
|
32
|
+
from .process import Process # Process management
|
33
|
+
from .remote import Remote # Remote storage representation
|
34
|
+
from .rpath import RPath # Remote path utilities
|
35
|
+
from .s3.types import MultiUploadResult # S3-specific types
|
36
|
+
from .types import ( # Common types
|
37
|
+
ListingOption,
|
38
|
+
Order,
|
39
|
+
PartInfo,
|
40
|
+
SizeResult,
|
41
|
+
SizeSuffix,
|
42
|
+
)
|
43
|
+
|
44
|
+
# Set up default logging configuration when the package is imported
|
28
45
|
setup_default_logging()
|
29
46
|
|
30
47
|
|
31
48
|
def rclone_verbose(val: bool | None) -> bool:
|
49
|
+
"""
|
50
|
+
Get or set the global verbosity setting for rclone operations.
|
51
|
+
|
52
|
+
Controls whether rclone commands will produce detailed output.
|
53
|
+
When enabled, commands will show more information about their operation.
|
54
|
+
|
55
|
+
Args:
|
56
|
+
val: If provided, sets the verbosity level. If None, returns the current setting.
|
57
|
+
|
58
|
+
Returns:
|
59
|
+
The current verbosity setting after any change.
|
60
|
+
"""
|
32
61
|
from rclone_api.rclone_impl import rclone_verbose as _rclone_verbose
|
33
62
|
|
34
63
|
return _rclone_verbose(val)
|
35
64
|
|
36
65
|
|
37
66
|
class Rclone:
|
67
|
+
"""
|
68
|
+
Main interface for interacting with Rclone.
|
69
|
+
|
70
|
+
This class provides methods for all major Rclone operations including
|
71
|
+
file transfers, listing, mounting, and remote management.
|
72
|
+
|
73
|
+
It serves as the primary entry point for the API, wrapping the underlying
|
74
|
+
implementation details and providing a clean, consistent interface.
|
75
|
+
"""
|
76
|
+
|
38
77
|
def __init__(
|
39
78
|
self, rclone_conf: Path | Config, rclone_exe: Path | None = None
|
40
79
|
) -> None:
|
80
|
+
"""
|
81
|
+
Initialize the Rclone interface.
|
82
|
+
|
83
|
+
Args:
|
84
|
+
rclone_conf: Path to rclone config file or Config object
|
85
|
+
rclone_exe: Optional path to rclone executable. If None, will search in PATH.
|
86
|
+
"""
|
41
87
|
from rclone_api.rclone_impl import RcloneImpl
|
42
88
|
|
43
89
|
self.impl: RcloneImpl = RcloneImpl(rclone_conf, rclone_exe)
|
44
90
|
|
45
91
|
def webgui(self, other_args: list[str] | None = None) -> Process:
|
46
|
-
"""
|
92
|
+
"""
|
93
|
+
Launch the Rclone web GUI.
|
94
|
+
|
95
|
+
Starts the built-in web interface for interacting with rclone.
|
96
|
+
|
97
|
+
Args:
|
98
|
+
other_args: Additional command-line arguments to pass to rclone
|
99
|
+
|
100
|
+
Returns:
|
101
|
+
Process object representing the running web GUI
|
102
|
+
"""
|
47
103
|
return self.impl.webgui(other_args=other_args)
|
48
104
|
|
49
105
|
def launch_server(
|
@@ -53,7 +109,20 @@ class Rclone:
|
|
53
109
|
password: str | None = None,
|
54
110
|
other_args: list[str] | None = None,
|
55
111
|
) -> Process:
|
56
|
-
"""
|
112
|
+
"""
|
113
|
+
Launch the Rclone server so it can receive commands.
|
114
|
+
|
115
|
+
Starts an rclone server that can be controlled remotely.
|
116
|
+
|
117
|
+
Args:
|
118
|
+
addr: Address and port to listen on (e.g., "localhost:5572")
|
119
|
+
user: Optional username for authentication
|
120
|
+
password: Optional password for authentication
|
121
|
+
other_args: Additional command-line arguments
|
122
|
+
|
123
|
+
Returns:
|
124
|
+
Process object representing the running server
|
125
|
+
"""
|
57
126
|
return self.impl.launch_server(
|
58
127
|
addr=addr, user=user, password=password, other_args=other_args
|
59
128
|
)
|
@@ -66,6 +135,19 @@ class Rclone:
|
|
66
135
|
capture: bool | None = None,
|
67
136
|
other_args: list[str] | None = None,
|
68
137
|
) -> CompletedProcess:
|
138
|
+
"""
|
139
|
+
Send commands to a running rclone server.
|
140
|
+
|
141
|
+
Args:
|
142
|
+
addr: Address of the rclone server (e.g., "localhost:5572")
|
143
|
+
user: Optional username for authentication
|
144
|
+
password: Optional password for authentication
|
145
|
+
capture: Whether to capture and return command output
|
146
|
+
other_args: Additional command-line arguments
|
147
|
+
|
148
|
+
Returns:
|
149
|
+
CompletedProcess containing the command result
|
150
|
+
"""
|
69
151
|
return self.impl.remote_control(
|
70
152
|
addr=addr,
|
71
153
|
user=user,
|
@@ -75,7 +157,18 @@ class Rclone:
|
|
75
157
|
)
|
76
158
|
|
77
159
|
def obscure(self, password: str) -> str:
|
78
|
-
"""
|
160
|
+
"""
|
161
|
+
Obscure a password for use in rclone config files.
|
162
|
+
|
163
|
+
Converts a plaintext password to rclone's obscured format.
|
164
|
+
Note that this is not secure encryption, just light obfuscation.
|
165
|
+
|
166
|
+
Args:
|
167
|
+
password: The plaintext password to obscure
|
168
|
+
|
169
|
+
Returns:
|
170
|
+
The obscured password string
|
171
|
+
"""
|
79
172
|
return self.impl.obscure(password=password)
|
80
173
|
|
81
174
|
def ls_stream(
|
@@ -85,31 +178,39 @@ class Rclone:
|
|
85
178
|
fast_list: bool = False,
|
86
179
|
) -> FilesStream:
|
87
180
|
"""
|
88
|
-
List files in the given path
|
181
|
+
List files in the given path as a stream of results.
|
182
|
+
|
183
|
+
This method is memory-efficient for large directories as it yields
|
184
|
+
results incrementally rather than collecting them all at once.
|
89
185
|
|
90
186
|
Args:
|
91
|
-
|
187
|
+
path: Remote path to list
|
92
188
|
max_depth: Maximum recursion depth (-1 for unlimited)
|
93
|
-
fast_list: Use fast list (only
|
189
|
+
fast_list: Use fast list (only recommended for listing entire repositories or small datasets)
|
190
|
+
|
191
|
+
Returns:
|
192
|
+
A stream of file entries that can be iterated over
|
94
193
|
"""
|
95
194
|
return self.impl.ls_stream(path=path, max_depth=max_depth, fast_list=fast_list)
|
96
195
|
|
97
196
|
def save_to_db(
|
98
197
|
self,
|
99
198
|
src: str,
|
100
|
-
db_url: str,
|
199
|
+
db_url: str, # sqalchemy style url, use sqlite:///data.db or mysql://user:pass@localhost/db or postgres://user:pass@localhost/db
|
101
200
|
max_depth: int = -1,
|
102
201
|
fast_list: bool = False,
|
103
202
|
) -> None:
|
104
203
|
"""
|
105
|
-
Save files to a database (sqlite, mysql, postgres)
|
204
|
+
Save files to a database (sqlite, mysql, postgres).
|
205
|
+
|
206
|
+
Lists all files in the source path and stores their metadata in a database.
|
207
|
+
Useful for creating searchable indexes of remote storage.
|
106
208
|
|
107
209
|
Args:
|
108
210
|
src: Remote path to list, this will be used to populate an entire table, so always use the root-most path.
|
109
211
|
db_url: Database URL, like sqlite:///data.db or mysql://user:pass@localhost/db or postgres://user:pass@localhost/db
|
110
212
|
max_depth: Maximum depth to traverse (-1 for unlimited)
|
111
213
|
fast_list: Use fast list (only use when getting THE entire data repository from the root/bucket)
|
112
|
-
|
113
214
|
"""
|
114
215
|
return self.impl.save_to_db(
|
115
216
|
src=src, db_url=db_url, max_depth=max_depth, fast_list=fast_list
|
@@ -123,6 +224,21 @@ class Rclone:
|
|
123
224
|
order: Order = Order.NORMAL,
|
124
225
|
listing_option: ListingOption = ListingOption.ALL,
|
125
226
|
) -> DirListing:
|
227
|
+
"""
|
228
|
+
List files and directories at the specified path.
|
229
|
+
|
230
|
+
Provides a detailed listing with file metadata.
|
231
|
+
|
232
|
+
Args:
|
233
|
+
path: Path to list (Dir, Remote, or string path)
|
234
|
+
max_depth: Maximum recursion depth (None for default)
|
235
|
+
glob: Optional glob pattern to filter results
|
236
|
+
order: Sorting order for the results
|
237
|
+
listing_option: What types of entries to include
|
238
|
+
|
239
|
+
Returns:
|
240
|
+
DirListing object containing the results
|
241
|
+
"""
|
126
242
|
return self.impl.ls(
|
127
243
|
path=path,
|
128
244
|
max_depth=max_depth,
|
@@ -132,6 +248,14 @@ class Rclone:
|
|
132
248
|
)
|
133
249
|
|
134
250
|
def listremotes(self) -> list[Remote]:
|
251
|
+
"""
|
252
|
+
List all configured remotes.
|
253
|
+
|
254
|
+
Returns a list of all remotes defined in the rclone configuration.
|
255
|
+
|
256
|
+
Returns:
|
257
|
+
List of Remote objects
|
258
|
+
"""
|
135
259
|
return self.impl.listremotes()
|
136
260
|
|
137
261
|
def diff(
|
@@ -150,8 +274,26 @@ class Rclone:
|
|
150
274
|
checkers: int | None = None,
|
151
275
|
other_args: list[str] | None = None,
|
152
276
|
) -> Generator[DiffItem, None, None]:
|
153
|
-
"""
|
154
|
-
|
277
|
+
"""
|
278
|
+
Compare two directories and yield differences.
|
279
|
+
|
280
|
+
Be extra careful with the src and dst values. If you are off by one
|
281
|
+
parent directory, you will get a huge amount of false diffs.
|
282
|
+
|
283
|
+
Args:
|
284
|
+
src: Rclone style src path
|
285
|
+
dst: Rclone style dst path
|
286
|
+
min_size: Minimum file size to check (e.g., "1MB")
|
287
|
+
max_size: Maximum file size to check (e.g., "1GB")
|
288
|
+
diff_option: How to report differences
|
289
|
+
fast_list: Whether to use fast listing
|
290
|
+
size_only: Compare only file sizes, not content
|
291
|
+
checkers: Number of checker threads
|
292
|
+
other_args: Additional command-line arguments
|
293
|
+
|
294
|
+
Yields:
|
295
|
+
DiffItem objects representing each difference found
|
296
|
+
"""
|
155
297
|
return self.impl.diff(
|
156
298
|
src=src,
|
157
299
|
dst=dst,
|
@@ -171,11 +313,17 @@ class Rclone:
|
|
171
313
|
breadth_first: bool = True,
|
172
314
|
order: Order = Order.NORMAL,
|
173
315
|
) -> Generator[DirListing, None, None]:
|
174
|
-
"""
|
316
|
+
"""
|
317
|
+
Walk through the given path recursively, yielding directory listings.
|
318
|
+
|
319
|
+
Similar to os.walk(), but for remote storage. Traverses directories
|
320
|
+
and yields their contents.
|
175
321
|
|
176
322
|
Args:
|
177
|
-
path: Remote path or Remote object to walk through
|
323
|
+
path: Remote path, Dir, or Remote object to walk through
|
178
324
|
max_depth: Maximum depth to traverse (-1 for unlimited)
|
325
|
+
breadth_first: If True, use breadth-first traversal, otherwise depth-first
|
326
|
+
order: Sorting order for directory entries
|
179
327
|
|
180
328
|
Yields:
|
181
329
|
DirListing: Directory listing for each directory encountered
|
@@ -191,17 +339,20 @@ class Rclone:
|
|
191
339
|
max_depth: int = -1,
|
192
340
|
order: Order = Order.NORMAL,
|
193
341
|
) -> Generator[Dir, None, None]:
|
194
|
-
"""
|
342
|
+
"""
|
343
|
+
Find folders that exist in source but are missing in destination.
|
195
344
|
|
196
|
-
|
345
|
+
Useful for identifying directories that need to be created before
|
346
|
+
copying files.
|
197
347
|
|
198
348
|
Args:
|
199
|
-
src: Source directory or Remote to
|
200
|
-
dst: Destination directory or Remote to
|
349
|
+
src: Source directory or Remote to scan
|
350
|
+
dst: Destination directory or Remote to compare against
|
201
351
|
max_depth: Maximum depth to traverse (-1 for unlimited)
|
352
|
+
order: Sorting order for directory entries
|
202
353
|
|
203
354
|
Yields:
|
204
|
-
|
355
|
+
Dir: Each directory that exists in source but not in destination
|
205
356
|
"""
|
206
357
|
return self.impl.scan_missing_folders(
|
207
358
|
src=src, dst=dst, max_depth=max_depth, order=order
|
@@ -210,7 +361,18 @@ class Rclone:
|
|
210
361
|
def cleanup(
|
211
362
|
self, path: str, other_args: list[str] | None = None
|
212
363
|
) -> CompletedProcess:
|
213
|
-
"""
|
364
|
+
"""
|
365
|
+
Cleanup any resources used by the Rclone instance.
|
366
|
+
|
367
|
+
Removes temporary files and directories created by rclone.
|
368
|
+
|
369
|
+
Args:
|
370
|
+
path: Path to clean up
|
371
|
+
other_args: Additional command-line arguments
|
372
|
+
|
373
|
+
Returns:
|
374
|
+
CompletedProcess with the result of the cleanup operation
|
375
|
+
"""
|
214
376
|
return self.impl.cleanup(path=path, other_args=other_args)
|
215
377
|
|
216
378
|
def copy_to(
|
@@ -221,10 +383,21 @@ class Rclone:
|
|
221
383
|
verbose: bool | None = None,
|
222
384
|
other_args: list[str] | None = None,
|
223
385
|
) -> CompletedProcess:
|
224
|
-
"""
|
386
|
+
"""
|
387
|
+
Copy one file from source to destination.
|
388
|
+
|
389
|
+
Warning - this can be slow for large files or when copying between
|
390
|
+
different storage providers.
|
225
391
|
|
226
|
-
|
392
|
+
Args:
|
393
|
+
src: Rclone style src path
|
394
|
+
dst: Rclone style dst path
|
395
|
+
check: Whether to verify the copy with checksums
|
396
|
+
verbose: Whether to show detailed progress
|
397
|
+
other_args: Additional command-line arguments
|
227
398
|
|
399
|
+
Returns:
|
400
|
+
CompletedProcess with the result of the copy operation
|
228
401
|
"""
|
229
402
|
return self.impl.copy_to(
|
230
403
|
src=src, dst=dst, check=check, verbose=verbose, other_args=other_args
|
@@ -249,10 +422,31 @@ class Rclone:
|
|
249
422
|
multi_thread_streams: int | None = None,
|
250
423
|
other_args: list[str] | None = None,
|
251
424
|
) -> list[CompletedProcess]:
|
252
|
-
"""
|
425
|
+
"""
|
426
|
+
Copy multiple files from source to destination.
|
427
|
+
|
428
|
+
Efficiently copies a list of files, potentially in parallel.
|
253
429
|
|
254
430
|
Args:
|
255
|
-
|
431
|
+
src: Rclone style src path
|
432
|
+
dst: Rclone style dst path
|
433
|
+
files: List of file paths relative to src, or Path to a file containing the list
|
434
|
+
check: Whether to verify copies with checksums
|
435
|
+
max_backlog: Maximum number of queued transfers
|
436
|
+
verbose: Whether to show detailed progress
|
437
|
+
checkers: Number of checker threads
|
438
|
+
transfers: Number of file transfers to run in parallel
|
439
|
+
low_level_retries: Number of low-level retries
|
440
|
+
retries: Number of high-level retries
|
441
|
+
retries_sleep: Sleep interval between retries (e.g., "10s")
|
442
|
+
metadata: Whether to preserve metadata
|
443
|
+
timeout: IO idle timeout (e.g., "5m")
|
444
|
+
max_partition_workers: Maximum number of partition workers
|
445
|
+
multi_thread_streams: Number of streams for multi-thread copy
|
446
|
+
other_args: Additional command-line arguments
|
447
|
+
|
448
|
+
Returns:
|
449
|
+
List of CompletedProcess objects for each copy operation
|
256
450
|
"""
|
257
451
|
return self.impl.copy_files(
|
258
452
|
src=src,
|
@@ -285,11 +479,24 @@ class Rclone:
|
|
285
479
|
retries: int | None = None,
|
286
480
|
other_args: list[str] | None = None,
|
287
481
|
) -> CompletedProcess:
|
288
|
-
"""
|
482
|
+
"""
|
483
|
+
Copy files from source to destination.
|
484
|
+
|
485
|
+
Recursively copies all files from src to dst.
|
289
486
|
|
290
487
|
Args:
|
291
|
-
src:
|
292
|
-
dst:
|
488
|
+
src: Rclone style src path
|
489
|
+
dst: Rclone style dst path
|
490
|
+
check: Whether to verify copies with checksums
|
491
|
+
transfers: Number of file transfers to run in parallel
|
492
|
+
checkers: Number of checker threads
|
493
|
+
multi_thread_streams: Number of streams for multi-thread copy
|
494
|
+
low_level_retries: Number of low-level retries
|
495
|
+
retries: Number of high-level retries
|
496
|
+
other_args: Additional command-line arguments
|
497
|
+
|
498
|
+
Returns:
|
499
|
+
CompletedProcess with the result of the copy operation
|
293
500
|
"""
|
294
501
|
return self.impl.copy(
|
295
502
|
src=src,
|
@@ -304,7 +511,17 @@ class Rclone:
|
|
304
511
|
)
|
305
512
|
|
306
513
|
def purge(self, path: Dir | str) -> CompletedProcess:
|
307
|
-
"""
|
514
|
+
"""
|
515
|
+
Purge a directory.
|
516
|
+
|
517
|
+
Removes a directory and all its contents.
|
518
|
+
|
519
|
+
Args:
|
520
|
+
path: Rclone style path
|
521
|
+
|
522
|
+
Returns:
|
523
|
+
CompletedProcess with the result of the purge operation
|
524
|
+
"""
|
308
525
|
return self.impl.purge(path=path)
|
309
526
|
|
310
527
|
def delete_files(
|
@@ -316,7 +533,20 @@ class Rclone:
|
|
316
533
|
max_partition_workers: int | None = None,
|
317
534
|
other_args: list[str] | None = None,
|
318
535
|
) -> CompletedProcess:
|
319
|
-
"""
|
536
|
+
"""
|
537
|
+
Delete files or directories.
|
538
|
+
|
539
|
+
Args:
|
540
|
+
files: Files to delete (single file/path or list)
|
541
|
+
check: Whether to verify deletions
|
542
|
+
rmdirs: Whether to remove empty directories
|
543
|
+
verbose: Whether to show detailed progress
|
544
|
+
max_partition_workers: Maximum number of partition workers
|
545
|
+
other_args: Additional command-line arguments
|
546
|
+
|
547
|
+
Returns:
|
548
|
+
CompletedProcess with the result of the delete operation
|
549
|
+
"""
|
320
550
|
return self.impl.delete_files(
|
321
551
|
files=files,
|
322
552
|
check=check,
|
@@ -327,19 +557,54 @@ class Rclone:
|
|
327
557
|
)
|
328
558
|
|
329
559
|
def exists(self, path: Dir | Remote | str | File) -> bool:
|
330
|
-
"""
|
560
|
+
"""
|
561
|
+
Check if a file or directory exists.
|
562
|
+
|
563
|
+
Args:
|
564
|
+
path: Path to check (Dir, Remote, File, or path string)
|
565
|
+
|
566
|
+
Returns:
|
567
|
+
True if the path exists, False otherwise
|
568
|
+
"""
|
331
569
|
return self.impl.exists(path=path)
|
332
570
|
|
333
571
|
def is_synced(self, src: str | Dir, dst: str | Dir) -> bool:
|
334
|
-
"""
|
572
|
+
"""
|
573
|
+
Check if two directories are in sync.
|
574
|
+
|
575
|
+
Compares the contents of src and dst to determine if they match.
|
576
|
+
|
577
|
+
Args:
|
578
|
+
src: Source directory (Dir object or path string)
|
579
|
+
dst: Destination directory (Dir object or path string)
|
580
|
+
|
581
|
+
Returns:
|
582
|
+
True if the directories are in sync, False otherwise
|
583
|
+
"""
|
335
584
|
return self.impl.is_synced(src=src, dst=dst)
|
336
585
|
|
337
586
|
def modtime(self, src: str) -> str | Exception:
|
338
|
-
"""
|
587
|
+
"""
|
588
|
+
Get the modification time of a file or directory.
|
589
|
+
|
590
|
+
Args:
|
591
|
+
src: Path to the file or directory
|
592
|
+
|
593
|
+
Returns:
|
594
|
+
Modification time as a string, or Exception if an error occurred
|
595
|
+
"""
|
339
596
|
return self.impl.modtime(src=src)
|
340
597
|
|
341
598
|
def modtime_dt(self, src: str) -> datetime | Exception:
|
342
|
-
"""
|
599
|
+
"""
|
600
|
+
Get the modification time of a file or directory as a datetime object.
|
601
|
+
|
602
|
+
Args:
|
603
|
+
src: Path to the file or directory
|
604
|
+
|
605
|
+
Returns:
|
606
|
+
Modification time as a datetime object, or Exception if an error occurred
|
607
|
+
"""
|
343
608
|
return self.impl.modtime_dt(src=src)
|
344
609
|
|
345
610
|
def write_text(
|
@@ -347,7 +612,18 @@ class Rclone:
|
|
347
612
|
text: str,
|
348
613
|
dst: str,
|
349
614
|
) -> Exception | None:
|
350
|
-
"""
|
615
|
+
"""
|
616
|
+
Write text to a file.
|
617
|
+
|
618
|
+
Creates or overwrites the file at dst with the given text.
|
619
|
+
|
620
|
+
Args:
|
621
|
+
text: Text content to write
|
622
|
+
dst: Destination file path
|
623
|
+
|
624
|
+
Returns:
|
625
|
+
None if successful, Exception if an error occurred
|
626
|
+
"""
|
351
627
|
return self.impl.write_text(text=text, dst=dst)
|
352
628
|
|
353
629
|
def write_bytes(
|
@@ -355,15 +631,42 @@ class Rclone:
|
|
355
631
|
data: bytes,
|
356
632
|
dst: str,
|
357
633
|
) -> Exception | None:
|
358
|
-
"""
|
634
|
+
"""
|
635
|
+
Write bytes to a file.
|
636
|
+
|
637
|
+
Creates or overwrites the file at dst with the given binary data.
|
638
|
+
|
639
|
+
Args:
|
640
|
+
data: Binary content to write
|
641
|
+
dst: Destination file path
|
642
|
+
|
643
|
+
Returns:
|
644
|
+
None if successful, Exception if an error occurred
|
645
|
+
"""
|
359
646
|
return self.impl.write_bytes(data=data, dst=dst)
|
360
647
|
|
361
648
|
def read_bytes(self, src: str) -> bytes | Exception:
|
362
|
-
"""
|
649
|
+
"""
|
650
|
+
Read bytes from a file.
|
651
|
+
|
652
|
+
Args:
|
653
|
+
src: Source file path
|
654
|
+
|
655
|
+
Returns:
|
656
|
+
File contents as bytes, or Exception if an error occurred
|
657
|
+
"""
|
363
658
|
return self.impl.read_bytes(src=src)
|
364
659
|
|
365
660
|
def read_text(self, src: str) -> str | Exception:
|
366
|
-
"""
|
661
|
+
"""
|
662
|
+
Read text from a file.
|
663
|
+
|
664
|
+
Args:
|
665
|
+
src: Source file path
|
666
|
+
|
667
|
+
Returns:
|
668
|
+
File contents as a string, or Exception if an error occurred
|
669
|
+
"""
|
367
670
|
return self.impl.read_text(src=src)
|
368
671
|
|
369
672
|
def copy_bytes(
|
@@ -374,7 +677,21 @@ class Rclone:
|
|
374
677
|
outfile: Path,
|
375
678
|
other_args: list[str] | None = None,
|
376
679
|
) -> Exception | None:
|
377
|
-
"""
|
680
|
+
"""
|
681
|
+
Copy a slice of bytes from the src file to dst.
|
682
|
+
|
683
|
+
Extracts a portion of a file based on offset and length.
|
684
|
+
|
685
|
+
Args:
|
686
|
+
src: Source file path
|
687
|
+
offset: Starting position in the source file
|
688
|
+
length: Number of bytes to copy
|
689
|
+
outfile: Local file path to write the bytes to
|
690
|
+
other_args: Additional command-line arguments
|
691
|
+
|
692
|
+
Returns:
|
693
|
+
None if successful, Exception if an error occurred
|
694
|
+
"""
|
378
695
|
return self.impl.copy_bytes(
|
379
696
|
src=src,
|
380
697
|
offset=offset,
|
@@ -386,14 +703,38 @@ class Rclone:
|
|
386
703
|
def copy_dir(
|
387
704
|
self, src: str | Dir, dst: str | Dir, args: list[str] | None = None
|
388
705
|
) -> CompletedProcess:
|
389
|
-
"""
|
706
|
+
"""
|
707
|
+
Copy a directory from source to destination.
|
708
|
+
|
709
|
+
Recursively copies all files and subdirectories.
|
710
|
+
|
711
|
+
Args:
|
712
|
+
src: Source directory (Dir object or path string)
|
713
|
+
dst: Destination directory (Dir object or path string)
|
714
|
+
args: Additional command-line arguments
|
715
|
+
|
716
|
+
Returns:
|
717
|
+
CompletedProcess with the result of the copy operation
|
718
|
+
"""
|
390
719
|
# convert src to str, also dst
|
391
720
|
return self.impl.copy_dir(src=src, dst=dst, args=args)
|
392
721
|
|
393
722
|
def copy_remote(
|
394
723
|
self, src: Remote, dst: Remote, args: list[str] | None = None
|
395
724
|
) -> CompletedProcess:
|
396
|
-
"""
|
725
|
+
"""
|
726
|
+
Copy a remote to another remote.
|
727
|
+
|
728
|
+
Copies all contents from one remote storage to another.
|
729
|
+
|
730
|
+
Args:
|
731
|
+
src: Source remote
|
732
|
+
dst: Destination remote
|
733
|
+
args: Additional command-line arguments
|
734
|
+
|
735
|
+
Returns:
|
736
|
+
CompletedProcess with the result of the copy operation
|
737
|
+
"""
|
397
738
|
return self.impl.copy_remote(src=src, dst=dst, args=args)
|
398
739
|
|
399
740
|
def copy_file_s3_resumable(
|
@@ -404,7 +745,25 @@ class Rclone:
|
|
404
745
|
upload_threads: int = 8, # Number of reader and writer threads to use
|
405
746
|
merge_threads: int = 4, # Number of threads to use for merging the parts
|
406
747
|
) -> Exception | None:
|
407
|
-
"""
|
748
|
+
"""
|
749
|
+
Copy a large file to S3 with resumable upload capability.
|
750
|
+
|
751
|
+
This method splits the file into parts for parallel upload and can
|
752
|
+
resume interrupted transfers using a custom algorithm in python.
|
753
|
+
|
754
|
+
Particularly useful for very large files where network interruptions
|
755
|
+
are likely.
|
756
|
+
|
757
|
+
Args:
|
758
|
+
src: Source file path (format: remote:bucket/path/file)
|
759
|
+
dst: Destination file path (format: remote:bucket/path/file)
|
760
|
+
part_infos: Optional list of part information for resuming uploads
|
761
|
+
upload_threads: Number of parallel upload threads
|
762
|
+
merge_threads: Number of threads for merging uploaded parts
|
763
|
+
|
764
|
+
Returns:
|
765
|
+
None if successful, Exception if an error occurred
|
766
|
+
"""
|
408
767
|
return self.impl.copy_file_s3_resumable(
|
409
768
|
src=src,
|
410
769
|
dst=dst,
|
@@ -426,17 +785,25 @@ class Rclone:
|
|
426
785
|
log: Path | None = None,
|
427
786
|
other_args: list[str] | None = None,
|
428
787
|
) -> Mount:
|
429
|
-
"""
|
788
|
+
"""
|
789
|
+
Mount a remote or directory to a local path.
|
790
|
+
|
791
|
+
Makes remote storage accessible as a local filesystem.
|
430
792
|
|
431
793
|
Args:
|
432
794
|
src: Remote or directory to mount
|
433
795
|
outdir: Local path to mount to
|
796
|
+
allow_writes: Whether to allow write operations
|
797
|
+
use_links: Whether to use symbolic links
|
798
|
+
vfs_cache_mode: VFS cache mode (e.g., "full", "minimal")
|
799
|
+
verbose: Whether to show detailed output
|
800
|
+
cache_dir: Directory to use for caching
|
801
|
+
cache_dir_delete_on_exit: Whether to delete cache on exit
|
802
|
+
log: Path to write logs to
|
803
|
+
other_args: Additional command-line arguments
|
434
804
|
|
435
805
|
Returns:
|
436
|
-
|
437
|
-
|
438
|
-
Raises:
|
439
|
-
subprocess.CalledProcessError: If the mount operation fails
|
806
|
+
Mount object representing the mounted filesystem
|
440
807
|
"""
|
441
808
|
return self.impl.mount(
|
442
809
|
src=src,
|
@@ -457,12 +824,23 @@ class Rclone:
|
|
457
824
|
addr: str = "localhost:8080",
|
458
825
|
other_args: list[str] | None = None,
|
459
826
|
) -> HttpServer:
|
460
|
-
"""
|
461
|
-
|
827
|
+
"""
|
828
|
+
Serve a remote or directory via HTTP.
|
829
|
+
|
830
|
+
Creates an HTTP server that provides access to the specified remote.
|
831
|
+
The returned HttpServer object includes a client for fetching files.
|
832
|
+
|
833
|
+
This is useful for providing web access to remote storage or for
|
834
|
+
accessing remote files from applications that support HTTP but not
|
835
|
+
the remote's native protocol.
|
462
836
|
|
463
837
|
Args:
|
464
838
|
src: Remote or directory to serve
|
465
839
|
addr: Network address and port to serve on (default: localhost:8080)
|
840
|
+
other_args: Additional arguments to pass to rclone
|
841
|
+
|
842
|
+
Returns:
|
843
|
+
HttpServer object with methods for accessing the served content
|
466
844
|
"""
|
467
845
|
return self.impl.serve_http(src=src, addr=addr, other_args=other_args)
|
468
846
|
|
@@ -475,7 +853,25 @@ class Rclone:
|
|
475
853
|
check: bool | None = False,
|
476
854
|
verbose: bool | None = None,
|
477
855
|
) -> SizeResult | Exception:
|
478
|
-
"""
|
856
|
+
"""
|
857
|
+
Get the size of a list of files.
|
858
|
+
|
859
|
+
Calculates the total size of the specified files.
|
860
|
+
|
861
|
+
Args:
|
862
|
+
src: Base path for the files
|
863
|
+
files: List of file paths relative to src
|
864
|
+
fast_list: Whether to use fast listing (not recommended for accuracy)
|
865
|
+
other_args: Additional command-line arguments
|
866
|
+
check: Whether to verify file integrity
|
867
|
+
verbose: Whether to show detailed output
|
868
|
+
|
869
|
+
Returns:
|
870
|
+
SizeResult with size information, or Exception if an error occurred
|
871
|
+
|
872
|
+
Example:
|
873
|
+
size_files("remote:bucket", ["path/to/file1", "path/to/file2"])
|
874
|
+
"""
|
479
875
|
return self.impl.size_files(
|
480
876
|
src=src,
|
481
877
|
files=files,
|
@@ -486,38 +882,50 @@ class Rclone:
|
|
486
882
|
)
|
487
883
|
|
488
884
|
def size_file(self, src: str) -> SizeSuffix | Exception:
|
489
|
-
"""
|
885
|
+
"""
|
886
|
+
Get the size of a file.
|
887
|
+
|
888
|
+
Args:
|
889
|
+
src: Path to the file
|
890
|
+
|
891
|
+
Returns:
|
892
|
+
SizeSuffix object representing the file size, or Exception if an error occurred
|
893
|
+
"""
|
490
894
|
return self.impl.size_file(src=src)
|
491
895
|
|
492
896
|
|
897
|
+
# Export public API components
|
493
898
|
__all__ = [
|
494
|
-
|
495
|
-
"
|
496
|
-
"
|
497
|
-
"
|
498
|
-
"
|
499
|
-
"
|
500
|
-
"
|
501
|
-
"
|
502
|
-
"
|
503
|
-
"
|
504
|
-
"
|
505
|
-
"
|
506
|
-
"
|
507
|
-
|
508
|
-
"
|
509
|
-
|
510
|
-
"
|
511
|
-
"
|
512
|
-
"
|
513
|
-
"
|
514
|
-
"
|
515
|
-
"
|
516
|
-
"
|
517
|
-
"
|
518
|
-
"
|
519
|
-
|
520
|
-
"
|
521
|
-
"
|
522
|
-
"
|
899
|
+
# Main classes
|
900
|
+
"Rclone", # Primary interface
|
901
|
+
"File", # File representation
|
902
|
+
"Config", # Configuration handling
|
903
|
+
"Remote", # Remote storage
|
904
|
+
"Dir", # Directory representation
|
905
|
+
"RPath", # Remote path utilities
|
906
|
+
"DirListing", # Directory listing
|
907
|
+
"FileList", # File list
|
908
|
+
"FileItem", # File item
|
909
|
+
"Process", # Process management
|
910
|
+
"DiffItem", # Difference item
|
911
|
+
"DiffType", # Difference type
|
912
|
+
# Functions
|
913
|
+
"rclone_verbose", # Verbosity control
|
914
|
+
# Data classes and enums
|
915
|
+
"CompletedProcess", # Process result
|
916
|
+
"DiffOption", # Difference options
|
917
|
+
"ListingOption", # Listing options
|
918
|
+
"Order", # Sorting order
|
919
|
+
"SizeResult", # Size result
|
920
|
+
"Parsed", # Parsed configuration
|
921
|
+
"Section", # Configuration section
|
922
|
+
"MultiUploadResult", # S3 upload result
|
923
|
+
"SizeSuffix", # Size with suffix
|
924
|
+
# Utilities
|
925
|
+
"configure_logging", # Logging configuration
|
926
|
+
"log", # Logging utilities
|
927
|
+
"HttpServer", # HTTP server
|
928
|
+
"Range", # HTTP range
|
929
|
+
"HttpFetcher", # HTTP fetcher
|
930
|
+
"PartInfo", # Part information for uploads
|
523
931
|
]
|