Mercurial > libervia-backend
comparison frontends/src/jp/cmd_debug.py @ 2041:456abbceee19
jp (debug/bridge): fixed unicode handling of arguments
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 21 Aug 2016 18:57:56 +0200 |
parents | 3a5badbb443d |
children | a3c2866841f7 |
comparison
equal
deleted
inserted
replaced
2040:f607349a01a4 | 2041:456abbceee19 |
---|---|
33 try: | 33 try: |
34 return eval(u",".join(self.args.arg)) | 34 return eval(u",".join(self.args.arg)) |
35 except SyntaxError as e: | 35 except SyntaxError as e: |
36 self.disp(u"Can't evaluate arguments: {mess}\n{text}\n{offset}^".format( | 36 self.disp(u"Can't evaluate arguments: {mess}\n{text}\n{offset}^".format( |
37 mess=e, | 37 mess=e, |
38 text=e.text, | 38 text=e.text.decode('utf-8'), |
39 offset=u" "*(e.offset-1) | 39 offset=u" "*(e.offset-1) |
40 ), error=True) | 40 ), error=True) |
41 self.host.quit(C.EXIT_BAD_ARG) | 41 self.host.quit(C.EXIT_BAD_ARG) |
42 else: | 42 else: |
43 return [] | 43 return [] |
50 BridgeCommon.__init__(self) | 50 BridgeCommon.__init__(self) |
51 self.need_loop=True | 51 self.need_loop=True |
52 | 52 |
53 def add_parser_options(self): | 53 def add_parser_options(self): |
54 self.parser.add_argument("method", type=str, help=_(u"name of the method to execute")) | 54 self.parser.add_argument("method", type=str, help=_(u"name of the method to execute")) |
55 self.parser.add_argument("arg", nargs="*", help=_(u"argument of the method")) | 55 self.parser.add_argument("arg", type=base.unicode_decoder, nargs="*", help=_(u"argument of the method")) |
56 | 56 |
57 def method_cb(self, ret): | 57 def method_cb(self, ret): |
58 self.disp(unicode(ret)) | 58 self.disp(unicode(ret)) |
59 self.host.quit() | 59 self.host.quit() |
60 | 60 |
81 base.CommandBase.__init__(self, host, 'signal', help=_(u'send a fake signal from backend')) | 81 base.CommandBase.__init__(self, host, 'signal', help=_(u'send a fake signal from backend')) |
82 BridgeCommon.__init__(self) | 82 BridgeCommon.__init__(self) |
83 | 83 |
84 def add_parser_options(self): | 84 def add_parser_options(self): |
85 self.parser.add_argument("signal", type=str, help=_(u"name of the signal to send")) | 85 self.parser.add_argument("signal", type=str, help=_(u"name of the signal to send")) |
86 self.parser.add_argument("arg", nargs="*", help=_(u"argument of the signal")) | 86 self.parser.add_argument("arg", type=base.unicode_decoder, nargs="*", help=_(u"argument of the signal")) |
87 | 87 |
88 def start(self): | 88 def start(self): |
89 args = self.evalArgs() | 89 args = self.evalArgs() |
90 json_args = json.dumps(args) | 90 json_args = json.dumps(args) |
91 # XXX: we use self.args.profile and not self.profile | 91 # XXX: we use self.args.profile and not self.profile |