deltachat-rpc-client 2.27.0__py3-none-any.whl → 2.29.0__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.
@@ -130,6 +130,10 @@ class Account:
130
130
  """Add a new transport using a QR code."""
131
131
  yield self._rpc.add_transport_from_qr.future(self.id, qr)
132
132
 
133
+ def delete_transport(self, addr: str):
134
+ """Delete a transport."""
135
+ self._rpc.delete_transport(self.id, addr)
136
+
133
137
  @futuremethod
134
138
  def list_transports(self):
135
139
  """Return the list of all email accounts that are used as a transport in the current profile."""
@@ -60,6 +60,10 @@ class Message:
60
60
  """Mark the message as seen."""
61
61
  self._rpc.markseen_msgs(self.account.id, [self.id])
62
62
 
63
+ def exists(self) -> bool:
64
+ """Return True if the message exists."""
65
+ return bool(self._rpc.get_existing_msg_ids(self.account.id, [self.id]))
66
+
63
67
  def continue_autocrypt_key_transfer(self, setup_code: str) -> None:
64
68
  """Continue the Autocrypt Setup Message key transfer.
65
69
 
@@ -40,12 +40,17 @@ class ACFactory:
40
40
  username = "ci-" + "".join(random.choice("2345789acdefghjkmnpqrstuvwxyz") for i in range(6))
41
41
  return f"{username}@{domain}", f"{username}${username}"
42
42
 
43
+ def get_account_qr(self):
44
+ """Return "dcaccount:" QR code for testing chatmail relay."""
45
+ domain = os.getenv("CHATMAIL_DOMAIN")
46
+ return f"dcaccount:{domain}"
47
+
43
48
  @futuremethod
44
49
  def new_configured_account(self):
45
50
  """Create a new configured account."""
46
51
  account = self.get_unconfigured_account()
47
- domain = os.getenv("CHATMAIL_DOMAIN")
48
- yield account.add_transport_from_qr.future(f"dcaccount:{domain}")
52
+ qr = self.get_account_qr()
53
+ yield account.add_transport_from_qr.future(qr)
49
54
 
50
55
  assert account.is_configured()
51
56
  return account
@@ -77,6 +82,7 @@ class ACFactory:
77
82
  ac_clone = self.get_unconfigured_account()
78
83
  for transport in transports:
79
84
  ac_clone.add_or_update_transport(transport)
85
+ ac_clone.bring_online()
80
86
  return ac_clone
81
87
 
82
88
  def get_accepted_chat(self, ac1: Account, ac2: Account) -> Chat:
@@ -9,7 +9,7 @@ import os
9
9
  import subprocess
10
10
  import sys
11
11
  from queue import Empty, Queue
12
- from threading import Event, Thread
12
+ from threading import Thread
13
13
  from typing import Any, Iterator, Optional
14
14
 
15
15
 
@@ -17,25 +17,6 @@ class JsonRpcError(Exception):
17
17
  """JSON-RPC error."""
18
18
 
19
19
 
20
- class RpcFuture:
21
- """RPC future waiting for RPC call result."""
22
-
23
- def __init__(self, rpc: "Rpc", request_id: int, event: Event):
24
- self.rpc = rpc
25
- self.request_id = request_id
26
- self.event = event
27
-
28
- def __call__(self):
29
- """Wait for the future to return the result."""
30
- self.event.wait()
31
- response = self.rpc.request_results.pop(self.request_id)
32
- if "error" in response:
33
- raise JsonRpcError(response["error"])
34
- if "result" in response:
35
- return response["result"]
36
- return None
37
-
38
-
39
20
  class RpcMethod:
40
21
  """RPC method."""
41
22
 
@@ -57,17 +38,23 @@ class RpcMethod:
57
38
  "params": args,
58
39
  "id": request_id,
59
40
  }
60
- event = Event()
61
- self.rpc.request_events[request_id] = event
41
+ self.rpc.request_results[request_id] = queue = Queue()
62
42
  self.rpc.request_queue.put(request)
63
43
 
64
- return RpcFuture(self.rpc, request_id, event)
44
+ def rpc_future():
45
+ """Wait for the request to receive a result."""
46
+ response = queue.get()
47
+ if "error" in response:
48
+ raise JsonRpcError(response["error"])
49
+ return response.get("result", None)
50
+
51
+ return rpc_future
65
52
 
66
53
 
67
54
  class Rpc:
68
55
  """RPC client."""
69
56
 
70
- def __init__(self, accounts_dir: Optional[str] = None, **kwargs):
57
+ def __init__(self, accounts_dir: Optional[str] = None, rpc_server_path="deltachat-rpc-server", **kwargs):
71
58
  """Initialize RPC client.
