annotate frontends/src/jp/cmd_info.py @ 2179:e42c6c131b52

jp (profile): fixed help gettext calls
author Goffi <goffi@goffi.org>
date Thu, 09 Mar 2017 23:10:17 +0100
parents fff88c33442f
children 4fd499d14b27
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1960
3e168cde7a7d jp: fixed shebang python call
Goffi <goffi@goffi.org>
parents: 1864
diff changeset
1 #!/usr/bin/env python2
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
3
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # jp: a SAT command line tool
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1414
diff changeset
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org)
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
6
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
11
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
16
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
19
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
20 import base
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core.i18n import _
2114
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
22 from sat_frontends.jp.constants import Const as C
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
23
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
24 __commands__ = ["Info"]
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
25
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
26
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
27 class Disco(base.CommandBase):
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
28
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
29 def __init__(self, host):
2114
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
30 super(Disco, self).__init__(host, 'disco', help=_('service discovery'))
1864
96ba685162f6 jp: all commands now use the new start method and set need_loop in __init__ when needed
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
31 self.need_loop=True
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
32
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
33 def add_parser_options(self):
2151
fff88c33442f jp (info/disco): added --node argument
Goffi <goffi@goffi.org>
parents: 2114
diff changeset
34 self.parser.add_argument(u"jid", type=base.unicode_decoder, help=_(u"entity to discover"))
fff88c33442f jp (info/disco): added --node argument
Goffi <goffi@goffi.org>
parents: 2114
diff changeset
35 self.parser.add_argument(u"-n", u"--node", type=base.unicode_decoder, default=u'', help=_(u"node to use"))
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
36
1864
96ba685162f6 jp: all commands now use the new start method and set need_loop in __init__ when needed
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
37 def start(self):
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
38 jids = self.host.check_jids([self.args.jid])
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
39 jid = jids[0]
2151
fff88c33442f jp (info/disco): added --node argument
Goffi <goffi@goffi.org>
parents: 2114
diff changeset
40 self.host.bridge.discoInfos(jid, node=self.args.node, profile_key=self.host.profile, callback=lambda infos: self.gotInfos(infos, jid), errback=self.error)
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
41
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
42 def error(self, failure):
1063
6ec513ad92c2 frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents: 974
diff changeset
43 print (_("Error while doing discovery [%s]") % failure)
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
44 self.host.quit(1)
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
45
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
46 def gotInfos(self, infos, jid):
2151
fff88c33442f jp (info/disco): added --node argument
Goffi <goffi@goffi.org>
parents: 2114
diff changeset
47 self.host.bridge.discoItems(jid, node=self.args.node, profile_key=self.host.profile, callback=lambda items: self.gotItems(infos, items), errback=self.error)
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
48
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
49 def gotItems(self, infos, items):
1414
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
50 features, identities, extensions = infos
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
51 features.sort()
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
52 identities.sort(key=lambda identity: identity[2])
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
53 items.sort(key=lambda item: item[2])
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
54 identities_lst = []
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
55 items_lst = []
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
56 for identity in identities:
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
57 category, type_, name = identity
1414
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
58 identities_lst.append(u"{name}({cat}/{type_})".format(
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
59 name = (name+' ') if name else '',
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
60 cat = category,
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
61 type_ = type_))
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
62 for item in items:
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
63 entity, node_id, name = item
1414
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
64 items_lst.append(u"{name}[{entity}{node_id}]".format(
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
65 name = (name+' ') if name else '',
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
66 entity = entity,
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
67 node_id = (', ' + node_id) if node_id else ''
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
68 ))
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
69 extensions_types = extensions.keys()
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
70 extensions_types.sort()
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
71
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
72 extensions_tpl = []
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
73 for type_ in extensions_types:
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
74 fields = []
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
75 for field in extensions[type_]:
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
76 field_lines = []
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
77 data, values = field
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
78 data_keys = data.keys()
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
79 data_keys.sort()
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
80 for key in data_keys:
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
81 field_lines.append(u'\t{key} = {value}'.format(key=key, value=data[key]))
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
82 for value in values:
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
83 field_lines.append(u'\tvalue = {value}'.format(value=value))
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
84 fields.append(u'\n'.join(field_lines))
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
85 extensions_tpl.append(u'{type_}\n{fields}'.format(type_=type_,
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
86 fields='\n\n'.join(fields)))
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
87
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
88 template = []
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
89 if features:
1414
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
90 template.append(_(u"Features:\n\n{features}"))
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
91 if identities:
1414
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
92 template.append(_(u"Identities:\n\n{identities}"))
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
93 if extensions_tpl:
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
94 template.append(_(u'Extensions:\n\n{extensions}'))
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
95 if items:
1414
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
96 template.append(_(u"Items:\n\n{items}"))
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
97
1414
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
98 print "\n--\n".join(template).format ( features = '\n'.join(features),
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
99 identities = '\n'.join(identities_lst),
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
100 extensions = '\n'.join(extensions_tpl),
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
101 items = '\n'.join(items_lst),
159d16336f87 core, bridge, jp: management of service discovery extensions (XEP-0128)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
102 )
966
9cae72da1b95 jp: added disco subcommand
Goffi <goffi@goffi.org>
parents:
diff changeset
103 self.host.quit()
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
104
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
105
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
106 class Version(base.CommandBase):
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
107
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
108 def __init__(self, host):
2114
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
109 super(Version, self).__init__(host, 'version', help=_('running session'))
1864
96ba685162f6 jp: all commands now use the new start method and set need_loop in __init__ when needed
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
110 self.need_loop=True
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
111
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
112 def add_parser_options(self):
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
113 self.parser.add_argument("jid", type=str, help=_("Entity to request"))
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
114
1864
96ba685162f6 jp: all commands now use the new start method and set need_loop in __init__ when needed
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
115 def start(self):
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
116 jids = self.host.check_jids([self.args.jid])
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
117 jid = jids[0]
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
118 self.host.bridge.getSoftwareVersion(jid, self.host.profile, callback=self.gotVersion, errback=self.error)
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
119
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
120 def error(self, failure):
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
121 print (_("Error while trying to get version [%s]") % failure)
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
122 self.host.quit(1)
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
123
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
124 def gotVersion(self, data):
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
125 infos = []
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
126 name, version, os = data
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
127 if name:
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
128 infos.append(_("Client name: %s") % name)
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
129 if version:
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
130 infos.append(_("Client version: %s") % version)
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
131 if os:
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
132 infos.append(_("Operating System: %s") % os)
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
133
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
134 print "\n".join(infos)
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
135 self.host.quit()
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
136
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
137
2114
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
138 class Session(base.CommandBase):
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
139
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
140 def __init__(self, host):
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
141 super(Session, self).__init__(host, 'session', use_output='dict', help=_('client version'))
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
142 self.need_loop=True
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
143
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
144 def add_parser_options(self):
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
145 pass
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
146
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
147 def start(self):
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
148 self.host.bridge.sessionInfosGet(self.host.profile, callback=self._sessionInfoGetCb, errback=self._sessionInfoGetEb)
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
149
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
150 def _sessionInfoGetCb(self, data):
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
151 self.output(data)
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
152 self.host.quit()
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
153
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
154 def _sessionInfoGetEb(self, error_data):
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
155 self.disp(_(u'Error getting session infos: {}').format(error_data), error=True)
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
156 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
157
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
158
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
159 class Info(base.CommandBase):
2114
dc5d214f0a3b jp (info/session): added a command to get data on current session
Goffi <goffi@goffi.org>
parents: 1960
diff changeset
160 subcommands = (Disco, Version, Session)
971
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
161
8ca5c990ed92 jp: "disco" subcommand, moved into a new "info" subcommand + added "version" subcommand which get software version
Goffi <goffi@goffi.org>
parents: 966
diff changeset
162 def __init__(self, host):
1199
96fb74a4714d misc: fixed some typos
Matteo Cypriani <mcy@lm7.fr>
parents: 1063
diff changeset
163 super(Info, self).__init__(host, 'info', use_profile=False, help=_('Get various pieces of information on entities'))