Mercurial > libervia-backend
annotate sat_frontends/jp/cmd_application.py @ 3375:b41ed8d9d40b
i18n: renamed template file to get the correct '.pot' extension
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 28 Sep 2020 21:10:33 +0200 |
parents | 47755614b82a |
children | 297389b1563c |
rev | line source |
---|---|
3374
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 # jp: a SàT command line tool |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 from . import base |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 from sat.core.i18n import _ |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 from sat.tools.common import data_format |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from sat_frontends.jp.constants import Const as C |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 __commands__ = ["Application"] |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 class List(base.CommandBase): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 """List available applications""" |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 def __init__(self, host): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 super(List, self).__init__( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 host, "list", use_profile=False, use_output=C.OUTPUT_LIST, |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 help=_("list available applications") |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 def add_parser_options(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 self.parser.add_argument( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 "-f", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 "--filters", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 action="extend", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 nargs="+", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 choices=["available", "running"], |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 default=["available"], |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 help=_("show applications with this status"), |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 async def start(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 try: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 found_apps = await self.host.bridge.applicationsList(self.args.filters) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 except Exception as e: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 self.disp(f"can't get applications list: {e}", error=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 await self.output(found_apps) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 self.host.quit() |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 class Start(base.CommandBase): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 """Start an application""" |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 def __init__(self, host): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 super(Start, self).__init__( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 host, "start", use_profile=False, help=_("start an application") |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 def add_parser_options(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 self.parser.add_argument( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 "name", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 help=_("name of the application to start"), |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 async def start(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 try: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 await self.host.bridge.applicationStart( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 self.args.name, |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 "", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 except Exception as e: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 self.disp(f"can't start {self.args.name}: {e}", error=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 self.host.quit() |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 class Stop(base.CommandBase): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 def __init__(self, host): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 super(Stop, self).__init__( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 host, "stop", use_profile=False, help=_("stop a running application") |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 def add_parser_options(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 id_group = self.parser.add_mutually_exclusive_group(required=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 id_group.add_argument( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 "name", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 nargs="?", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 help=_("name of the application to stop"), |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 id_group.add_argument( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 "-i", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 "--id", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 help=_("identifier of the instance to stop"), |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 async def start(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 try: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 if self.args.name is not None: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 args = [self.args.name, "name"] |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 args = [self.args.id, "instance"] |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 await self.host.bridge.applicationStop( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 *args, |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 "", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 except Exception as e: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 if self.args.name is not None: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 self.disp( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 f"can't stop application {self.args.name!r}: {e}", error=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 self.disp( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 f"can't stop application instance with id {self.args.id!r}: {e}", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 error=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 self.host.quit() |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 class Exposed(base.CommandBase): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 def __init__(self, host): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 super(Exposed, self).__init__( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 host, "exposed", use_profile=False, use_output=C.OUTPUT_DICT, |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 help=_("show data exposed by a running application") |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 def add_parser_options(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 id_group = self.parser.add_mutually_exclusive_group(required=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 id_group.add_argument( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 "name", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 nargs="?", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 help=_("name of the application to stop"), |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 id_group.add_argument( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 "-i", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 "--id", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 help=_("identifier of the instance to stop"), |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 async def start(self): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 try: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 if self.args.name is not None: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 args = [self.args.name, "name"] |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 args = [self.args.id, "instance"] |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 exposed_data_raw = await self.host.bridge.applicationExposedGet( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 *args, |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 "", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 ) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 except Exception as e: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 if self.args.name is not None: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 self.disp( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 f"can't get values exposed from application {self.args.name!r}: {e}", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 error=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 self.disp( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 f"can't values exposed from application instance with id {self.args.id!r}: {e}", |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 error=True) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 else: |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 exposed_data = data_format.deserialise(exposed_data_raw) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 await self.output(exposed_data) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 self.host.quit() |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 class Application(base.CommandBase): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 subcommands = (List, Start, Stop, Exposed) |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 def __init__(self, host): |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 super(Application, self).__init__( |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 host, "application", use_profile=False, help=_("manage applications"), |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 aliases=['app'], |
47755614b82a
jp (application): new `application` (or `app`) commands:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 ) |