deltabot-cli 6.1.0__tar.gz → 6.2.0__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.1
2
2
  Name: deltabot-cli
3
- Version: 6.1.0
3
+ Version: 6.2.0
4
4
  Summary: Library to speedup Delta Chat bot development
5
5
  Author-email: adbenitez <adb@merlinux.eu>
6
6
  Project-URL: Homepage, https://github.com/deltachat-bot/deltabot-cli-py
@@ -6,12 +6,13 @@ import subprocess
6
6
  import sys
7
7
  import time
8
8
  from argparse import ArgumentParser, Namespace
9
+ from pathlib import Path
9
10
  from threading import Thread
10
11
  from typing import Callable, Set, Union
11
12
 
12
13
  import qrcode
13
14
  from appdirs import user_config_dir
14
- from deltachat2 import Bot, Event, EventType, IOTransport, JsonRpcError, Rpc
15
+ from deltachat2 import Bot, CoreEvent, Event, EventType, IOTransport, JsonRpcError, Rpc
15
16
  from deltachat2.events import EventFilter, HookCollection, HookDecorator, RawEvent
16
17
  from rich.logging import RichHandler
17
18
 
@@ -131,6 +132,9 @@ class BotCli:
131
132
  config_parser.add_argument("option", help="option name", nargs="?")
132
133
  config_parser.add_argument("value", help="option value to set", nargs="?")
133
134
 
135
+ import_parser = self.add_subcommand(_import_cmd, name="import")
136
+ import_parser.add_argument("path", help="path to the account backup", type=Path)
137
+
134
138
  self.add_subcommand(_serve_cmd, name="serve")
135
139
  self.add_subcommand(_qr_cmd, name="qr")
136
140
  self.add_subcommand(_list_cmd, name="list")
@@ -215,7 +219,7 @@ def _init_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None: # noqa: C901
215
219
  while True:
216
220
  raw_event = bot.rpc.get_next_event()
217
221
  accid = raw_event.context_id
218
- event = raw_event.event
222
+ event = CoreEvent(raw_event.event)
219
223
  if event.kind == EventType.CONFIGURE_PROGRESS:
220
224
  if event.comment:
221
225
  bot.logger.info(event.comment)
@@ -340,7 +344,7 @@ def _list_cmd(cli: BotCli, bot: Bot, _args: Namespace) -> None:
340
344
  for accid in accounts:
341
345
  addr = cli.get_address(rpc, accid)
342
346
  if not rpc.is_configured(accid):
343
- addr = addr + " (not configured)"
347
+ addr = f"{addr or ''} (not configured)"
344
348
  print(f"#{accid} - {addr}")
345
349
 
346
350
 
@@ -365,3 +369,20 @@ def _remove_cmd(cli: BotCli, bot: Bot, args: Namespace) -> None:
365
369
  addr = cli.get_address(bot.rpc, accid)
366
370
  bot.rpc.remove_account(accid)
367
371
  print(f"Account #{accid} ({addr}) removed successfully.")
372
+
373
+
374
+ def _import_cmd(_cli: BotCli, bot: Bot, args: Namespace) -> None:
375
+ """import account backup"""
376
+ if not args.path.exists():
377
+ bot.logger.error(f"path doesn't exist: {str(args.path)!r}")
378
+ sys.exit(1)
379
+ accid = bot.rpc.add_account()
380
+ try:
381
+ bot.rpc.import_backup(accid, str(args.path), None)
382
+ except JsonRpcError as ex:
383
+ bot.rpc.remove_account(accid)
384
+ bot.logger.exception(ex)
385
+ sys.exit(1)
386
+ else:
387
+ addr = bot.rpc.get_config(accid, "configured_addr")
388
+ print(f"Account #{accid} ({addr}) imported successfully.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: deltabot-cli
3
- Version: 6.1.0
3
+ Version: 6.2.0
4
4
  Summary: Library to speedup Delta Chat bot development
5
5
  Author-email: adbenitez <adb@merlinux.eu>
6
6
  Project-URL: Homepage, https://github.com/deltachat-bot/deltabot-cli-py
@@ -41,6 +41,9 @@ dev = [
41
41
  [tool.setuptools_scm]
42
42
  # can be empty if no extra settings are needed, presence enables setuptools_scm
43
43
 
44
+ [tool.setuptools]
45
+ packages = ["deltabot_cli"]
46
+
44
47
  [tool.black]
45
48
  line-length = 100
46
49
 
File without changes
File without changes
File without changes
File without changes
File without changes