Mercurial > libervia-backend
annotate sat_frontends/jp/cmd_debug.py @ 3695:87caf6284c55
docker (prosody): don't use `tmpfs` for `/var/lib/prosody` (it prevents the container to start)
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 22 Oct 2021 10:40:24 +0200 |
parents | 04283582966f |
children | 691dbd78981c |
rev | line source |
---|---|
3137 | 1 #!/usr/bin/env python3 |
2 | |
2038 | 3 |
4 # jp: a SàT command line tool | |
3479 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
2038 | 6 |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
3028 | 21 from . import base |
2038 | 22 from sat.core.i18n import _ |
23 from sat_frontends.jp.constants import Const as C | |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
24 from sat.tools.common.ansi import ANSI as A |
2038 | 25 import json |
26 | |
27 __commands__ = ["Debug"] | |
28 | |
29 | |
30 class BridgeCommon(object): | |
31 def evalArgs(self): | |
32 if self.args.arg: | |
33 try: | |
3028 | 34 return eval("[{}]".format(",".join(self.args.arg))) |
2038 | 35 except SyntaxError as e: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
36 self.disp( |
3028 | 37 "Can't evaluate arguments: {mess}\n{text}\n{offset}^".format( |
38 mess=e, text=e.text, offset=" " * (e.offset - 1) | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
39 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
40 error=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
41 ) |
2038 | 42 self.host.quit(C.EXIT_BAD_ARG) |
43 else: | |
44 return [] | |
45 | |
46 | |
47 class Method(base.CommandBase, BridgeCommon): | |
48 def __init__(self, host): | |
3028 | 49 base.CommandBase.__init__(self, host, "method", help=_("call a bridge method")) |
2038 | 50 BridgeCommon.__init__(self) |
51 | |
52 def add_parser_options(self): | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
53 self.parser.add_argument( |
3028 | 54 "method", type=str, help=_("name of the method to execute") |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
55 ) |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
56 self.parser.add_argument("arg", nargs="*", help=_("argument of the method")) |
2038 | 57 |
3040 | 58 async def start(self): |
2038 | 59 method = getattr(self.host.bridge, self.args.method) |
3040 | 60 import inspect |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
61 |
3040 | 62 argspec = inspect.getargspec(method) |
63 | |
64 kwargs = {} | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
65 if "profile_key" in argspec.args: |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
66 kwargs["profile_key"] = self.profile |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
67 elif "profile" in argspec.args: |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
68 kwargs["profile"] = self.profile |
3040 | 69 |
2038 | 70 args = self.evalArgs() |
3040 | 71 |
2038 | 72 try: |
3040 | 73 ret = await method( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
74 *args, |
3040 | 75 **kwargs, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
76 ) |
3040 | 77 except Exception as e: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
78 self.disp( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
79 _("Error while executing {method}: {e}").format( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
80 method=self.args.method, e=e |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
81 ), |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
82 error=True, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
83 ) |
3040 | 84 self.host.quit(C.EXIT_ERROR) |
85 else: | |
86 if ret is not None: | |
87 self.disp(str(ret)) | |
88 self.host.quit() | |
2038 | 89 |
90 | |
91 class Signal(base.CommandBase, BridgeCommon): | |
92 def __init__(self, host): | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
93 base.CommandBase.__init__( |
3028 | 94 self, host, "signal", help=_("send a fake signal from backend") |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
95 ) |
2038 | 96 BridgeCommon.__init__(self) |
97 | |
98 def add_parser_options(self): | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
99 self.parser.add_argument("signal", type=str, help=_("name of the signal to send")) |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
100 self.parser.add_argument("arg", nargs="*", help=_("argument of the signal")) |
2038 | 101 |
3040 | 102 async def start(self): |
2038 | 103 args = self.evalArgs() |
104 json_args = json.dumps(args) | |
105 # XXX: we use self.args.profile and not self.profile | |
106 # because we want the raw profile_key (so plugin handle C.PROF_KEY_NONE) | |
3040 | 107 try: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
108 await self.host.bridge.debugFakeSignal( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
109 self.args.signal, json_args, self.args.profile |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
110 ) |
3040 | 111 except Exception as e: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
112 self.disp(_("Can't send fake signal: {e}").format(e=e), error=True) |
3040 | 113 self.host.quit(C.EXIT_ERROR) |
114 else: | |
115 self.host.quit() | |
2038 | 116 |
117 | |
118 class Bridge(base.CommandBase): | |
119 subcommands = (Method, Signal) | |
120 | |
121 def __init__(self, host): | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
122 super(Bridge, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
123 host, "bridge", use_profile=False, help=_("bridge s(t)imulation") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
124 ) |
2038 | 125 |
126 | |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
127 class Monitor(base.CommandBase): |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
128 def __init__(self, host): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
129 super(Monitor, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
130 host, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
131 "monitor", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
132 use_verbose=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
133 use_profile=False, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
134 use_output=C.OUTPUT_XML, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
135 help=_("monitor XML stream"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
136 ) |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
137 |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
138 def add_parser_options(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
139 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
140 "-d", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
141 "--direction", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
142 choices=("in", "out", "both"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
143 default="both", |
3028 | 144 help=_("stream direction filter"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
145 ) |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
146 |
3040 | 147 async def printXML(self, direction, xml_data, profile): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
148 if self.args.direction == "in" and direction != "IN": |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
149 return |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
150 if self.args.direction == "out" and direction != "OUT": |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
151 return |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
152 verbosity = self.host.verbosity |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
153 if not xml_data.strip(): |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
154 if verbosity <= 2: |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
155 return |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
156 whiteping = True |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
157 else: |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
158 whiteping = False |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
159 |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
160 if verbosity: |
3040 | 161 profile_disp = f" ({profile})" if verbosity > 1 else "" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
162 if direction == "IN": |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
163 self.disp( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
164 A.color( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
165 A.BOLD, A.FG_YELLOW, "<<<===== IN ====", A.FG_WHITE, profile_disp |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
166 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
167 ) |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
168 else: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
169 self.disp( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
170 A.color( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
171 A.BOLD, A.FG_CYAN, "==== OUT ====>>>", A.FG_WHITE, profile_disp |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
172 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
173 ) |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
174 if whiteping: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
175 self.disp("[WHITESPACE PING]") |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
176 else: |
2441
e86dc8cb4345
jp (debug/monitor): if data can't be parsed (happen at beginning/end of stream because it's not complete XML), it is printed directly.
Goffi <goffi@goffi.org>
parents:
2417
diff
changeset
|
177 try: |
3040 | 178 await self.output(xml_data) |
2441
e86dc8cb4345
jp (debug/monitor): if data can't be parsed (happen at beginning/end of stream because it's not complete XML), it is printed directly.
Goffi <goffi@goffi.org>
parents:
2417
diff
changeset
|
179 except Exception: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
180 # initial stream is not valid XML, |
2441
e86dc8cb4345
jp (debug/monitor): if data can't be parsed (happen at beginning/end of stream because it's not complete XML), it is printed directly.
Goffi <goffi@goffi.org>
parents:
2417
diff
changeset
|
181 # in this case we print directly to data |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
182 # FIXME: we should test directly lxml.etree.XMLSyntaxError |
2441
e86dc8cb4345
jp (debug/monitor): if data can't be parsed (happen at beginning/end of stream because it's not complete XML), it is printed directly.
Goffi <goffi@goffi.org>
parents:
2417
diff
changeset
|
183 # but importing lxml directly here is not clean |
e86dc8cb4345
jp (debug/monitor): if data can't be parsed (happen at beginning/end of stream because it's not complete XML), it is printed directly.
Goffi <goffi@goffi.org>
parents:
2417
diff
changeset
|
184 # should be wrapped in a custom Exception |
e86dc8cb4345
jp (debug/monitor): if data can't be parsed (happen at beginning/end of stream because it's not complete XML), it is printed directly.
Goffi <goffi@goffi.org>
parents:
2417
diff
changeset
|
185 self.disp(xml_data) |
3028 | 186 self.disp("") |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
187 |
3040 | 188 async def start(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
189 self.host.bridge.register_signal("xmlLog", self.printXML, "plugin") |
2417
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
190 |
192ae573901a
jp (debug): new monitor command to show pretty formatted XML stream
Goffi <goffi@goffi.org>
parents:
2414
diff
changeset
|
191 |
3047
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
192 class Theme(base.CommandBase): |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
193 def __init__(self, host): |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
194 base.CommandBase.__init__( |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
195 self, host, "theme", help=_("print colours used with your background") |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
196 ) |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
197 |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
198 def add_parser_options(self): |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
199 pass |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
200 |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
201 async def start(self): |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
202 for attr in dir(C): |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
203 if not attr.startswith("A_"): |
3047
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
204 continue |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
205 color = getattr(C, attr) |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
206 if attr == "A_LEVEL_COLORS": |
3047
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
207 # This constant contains multiple colors |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
208 self.disp("LEVEL COLORS: ", end=" ") |
3047
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
209 for idx, c in enumerate(color): |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
210 last = idx == len(color) - 1 |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
211 end = "\n" if last else " " |
3407
2f0be2b7de68
jp: replace `no_lf` argument by `end` in `disp` (same as in `print`)
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
212 self.disp( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
213 c + f"LEVEL_{idx}" + A.RESET + (", " if not last else ""), end=end |
3407
2f0be2b7de68
jp: replace `no_lf` argument by `end` in `disp` (same as in `print`)
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
214 ) |
3047
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
215 else: |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
216 text = attr[2:] |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
217 self.disp(A.color(color, text)) |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
218 self.host.quit() |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
219 |
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
220 |
2038 | 221 class Debug(base.CommandBase): |
3047
cf843dd7c345
jp (debug): new "theme" command to print colour theme according to `background` value:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
222 subcommands = (Bridge, Monitor, Theme) |
2038 | 223 |
224 def __init__(self, host): | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
225 super(Debug, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
226 host, "debug", use_profile=False, help=_("debugging tools") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
227 ) |