comparison sat_frontends/jp/cmd_application.py @ 3377:297389b1563c

jp (application/list): don't use `extend` in argument as in it Python 3.8+ only
author Goffi <goffi@goffi.org>
date Thu, 01 Oct 2020 10:12:01 +0200
parents 47755614b82a
children be6d91572633
comparison
equal deleted inserted replaced
3376:a94cdda7d5c4 3377:297389b1563c
32 host, "list", use_profile=False, use_output=C.OUTPUT_LIST, 32 host, "list", use_profile=False, use_output=C.OUTPUT_LIST,
33 help=_("list available applications") 33 help=_("list available applications")
34 ) 34 )
35 35
36 def add_parser_options(self): 36 def add_parser_options(self):
37 # FIXME: "extend" would be better here, but it's only available from Python 3.8+
38 # so we use "append" until minimum version of Python is raised.
37 self.parser.add_argument( 39 self.parser.add_argument(
38 "-f", 40 "-f",
39 "--filters", 41 "--filter",
40 action="extend", 42 dest="filters",
41 nargs="+", 43 action="append",
42 choices=["available", "running"], 44 choices=["available", "running"],
43 default=["available"],
44 help=_("show applications with this status"), 45 help=_("show applications with this status"),
45 ) 46 )
46 47
47 async def start(self): 48 async def start(self):
49
50 # FIXME: this is only needed because we can't use "extend" in
51 # add_parser_options, see note there
52 if self.args.filters:
53 self.args.filters = list(set(self.args.filters))
54 else:
55 self.args.filters = ['available']
56
48 try: 57 try:
49 found_apps = await self.host.bridge.applicationsList(self.args.filters) 58 found_apps = await self.host.bridge.applicationsList(self.args.filters)
50 except Exception as e: 59 except Exception as e:
51 self.disp(f"can't get applications list: {e}", error=True) 60 self.disp(f"can't get applications list: {e}", error=True)
52 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 61 self.host.quit(C.EXIT_BRIDGE_ERRBACK)