rclone-api 1.5.51__py3-none-any.whl → 1.5.52__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/rclone_impl.py CHANGED
@@ -2,6 +2,7 @@
2
2
  Unit test file.
3
3
  """
4
4
 
5
+ import logging
5
6
  import os
6
7
  import random
7
8
  import subprocess
@@ -57,6 +58,8 @@ from rclone_api.util import (
57
58
  # Enable tracing memory usage always
58
59
  tracemalloc.start()
59
60
 
61
+ logger = logging.getLogger(__name__)
62
+
60
63
 
61
64
  def rclone_verbose(verbose: bool | None) -> bool:
62
65
  if verbose is not None:
@@ -867,9 +870,10 @@ class RcloneImpl:
867
870
  parsed: Parsed = self.config.parse()
868
871
  sections: dict[str, Section] = parsed.sections
869
872
  if remote not in sections:
870
- raise ValueError(f"Remote {remote} not found in rclone config")
873
+ return False
871
874
  section: Section = sections[remote]
872
- return section.type() == "s3"
875
+ t = section.type()
876
+ return t in ["s3", "b2"]
873
877
 
874
878
  def copy_file_s3_resumable(
875
879
  self,
@@ -915,19 +919,23 @@ class RcloneImpl:
915
919
  ) -> Exception | None:
916
920
  """Write bytes to a file."""
917
921
 
918
- if isinstance(data, Path):
919
- data = data.read_bytes()
920
-
921
- with TemporaryDirectory() as tmpdir:
922
- tmpfile = Path(tmpdir) / "file.bin"
923
- tmpfile.write_bytes(data)
924
- dst_is_s3 = self.is_s3(dst)
925
- if dst_is_s3:
926
- return self.copy_file_s3(tmpfile, dst, verbose=verbose)
927
-
928
- completed_proc = self.copy_to(str(tmpfile), dst, check=True)
929
- if completed_proc.returncode != 0:
930
- return Exception(f"Failed to write bytes to {dst}", completed_proc)
922
+ try:
923
+ if isinstance(data, Path):
924
+ data = data.read_bytes()
925
+
926
+ with TemporaryDirectory() as tmpdir:
927
+ tmpfile = Path(tmpdir) / "file.bin"
928
+ tmpfile.write_bytes(data)
929
+ dst_is_s3 = self.is_s3(dst)
930
+ if dst_is_s3:
931
+ return self.copy_file_s3(tmpfile, dst, verbose=verbose)
932
+
933
+ completed_proc = self.copy_to(str(tmpfile), dst, check=True)
934
+ if completed_proc.returncode != 0:
935
+ return Exception(f"Failed to write bytes to {dst}", completed_proc)
936
+ except Exception as e:
937
+ logging.error(f"Failed to write bytes to {dst}")
938
+ return e
931
939
  return None
932
940
 
933
941
  def read_bytes(self, src: str) -> bytes | Exception:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rclone_api
3
- Version: 1.5.51
3
+ Version: 1.5.52
4
4
  Summary: rclone api in python
5
5
  Home-page: https://github.com/zackees/rclone-api
6
6
  License: BSD 3-Clause License
@@ -20,7 +20,7 @@ rclone_api/log.py,sha256=VZHM7pNSXip2ZLBKMP7M1u-rp_F7zoafFDuR8CPUoKI,1271
20
20
  rclone_api/mount.py,sha256=LZqEhuKZunbWVqmsOIqkkCotaxWJpdFRS1InXveoU5E,1428
21
21
  rclone_api/mount_util.py,sha256=jqhJEVTHV6c6lOOzUYb4FLMbqDMHdz7-QRcdH-IobFc,10154
22
22
  rclone_api/process.py,sha256=MeWiN-TrrN0HmtWexBPxGwf84z6f-_E5yaXE-YtLYpY,5879
23
- rclone_api/rclone_impl.py,sha256=AXj74tSOsR3bnVtAYNcHOIHH74krRXvPggWaMdnEwm4,52126
23
+ rclone_api/rclone_impl.py,sha256=s00SHQGcKskbauWiIZQBQKSR0NOJ6SSiXhMf0fwkl9U,52328
24
24
  rclone_api/remote.py,sha256=mTgMTQTwxUmbLjTpr-AGTId2ycXKI9mLX5L7PPpDIoc,520
25
25
  rclone_api/rpath.py,sha256=Y1JjQWcie39EgQrq-UtbfDz5yDLCwwfu27W7AQXllSE,2860
26
26
  rclone_api/scan_missing_folders.py,sha256=-8NCwpCaHeHrX-IepCoAEsX1rl8S-GOCxcIhTr_w3gA,4747
@@ -55,9 +55,9 @@ rclone_api/s3/multipart/upload_parts_inline.py,sha256=V7syKjFyVIe4U9Ahl5XgqVTzt9
55
55
  rclone_api/s3/multipart/upload_parts_resumable.py,sha256=6-nlMclS8jyVvMvFbQDcZOX9MY1WbCcKA_s9bwuYxnk,9793
56
56
  rclone_api/s3/multipart/upload_parts_server_side_merge.py,sha256=Fp2pdrs5dONQI9LkfNolgAGj1-Z2V1SsRd0r0sreuXI,18040
57
57
  rclone_api/s3/multipart/upload_state.py,sha256=f-Aq2NqtAaMUMhYitlICSNIxCKurWAl2gDEUVizLIqw,6019
58
- rclone_api-1.5.51.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
59
- rclone_api-1.5.51.dist-info/METADATA,sha256=EWCOVITezwvrFLaLlSQGsCGLBTRdBuRKtz2h4u8tZW8,37305
60
- rclone_api-1.5.51.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
61
- rclone_api-1.5.51.dist-info/entry_points.txt,sha256=ognh2e11HTjn73_KL5MWI67pBKS2jekBi-QTiRXySXA,316
62
- rclone_api-1.5.51.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
63
- rclone_api-1.5.51.dist-info/RECORD,,
58
+ rclone_api-1.5.52.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
59
+ rclone_api-1.5.52.dist-info/METADATA,sha256=pzUkl7zLuD22M8z-gOpbEkACDpT0tZ6r62N3hJ-LwMc,37305
60
+ rclone_api-1.5.52.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
61
+ rclone_api-1.5.52.dist-info/entry_points.txt,sha256=ognh2e11HTjn73_KL5MWI67pBKS2jekBi-QTiRXySXA,316
62
+ rclone_api-1.5.52.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
63
+ rclone_api-1.5.52.dist-info/RECORD,,