rclone-api 1.4.4__py2.py3-none-any.whl → 1.4.6__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.
@@ -9,6 +9,7 @@ from dataclasses import dataclass
9
9
  from datetime import datetime
10
10
  from pathlib import Path
11
11
 
12
+ from rclone_api import rclone_verbose
12
13
  from rclone_api.dir_listing import DirListing
13
14
  from rclone_api.http_server import HttpServer
14
15
  from rclone_api.rclone_impl import RcloneImpl
@@ -18,6 +19,8 @@ from rclone_api.types import (
18
19
  SizeSuffix,
19
20
  )
20
21
 
22
+ rclone_verbose(True)
23
+
21
24
 
22
25
  @dataclass
23
26
  class UploadPart:
@@ -46,6 +49,11 @@ def upload_task(self: RcloneImpl, upload_part: UploadPart) -> UploadPart:
46
49
  try:
47
50
  if upload_part.exception is not None:
48
51
  return upload_part
52
+ # print(f"Uploading {upload_part.chunk} to {upload_part.dst_part}")
53
+ msg = "\n#########################################\n"
54
+ msg += f"# Uploading {upload_part.chunk} to {upload_part.dst_part}\n"
55
+ msg += "#########################################\n"
56
+ print
49
57
  self.copy_to(upload_part.chunk.as_posix(), upload_part.dst_part)
50
58
  return upload_part
51
59
  except Exception as e:
