comparison sat_frontends/jp/cmd_ping.py @ 3568:04283582966f

core, frontends: fix invalid translatable strings. Some f-strings where used in translatable text, this has been fixed by using explicit `format()` call (using a script based on `tokenize`). As tokenize messes with spaces, a reformating tool (`black`) has been applied to some files afterwards.
author Goffi <goffi@goffi.org>
date Mon, 14 Jun 2021 18:35:12 +0200
parents be6d91572633
children 4b842c1fb686
comparison
equal deleted inserted replaced
3567:a240748ed686 3568:04283582966f
23 23
24 __commands__ = ["Ping"] 24 __commands__ = ["Ping"]
25 25
26 26
27 class Ping(base.CommandBase): 27 class Ping(base.CommandBase):
28
29 def __init__(self, host): 28 def __init__(self, host):
30 super(Ping, self).__init__(host, 'ping', help=_('ping XMPP entity')) 29 super(Ping, self).__init__(host, "ping", help=_("ping XMPP entity"))
31 30
32 def add_parser_options(self): 31 def add_parser_options(self):
33 self.parser.add_argument( 32 self.parser.add_argument("jid", help=_("jid to ping"))
34 "jid", help=_("jid to ping")
35 )
36 self.parser.add_argument( 33 self.parser.add_argument(
37 "-d", "--delay-only", action="store_true", help=_("output delay only (in s)") 34 "-d", "--delay-only", action="store_true", help=_("output delay only (in s)")
38 ) 35 )
39 36
40 async def start(self): 37 async def start(self):
41 try: 38 try:
42 pong_time = await self.host.bridge.ping(self.args.jid, self.profile) 39 pong_time = await self.host.bridge.ping(self.args.jid, self.profile)
43 except Exception as e: 40 except Exception as e:
44 self.disp(msg=_(f"can't do the ping: {e}"), error=True) 41 self.disp(msg=_("can't do the ping: {e}").format(e=e), error=True)
45 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 42 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
46 else: 43 else:
47 msg = pong_time if self.args.delay_only else f"PONG ({pong_time} s)" 44 msg = pong_time if self.args.delay_only else f"PONG ({pong_time} s)"
48 self.disp(msg) 45 self.disp(msg)
49 self.host.quit() 46 self.host.quit()