From 98b6b5e3f691f20433d8c1be289a6b62d1ab93c6 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 3 Dec 2022 18:37:02 +0000 Subject: [PATCH] Update instructions on using ipython --- deltachat-rpc-client/README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/deltachat-rpc-client/README.md b/deltachat-rpc-client/README.md index 6b38c361a..559806391 100644 --- a/deltachat-rpc-client/README.md +++ b/deltachat-rpc-client/README.md @@ -17,17 +17,24 @@ Additional arguments to `tox` are passed to pytest, e.g. `tox -- -s` does not ca ## Using in REPL +Setup a development environment: +``` +$ tox --devenv env +$ . env/bin/activate +``` + It is recommended to use IPython, because it supports using `await` directly from the REPL. ``` -PATH="../target/debug:$PATH" ipython +$ pip install ipython +$ PATH="../target/debug:$PATH" ipython ... In [1]: from deltachat_rpc_client import * -In [2]: dc = Deltachat(await start_rpc_server()) -In [3]: await dc.get_all_accounts() -Out [3]: [] -In [4]: alice = await dc.add_account() -In [5]: (await alice.get_info())["journal_mode"] -Out [5]: 'wal' +In [2]: rpc_generator = start_rpc_server() +In [3]: rpc = await rpc_generator.__aenter__() +In [4]: dc = Deltachat(rpc) +In [5]: system_info = await dc.get_system_info() +In [6]: system_info["level"] +Out [6]: 'awesome' ```