Mercurial > libervia-backend
annotate frontends/src/jp/cmd_adhoc.py @ 2529:cbbf2ff2ef3f
component file sharing: changed pubsub identity:
pubsub service disco identity has been changed to non standard "virtual" type, to avoid it to be used as main pubsub service by the client.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 18 Mar 2018 11:26:01 +0100 |
parents | 0046283a285d |
children |
rev | line source |
---|---|
1960 | 1 #!/usr/bin/env python2 |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # jp: a SAT command line tool |
2483 | 5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 import base |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 from sat.core.i18n import _ |
2409
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
22 from functools import partial |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
23 from sat_frontends.jp.constants import Const as C |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
24 from sat_frontends.jp import xmlui_manager |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 __commands__ = ["AdHoc"] |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 FLAG_LOOP = 'LOOP' |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 MAGIC_BAREJID = '@PROFILE_BAREJID@' |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
2409
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
31 |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 class Remote(base.CommandBase): |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 def __init__(self, host): |
2409
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
34 super(Remote, self).__init__(host, 'remote', use_verbose=True, help=_(u'remote control a software')) |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 def add_parser_options(self): |
2409
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
37 self.parser.add_argument("software", type=str, help=_(u"software name")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
38 self.parser.add_argument("-j", "--jids", type=base.unicode_decoder, nargs='*', default=[], help=_(u"jids allowed to use the command")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
39 self.parser.add_argument("-g", "--groups", type=base.unicode_decoder, nargs='*', default=[], help=_(u"groups allowed to use the command")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
40 self.parser.add_argument("--forbidden-groups", type=base.unicode_decoder, nargs='*', default=[], help=_(u"groups that are *NOT* allowed to use the command")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
41 self.parser.add_argument("--forbidden-jids", type=base.unicode_decoder, nargs='*', default=[], help=_(u"jids that are *NOT* allowed to use the command")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
42 self.parser.add_argument("-l", "--loop", action="store_true", help=_(u"loop on the commands")) |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 |
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
|
44 def start(self): |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 name = self.args.software.lower() |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 flags = [] |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 magics = {jid for jid in self.args.jids if jid.count('@')>1} |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 magics.add(MAGIC_BAREJID) |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 jids = set(self.args.jids).difference(magics) |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 if self.args.loop: |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 flags.append(FLAG_LOOP) |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 bus_name, methods = self.host.bridge.adHocDBusAddAuto(name, jids, self.args.groups, magics, |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 self.args.forbidden_jids, self.args.forbidden_groups, |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 flags, self.profile) |
1933
16e65f15f31f
plugin adhoc_dbus, jp (cmd/adhoc): fixes adHocDBusAddAuto when no bus is found
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
55 if not bus_name: |
16e65f15f31f
plugin adhoc_dbus, jp (cmd/adhoc): fixes adHocDBusAddAuto when no bus is found
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
56 self.disp(_("No bus name found"), 1) |
16e65f15f31f
plugin adhoc_dbus, jp (cmd/adhoc): fixes adHocDBusAddAuto when no bus is found
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
57 return |
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
|
58 self.disp(_("Bus name found: [%s]" % bus_name), 1) |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 for method in methods: |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 path, iface, command = method |
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
|
61 self.disp(_("Command found: (path:%(path)s, iface: %(iface)s) [%(command)s]" % {'path': path, |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 'iface': iface, |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 'command': command |
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
|
64 }),1) |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
2409
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
66 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
67 class Run(base.CommandBase): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
68 """Run an Ad-Hoc command""" |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
69 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
70 def __init__(self, host): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
71 super(Run, self).__init__(host, 'run', use_verbose=True, help=_(u'run an Ad-Hoc command')) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
72 self.need_loop=True |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
73 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
74 def add_parser_options(self): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
75 self.parser.add_argument('-j', '--jid', type=base.unicode_decoder, default=u'', help=_(u"jid of the service (default: profile's server")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
76 self.parser.add_argument("-S", "--submit", action='append_const', const=xmlui_manager.SUBMIT, dest='workflow', help=_(u"submit form/page")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
77 self.parser.add_argument("-f", |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
78 "--field", |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
79 type=base.unicode_decoder, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
80 action='append', |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
81 nargs=2, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
82 dest='workflow', |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
83 metavar=(u"KEY", u"VALUE"), |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
84 help=_(u"field value")) |
2411
f9167c053475
jp (ad-hoc/run): node is now a positional argument
Goffi <goffi@goffi.org>
parents:
2409
diff
changeset
|
85 self.parser.add_argument('node', type=base.unicode_decoder, nargs='?', default=u'', help=_(u"node of the command (default: list commands)")) |
2409
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
86 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
87 def adHocRunCb(self, xmlui_raw): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
88 xmlui = xmlui_manager.create(self.host, xmlui_raw) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
89 workflow = self.args.workflow |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
90 xmlui.show(workflow) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
91 if not workflow: |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
92 if xmlui.type == 'form': |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
93 xmlui.submitForm() |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
94 else: |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
95 self.host.quit() |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
96 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
97 def start(self): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
98 self.host.bridge.adHocRun( |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
99 self.args.jid, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
100 self.args.node, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
101 self.profile, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
102 callback=self.adHocRunCb, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
103 errback=partial(self.errback, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
104 msg=_(u"can't get ad-hoc commands list: {}"), |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
105 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
106 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
107 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
108 class List(base.CommandBase): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
109 """Run an Ad-Hoc command""" |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
110 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
111 def __init__(self, host): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
112 super(List, self).__init__(host, 'list', use_verbose=True, help=_(u'list Ad-Hoc commands of a service')) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
113 self.need_loop=True |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
114 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
115 def add_parser_options(self): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
116 self.parser.add_argument('-j', '--jid', type=base.unicode_decoder, default=u'', help=_(u"jid of the service (default: profile's server")) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
117 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
118 def adHocListCb(self, xmlui_raw): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
119 xmlui = xmlui_manager.create(self.host, xmlui_raw) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
120 xmlui.readonly = True |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
121 xmlui.show() |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
122 self.host.quit() |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
123 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
124 def start(self): |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
125 self.host.bridge.adHocList( |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
126 self.args.jid, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
127 self.profile, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
128 callback=self.adHocListCb, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
129 errback=partial(self.errback, |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
130 msg=_(u"can't get ad-hoc commands list: {}"), |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
131 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
132 |
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
133 |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 class AdHoc(base.CommandBase): |
2409
d2ff5ff3de77
jp (ad-hoc): new "list" and "run" commands:
Goffi <goffi@goffi.org>
parents:
1960
diff
changeset
|
135 subcommands = (Run, List, Remote) |
824
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 def __init__(self, host): |
c304ce32042b
jp: added ad-hoc subcommand with a remote sub-subcommand to create a D-Bus remote
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 super(AdHoc, self).__init__(host, 'ad-hoc', use_profile=False, help=_('Ad-hoc commands')) |