deltachat-rpc-client 2.28.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.
- deltachat_rpc_client/message.py +4 -0
- deltachat_rpc_client/rpc.py +23 -48
- {deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/METADATA +3 -5
- {deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/RECORD +8 -8
- {deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/WHEEL +0 -0
- {deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/entry_points.txt +0 -0
- {deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/licenses/LICENSE +0 -0
- {deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/top_level.txt +0 -0
deltachat_rpc_client/message.py
CHANGED
|
@@ -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
|
|
deltachat_rpc_client/rpc.py
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
86
|
-
self.
|
|
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
|
-
|
|
99
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
18
|
+
Requires-Python: >=3.10
|
|
21
19
|
Description-Content-Type: text/markdown
|
|
22
20
|
License-File: LICENSE
|
|
23
21
|
Dynamic: license-file
|
|
@@ -7,13 +7,13 @@ deltachat_rpc_client/const.py,sha256=p6hSXNYLBpPLpMz0UkT8QnMrqmA_cZ3sw-o8S3ryVM4
|
|
|
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=
|
|
10
|
+
deltachat_rpc_client/message.py,sha256=xA3rLUOPkakqr7kW3JORVYLKHQxvggBqgrXPnDK1a0s,5156
|
|
11
11
|
deltachat_rpc_client/py.typed,sha256=nGQ9Itq-bkXBn5Ri1JIR0oYnDNv7LDRfkowxBSSqVTM,60
|
|
12
12
|
deltachat_rpc_client/pytestplugin.py,sha256=aoueJt7pXJUQsSBRRyVHLU-geSC9LUOJ7qlvJbWTB4A,5899
|
|
13
|
-
deltachat_rpc_client/rpc.py,sha256=
|
|
14
|
-
deltachat_rpc_client-2.
|
|
15
|
-
deltachat_rpc_client-2.
|
|
16
|
-
deltachat_rpc_client-2.
|
|
17
|
-
deltachat_rpc_client-2.
|
|
18
|
-
deltachat_rpc_client-2.
|
|
19
|
-
deltachat_rpc_client-2.
|
|
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,,
|
|
File without changes
|
{deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{deltachat_rpc_client-2.28.0.dist-info → deltachat_rpc_client-2.29.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|