72
59
 
73
60
  The given arguments will be passed to subprocess.Popen().
@@ -79,13 +66,12 @@ class Rpc:
79
66
  }
80
67
 
81
68
  self._kwargs = kwargs
69
+ self.rpc_server_path = rpc_server_path
82
70
  self.process: subprocess.Popen
83
71
  self.id_iterator: Iterator[int]
84
72
  self.event_queues: dict[int, Queue]
85
- # Map from request ID to `threading.Event`.
86
- self.request_events: dict[int, Event]
87
- # Map from request ID to the result.
88
- self.request_results: dict[int, Any]
73
+ # Map from request ID to a Queue which provides a single result
74
+ self.request_results: dict[int, Queue]
89
75
  self.request_queue: Queue[Any]
90
76
  self.closing: bool
91
77
  self.reader_thread: Thread
@@ -94,27 +80,18 @@ class Rpc:
94
80
 
95
81
  def start(self) -> None:
96
82
  """Start RPC server subprocess."""
83
+ popen_kwargs = {"stdin": subprocess.PIPE, "stdout": subprocess.PIPE}
97
84
  if sys.version_info >= (3, 11):
98
- self.process = subprocess.Popen(
99
- "deltachat-rpc-server",
100
- stdin=subprocess.PIPE,
101
- stdout=subprocess.PIPE,
102
- # Prevent subprocess from capturing SIGINT.
103
- process_group=0,
104
- **self._kwargs,
105
- )
85
+ # Prevent subprocess from capturing SIGINT.
86
+ popen_kwargs["process_group"] = 0
106
87
  else:
107
- self.process = subprocess.Popen(
108
- "deltachat-rpc-server",
109
- stdin=subprocess.PIPE,
110
- stdout=subprocess.PIPE,
111
- # `process_group` is not supported before Python 3.11.
112
- preexec_fn=os.setpgrp, # noqa: PLW1509
113
- **self._kwargs,
114
- )
88
+ # `process_group` is not supported before Python 3.11.
89
+ popen_kwargs["preexec_fn"] = os.setpgrp # noqa: PLW1509
90
+
91
+ popen_kwargs.update(self._kwargs)
92
+ self.process = subprocess.Popen(self.rpc_server_path, **popen_kwargs)
115
93
  self.id_iterator = itertools.count(start=1)
116
94
  self.event_queues = {}
117
- self.request_events = {}
118
95
  self.request_results = {}
119
96
  self.request_queue = Queue()
120
97
  self.closing = False
@@ -149,9 +126,7 @@ class Rpc:
149
126
  response = json.loads(line)
150
127
  if "id" in response:
151
128
  response_id = response["id"]
152
- event = self.request_events.pop(response_id)
153
- self.request_results[response_id] = response
154
- event.set()
129
+ self.request_results.pop(response_id).put(response)
155
130
  else:
156
131
  logging.warning("Got a response without ID: %s", response)
157
132
  except Exception:
@@ -1,15 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deltachat-rpc-client
3
- Version: 2.27.0
3
+ Version: 2.29.0
4
4
  Summary: Python client for Delta Chat core JSON-RPC interface
5
+ License-Expression: MPL-2.0
5
6
  Classifier: Development Status :: 5 - Production/Stable
6
7
  Classifier: Intended Audience :: Developers
7
- Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
8
8
  Classifier: Operating System :: POSIX :: Linux
9
9
  Classifier: Operating System :: MacOS :: MacOS X
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.8
12
- Classifier: Programming Language :: Python :: 3.9
13
11
  Classifier: Programming Language :: Python :: 3.10
14
12
  Classifier: Programming Language :: Python :: 3.11
15
13
  Classifier: Programming Language :: Python :: 3.12
@@ -17,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.13
17
15
  Classifier: Programming Language :: Python :: 3.14
18
16
  Classifier: Topic :: Communications :: Chat
