rclone-bin-api 1.0.2__tar.gz → 1.0.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rclone-bin-api
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Rclone API for Python including the Rclone binaries.
5
5
  Author-email: Michael G <me@mgineer85.de>
6
6
  Maintainer-email: Michael G <me@mgineer85.de>
@@ -2,7 +2,7 @@
2
2
  [project]
3
3
  name = "rclone-bin-api"
4
4
  description = "Rclone API for Python including the Rclone binaries."
5
- version = "1.0.2"
5
+ version = "1.0.4"
6
6
  authors = [{ name = "Michael G", email = "me@mgineer85.de" }]
7
7
  maintainers = [{ name = "Michael G", email = "me@mgineer85.de" }]
8
8
  requires-python = ">=3.11"
@@ -11,7 +11,7 @@ from setuptools import setup
11
11
  from setuptools.command.build_py import build_py
12
12
  from wheel.bdist_wheel import bdist_wheel
13
13
 
14
- rclone_version = os.environ.get("RCLONE_VERSION", "1.72.1")
14
+ rclone_version = os.environ.get("RCLONE_VERSION", "1.73.0")
15
15
  rclone_build_platform = os.environ.get("RCLONE_BUILD_PLATFORM", None)
16
16
 
17
17
  PLATFORMS = {
@@ -24,6 +24,7 @@ class RcloneApi:
24
24
  checkers: int = 4,
25
25
  enable_webui: bool = False,
26
26
  bwlimit: str | None = None,
27
+ config_file: Path | None = None,
27
28
  ):
28
29
  self.__bind_addr = bind
29
30
  self.__log_file = log_file
@@ -32,6 +33,8 @@ class RcloneApi:
32
33
  self.__checkers = checkers
33
34
  self.__enable_webui = enable_webui
34
35
  self.__bwlimit = bwlimit
36
+ self.__config_file = config_file
37
+
35
38
  self.__connect_addr = f"http://{bind}"
36
39
  self.__process = None
37
40
  self.__rclone_bin = BINARY_PATH
@@ -52,6 +55,7 @@ class RcloneApi:
52
55
  [
53
56
  str(self.__rclone_bin),
54
57
  "rcd",
58
+ *([f"--config={self.__config_file}"] if self.__config_file else []),
55
59
  f"--rc-addr={self.__bind_addr}",
56
60
  "--rc-no-auth", # TODO: add auth.
57
61
  *(["--rc-web-gui"] if self.__enable_webui else []),
@@ -121,6 +125,8 @@ class RcloneApi:
121
125
  assert not (not fs.endswith(":") and not Path(fs).is_absolute()), f"fs must be absolute when remote is a local path: {fs=} {remote=}"
122
126
 
123
127
  def _post(self, endpoint: str, data: dict[str, Any] | None = None):
128
+ TIMEOUT = 90
129
+
124
130
  req = urllib.request.Request(
125
131
  url=f"{self.__connect_addr}/{endpoint}",
126
132
  data=json.dumps(data or {}).encode("utf-8"),
@@ -129,7 +135,7 @@ class RcloneApi:
129
135
  )
130
136
 
131
137
  try:
132
- with urllib.request.urlopen(req, timeout=20) as resp:
138
+ with urllib.request.urlopen(req, timeout=TIMEOUT) as resp:
133
139
  raw: bytes = resp.read()
134
140
  response_json = json.loads(raw.decode("utf-8"))
135
141
 
@@ -137,6 +143,8 @@ class RcloneApi:
137
143
  raw: bytes = exc.read()
138
144
  response_json = json.loads(raw.decode("utf-8"))
139
145
  raise RcloneProcessException.from_dict(response_json) from exc
146
+ except TimeoutError as exc:
147
+ raise RcloneConnectionException(f"Operation timed out after {TIMEOUT}s. To copy large files consider using _async methods.") from exc
140
148
  except Exception as exc: # all other errors
141
149
  raise RcloneConnectionException(f"Issue connecting to rclone RC server, error: {exc}") from exc
142
150
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rclone-bin-api
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Rclone API for Python including the Rclone binaries.
5
5
  Author-email: Michael G <me@mgineer85.de>
6
6
  Maintainer-email: Michael G <me@mgineer85.de>
File without changes
File without changes