@@ -285,6 +293,10 @@ def copy_file_parts(
285
293
  all_numbers_already_done: set[int] = set(
286
294
  info_json.fetch_all_finished_part_numbers()
287
295
  )
296
+
297
+ first_part_number = part_infos[0].part_number
298
+ last_part_number = part_infos[-1].part_number
299
+
288
300
  print(f"all_numbers_already_done: {sorted(list(all_numbers_already_done))}")
289
301
 
290
302
  filtered_part_infos: list[PartInfo] = []
@@ -301,8 +313,9 @@ def copy_file_parts(
301
313
  chunk_size = SizeSuffix(part_infos[0].range.end - part_infos[0].range.start)
302
314
 
303
315
  info_json.chunksize = chunk_size
304
- info_json.first_part = part_infos[0].part_number
305
- info_json.last_part = part_infos[-1].part_number
316
+
317
+ info_json.first_part = first_part_number
318
+ info_json.last_part = last_part_number
306
319
  info_json.save()
307
320
 
308
321
  # We are now validated
rclone_api/http_server.py CHANGED
@@ -3,6 +3,7 @@ Unit test file for testing rclone mount functionality.
3
3
  """
4
4
 
5
5
  import tempfile
6
+ import time
6
7
  import warnings
7
8
  from concurrent.futures import Future, ThreadPoolExecutor
8
9
  from pathlib import Path
@@ -63,33 +64,46 @@ class HttpServer:
63
64
  self, path: str, dst: Path, range: Range | None = None
64
65
  ) -> Path | Exception:
65
66
  """Get bytes from the server."""
66
- if not dst.parent.exists():
67
- dst.parent.mkdir(parents=True, exist_ok=True)
68
- headers: dict[str, str] = {}
69
- if range:
70
- headers.update(range.to_header())
71
- url = self._get_file_url(path)
72
- try:
73
- with httpx.stream(
74
- "GET", url, headers=headers, timeout=_TIMEOUT
75
- ) as response:
76
- response.raise_for_status()
77
- with open(dst, "wb") as file:
78
- for chunk in response.iter_bytes(chunk_size=8192):
79
- if chunk:
80
- file.write(chunk)
81
- else:
82
- assert response.is_closed
83
- # print(f"Downloaded bytes {start}-{end} to {dst}")
84
- if range:
85
- print(f"Downloaded bytes {range.start}-{range.end} to {dst}")
86
- else:
87
- size = dst.stat().st_size
88
- print(f"Downloaded {size} bytes to {dst}")
89
- return dst
90
- except Exception as e:
91
- warnings.warn(f"Failed to download {url} to {dst}: {e}")
92
- return e
67
+
68
+ def task() -> Path | Exception:
69
+
70
+ if not dst.parent.exists():
71
+ dst.parent.mkdir(parents=True, exist_ok=True)
72
+ headers: dict[str, str] = {}
73
+ if range:
74
+ headers.update(range.to_header())
75
+ url = self._get_file_url(path)
76
+ try:
77
+ with httpx.stream(
78
+ "GET", url, headers=headers, timeout=_TIMEOUT
79
+ ) as response:
80
+ response.raise_for_status()
81
+ with open(dst, "wb") as file:
82
+ for chunk in response.iter_bytes(chunk_size=8192):
83
+ if chunk:
84
+ file.write(chunk)
85
+ else:
86
+ assert response.is_closed
87
+ # print(f"Downloaded bytes {start}-{end} to {dst}")
88
+ if range:
89
+ print(f"Downloaded bytes {range.start}-{range.end} to {dst}")
90
+ else:
91
+ size = dst.stat().st_size
92
+ print(f"Downloaded {size} bytes to {dst}")
93
+ return dst
94
+ except Exception as e:
95
+ warnings.warn(f"Failed to download {url} to {dst}: {e}")
96
+ return e
97
+
98
+ retries = 3
99
+ for i in _range(retries):
100
+ out = task()
101
+ if not isinstance(out, Exception):
102
+ return out
103
+ warnings.warn(f"Failed to download {path} to {dst}: {out}, retrying ({i})")
104
+ time.sleep(10)
105
+ else:
106
+ return Exception(f"Failed to download {path} to {dst}")
93
107
 
94
108
  def download_multi_threaded(
95
109
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rclone_api
3
- Version: 1.4.4
3
+ Version: 1.4.6
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -14,7 +14,7 @@ rclone_api/file_part.py,sha256=i6ByS5_sae8Eba-4imBVTxd-xKC8ExWy7NR8QGr0ors,6155
14
14
  rclone_api/file_stream.py,sha256=_W3qnwCuigqA0hzXl2q5pAxSZDRaUSwet4BkT0lpnzs,1431
15
15
  rclone_api/filelist.py,sha256=xbiusvNgaB_b_kQOZoHMJJxn6TWGtPrWd2J042BI28o,767
16
16
  rclone_api/group_files.py,sha256=H92xPW9lQnbNw5KbtZCl00bD6iRh9yRbCuxku4j_3dg,8036
17
- rclone_api/http_server.py,sha256=YrILbxK0Xpnpkm8l9uGEXH_AOCGPUX8Cx33jKVtu7ZM,8207
17
+ rclone_api/http_server.py,sha256=3fPBV6l50erTe32DyeJBNmsDrn5KuujsbmEAbx13T-c,8720
18
18
  rclone_api/log.py,sha256=VZHM7pNSXip2ZLBKMP7M1u-rp_F7zoafFDuR8CPUoKI,1271
19
19
  rclone_api/mount.py,sha256=TE_VIBMW7J1UkF_6HRCt8oi_jGdMov4S51bm2OgxFAM,10045
20
20
  rclone_api/process.py,sha256=BGXJTZVT__jeaDyjN8_kRycliOhkBErMPdHO1hKRvJE,5271
@@ -32,7 +32,7 @@ rclone_api/cmd/save_to_db.py,sha256=ylvnhg_yzexM-m6Zr7XDiswvoDVSl56ELuFAdb9gqBY,
32
32
  rclone_api/db/__init__.py,sha256=OSRUdnSWUlDTOHmjdjVmxYTUNpTbtaJ5Ll9sl-PfZg0,40
33
33
  rclone_api/db/db.py,sha256=YRnYrCaXHwytQt07uEZ_mMpvPHo9-0IWcOb95fVOOfs,10086
34
34
  rclone_api/db/models.py,sha256=v7qaXUehvsDvU51uk69JI23fSIs9JFGcOa-Tv1c_wVs,1600
35
- rclone_api/detail/copy_file_parts.py,sha256=2XA2jLCdxkenqEVCFOo3yNrYEkziNTU_Mlsp0Ra-vkg,12291
35
+ rclone_api/detail/copy_file_parts.py,sha256=wO0IZoZS8360dR3S3TyuPTPJOyqd-z0QpSz88-9tjio,12727
36
36
  rclone_api/detail/walk.py,sha256=-54NVE8EJcCstwDoaC_UtHm73R2HrZwVwQmsnv55xNU,3369
37
37
  rclone_api/experimental/flags.py,sha256=qCVD--fSTmzlk9hloRLr0q9elzAOFzPsvVpKM3aB1Mk,2739
38
38
  rclone_api/experimental/flags_base.py,sha256=ajU_czkTcAxXYU-SlmiCfHY7aCQGHvpCLqJ-Z8uZLk0,2102
@@ -47,9 +47,9 @@ rclone_api/s3/multipart/file_info.py,sha256=8v_07_eADo0K-Nsv7F0Ac1wcv3lkIsrR3MaR
47
47
  rclone_api/s3/multipart/finished_piece.py,sha256=TcwA58-qgKBiskfHrePoCWaSSep6Za9psZEpzrLUUhE,1199
48
48
  rclone_api/s3/multipart/upload_info.py,sha256=d6_OfzFR_vtDzCEegFfzCfWi2kUBUV4aXZzqAEVp1c4,1874
49
49
  rclone_api/s3/multipart/upload_state.py,sha256=f-Aq2NqtAaMUMhYitlICSNIxCKurWAl2gDEUVizLIqw,6019
50
- rclone_api-1.4.4.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
51
- rclone_api-1.4.4.dist-info/METADATA,sha256=qUjt3zZ0FKik4AqUkdvWOGhIrShXrgFOwEsfROcVRSE,4627
52
- rclone_api-1.4.4.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
53
- rclone_api-1.4.4.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
54
- rclone_api-1.4.4.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
55
- rclone_api-1.4.4.dist-info/RECORD,,
50
+ rclone_api-1.4.6.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
51
+ rclone_api-1.4.6.dist-info/METADATA,sha256=Wq4cALgVpPO9GCGDE6YkFfZiFwbZWglP5-uwqNWuwjQ,4627
52
+ rclone_api-1.4.6.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
53
+ rclone_api-1.4.6.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
54
+ rclone_api-1.4.6.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
55
+ rclone_api-1.4.6.dist-info/RECORD,,