19
17
  Classifier: Topic :: Communications :: Email
20
- Requires-Python: >=3.8
18
+ Requires-Python: >=3.10
21
19
  Description-Content-Type: text/markdown
22
20
  License-File: LICENSE
23
21
  Dynamic: license-file
@@ -1,19 +1,19 @@
1
1
  deltachat_rpc_client/__init__.py,sha256=zroJARiq9HBi7Ln03KlICOUJHSjm3CGIFkHfXILEdOQ,567
2
2
  deltachat_rpc_client/_utils.py,sha256=v0iWVSa6S-s078GgnnhflCRhA9pfWI-CfK8mjZ4zjXc,6393
3
- deltachat_rpc_client/account.py,sha256=itF7QYR9m26ImyuOVbUtCj7AMkHu6_PMyiKTto_Z4K0,19421
3
+ deltachat_rpc_client/account.py,sha256=CNUwmWNdWlaEXuDHy0Xld7EFnNaBrMk_BORkVeNIql4,19549
4
4
  deltachat_rpc_client/chat.py,sha256=x5CEIORL1-731QC4KcXd_0JKtRpe7nT9oAygmKkooHI,11707
5
5
  deltachat_rpc_client/client.py,sha256=6eP_lH5z7G5Sy7vDRNfKNY3dkUqJqKZDVyCGjynsuW8,7181
6
6
  deltachat_rpc_client/const.py,sha256=p6hSXNYLBpPLpMz0UkT8QnMrqmA_cZ3sw-o8S3ryVM4,6675
7
7
  deltachat_rpc_client/contact.py,sha256=NLh1XNnD_LQf27pNcVgqNN97Gbv190VSCuEyjjce4L4,1893
8
8
  deltachat_rpc_client/deltachat.py,sha256=-6SqQAS8_mMWLBP3U1HvFsNIpcAPYBlmqF8R6Bt90YQ,1894
9
9
  deltachat_rpc_client/events.py,sha256=Y45LoGlQy0i1U-LhoqF9njqJWA8v4b-XHfXZ4VOr1TQ,10205
10
- deltachat_rpc_client/message.py,sha256=PWSm5e-woWgYXPcnwygQO0fNSRV-NvKvuerqWkJxiik,4996
10
+ deltachat_rpc_client/message.py,sha256=xA3rLUOPkakqr7kW3JORVYLKHQxvggBqgrXPnDK1a0s,5156
11
11
  deltachat_rpc_client/py.typed,sha256=nGQ9Itq-bkXBn5Ri1JIR0oYnDNv7LDRfkowxBSSqVTM,60
12
- deltachat_rpc_client/pytestplugin.py,sha256=gM5b9UL6d7ktRbu-1pyaRkg22m0qHT_wrP1ypHsgk2U,5713
13
- deltachat_rpc_client/rpc.py,sha256=AUY8UJP7NlRSE5ewJs9jGxJdK8etKqsCEFWiIqnX5T8,6981
14
- deltachat_rpc_client-2.27.0.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
- deltachat_rpc_client-2.27.0.dist-info/METADATA,sha256=rz3CihD8i9mg6tUEJbVs7DXD-nB_oKRSzndPI0qLZQY,2225
16
- deltachat_rpc_client-2.27.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- deltachat_rpc_client-2.27.0.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
- deltachat_rpc_client-2.27.0.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
- deltachat_rpc_client-2.27.0.dist-info/RECORD,,
12
+ deltachat_rpc_client/pytestplugin.py,sha256=aoueJt7pXJUQsSBRRyVHLU-geSC9LUOJ7qlvJbWTB4A,5899
13
+ deltachat_rpc_client/rpc.py,sha256=q8EaEc7tjvikIS7dYWnmJdGTH61ulDJjNSbfKASQ2UQ,6315
14
+ deltachat_rpc_client-2.29.0.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
+ deltachat_rpc_client-2.29.0.dist-info/METADATA,sha256=OaVhbZ5Tj3lcxGFIBUlz-KDbFO3JEi1-k-Rwi29FOxk,2078
16
+ deltachat_rpc_client-2.29.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ deltachat_rpc_client-2.29.0.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
+ deltachat_rpc_client-2.29.0.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
+ deltachat_rpc_client-2.29.0.dist-info/RECORD,,