Mercurial > libervia-backend
annotate frontends/src/jp/cmd_pubsub.py @ 2339:d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
added subscriptions commands for node owner, with get/set subcommands (work in a similar way as affiliations)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 20 Aug 2017 10:33:33 +0200 |
parents | f4a0723042ee |
children | 3c0a3fae1862 |
rev | line source |
---|---|
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # jp: a SàT command line tool |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 import base |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from sat.core.i18n import _ |
2316 | 23 from sat.core import exceptions |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from sat_frontends.jp.constants import Const as C |
2275
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
25 from sat_frontends.jp import common |
2316 | 26 from sat_frontends.jp import arg_tools |
2221
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
27 from functools import partial |
2224
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
28 from sat.tools.common import uri |
2316 | 29 from sat.tools.common.ansi import ANSI as A |
30 from sat_frontends.tools import jid, strings | |
31 import argparse | |
2308
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
32 import os.path |
2316 | 33 import re |
34 import subprocess | |
35 import sys | |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 __commands__ = ["Pubsub"] |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 |
2275
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
39 PUBSUB_TMP_DIR = u"pubsub" |
2339
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
40 ALLOWED_SUBSCRIPTIONS_OWNER = ('subscribed', 'pending', 'none') |
2275
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
41 |
2308
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
42 # TODO: need to split this class in several modules, plugin should handle subcommands |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
43 |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
45 class NodeInfo(base.CommandBase): |
2197
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
46 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
47 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
48 base.CommandBase.__init__(self, host, 'info', use_output=C.OUTPUT_DICT, use_pubsub_node_req=True, help=_(u'retrieve node configuration')) |
2197
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
49 self.need_loop=True |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
50 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
51 def add_parser_options(self): |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
52 self.parser.add_argument("-k", "--key", type=base.unicode_decoder, action='append', dest='keys', |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
53 help=_(u"data key to filter")) |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
54 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
55 def removePrefix(self, key): |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
56 return key[7:] if key.startswith(u"pubsub#") else key |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
57 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
58 def filterKey(self, key): |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
59 return any((key == k or key == u'pubsub#' + k) for k in self.args.keys) |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
60 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
61 def psNodeConfigurationGetCb(self, config_dict): |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
62 key_filter = (lambda k: True) if not self.args.keys else self.filterKey |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
63 config_dict = {self.removePrefix(k):v for k,v in config_dict.iteritems() if key_filter(k)} |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
64 self.output(config_dict) |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
65 self.host.quit() |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
66 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
67 def psNodeConfigurationGetEb(self, failure_): |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
68 self.disp(u"can't get node configuration: {reason}".format( |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
69 reason=failure_), error=True) |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
70 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
71 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
72 def start(self): |
2279
e2f96cd1887b
jp (cmd_pubsub): xmpp: uri handling, first draft
Goffi <goffi@goffi.org>
parents:
2276
diff
changeset
|
73 common.checkURI(self.args) |
2197
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
74 self.host.bridge.psNodeConfigurationGet( |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
75 self.args.service, |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
76 self.args.node, |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
77 self.profile, |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
78 callback=self.psNodeConfigurationGetCb, |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
79 errback=self.psNodeConfigurationGetEb) |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
80 |
2221
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
81 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
82 class NodeCreate(base.CommandBase): |
2221
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
83 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
84 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
85 base.CommandBase.__init__(self, host, 'create', use_output=C.OUTPUT_DICT, use_pubsub_node_req=True, use_verbose=True, help=_(u'create a node')) |
2221
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
86 self.need_loop=True |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
87 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
88 def add_parser_options(self): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
89 self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields', |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
90 default={}, metavar=(u"KEY", u"VALUE"), help=_(u"configuration field to set")) |
2221
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
91 self.parser.add_argument("-F", "--full-prefix", action="store_true", help=_(u"don't prepend \"pubsub#\" prefix to field names")) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
92 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
93 def psNodeCreateCb(self, node_id): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
94 if self.host.verbosity: |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
95 announce = _(u'node created successfully: ') |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
96 else: |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
97 announce = u'' |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
98 self.disp(announce + node_id) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
99 self.host.quit() |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
100 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
101 def psNodeCreateEb(self, failure_): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
102 self.disp(u"can't create: {reason}".format( |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
103 reason=failure_), error=True) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
104 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
105 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
106 def start(self): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
107 if not self.args.full_prefix: |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
108 options = {u'pubsub#' + k: v for k,v in self.args.fields} |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
109 else: |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
110 options = dict(self.args.fields) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
111 self.host.bridge.psNodeCreate( |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
112 self.args.service, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
113 self.args.node, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
114 options, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
115 self.profile, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
116 callback=self.psNodeCreateCb, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
117 errback=partial(self.errback, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
118 msg=_(u"can't create node: {}"), |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
119 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
120 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
121 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
122 class NodeDelete(base.CommandBase): |
2221
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
123 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
124 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
125 base.CommandBase.__init__(self, host, 'delete', use_pubsub_node_req=True, help=_(u'delete a node')) |
2221
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
126 self.need_loop=True |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
127 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
128 def add_parser_options(self): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
129 self.parser.add_argument('-f', '--force', action='store_true', help=_(u'delete node without confirmation')) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
130 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
131 def psNodeDeleteCb(self): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
132 self.disp(_(u'node deleted successfully')) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
133 self.host.quit() |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
134 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
135 def start(self): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
136 if not self.args.force: |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
137 if not self.args.service: |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
138 message = _(u"Are you sure to delete pep node [{node_id}] ?").format( |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
139 node_id=self.args.node) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
140 else: |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
141 message = _(u"Are you sure to delete node [{node_id}] on service [{service}] ?").format( |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
142 node_id=self.args.node, service=self.args.service) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
143 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
144 res = raw_input("{} (y/N)? ".format(message)) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
145 if res not in ("y", "Y"): |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
146 self.disp(_(u"node deletion cancelled")) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
147 self.host.quit(2) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
148 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
149 self.host.bridge.psNodeDelete( |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
150 self.args.service, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
151 self.args.node, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
152 self.profile, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
153 callback=self.psNodeDeleteCb, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
154 errback=partial(self.errback, |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
155 msg=_(u"can't delete node: {}"), |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
156 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
157 |
a6c9bc4d1de0
jp (pubsub/node): added create and delete commands
Goffi <goffi@goffi.org>
parents:
2214
diff
changeset
|
158 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
159 class NodeSet(base.CommandBase): |
2199
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
160 |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
161 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
162 base.CommandBase.__init__(self, host, 'set', use_output=C.OUTPUT_DICT, use_pubsub_node_req=True, use_verbose=True, help=_(u'set node configuration')) |
2199
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
163 self.need_loop=True |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
164 |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
165 def add_parser_options(self): |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
166 self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields', |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
167 required=True, metavar=(u"KEY", u"VALUE"), help=_(u"configuration field to set (required)")) |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
168 |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
169 def psNodeConfigurationSetCb(self): |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
170 self.disp(_(u'node configuration successful'), 1) |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
171 self.host.quit() |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
172 |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
173 def psNodeConfigurationSetEb(self, failure_): |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
174 self.disp(u"can't set node configuration: {reason}".format( |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
175 reason=failure_), error=True) |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
176 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
177 |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
178 def getKeyName(self, k): |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
179 if not k.startswith(u'pubsub#'): |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
180 return u'pubsub#' + k |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
181 else: |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
182 return k |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
183 |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
184 def start(self): |
2290
d5c75be1c8c0
jp (pubsub/node/set): added checkURI to handle xmpp: URIs
Goffi <goffi@goffi.org>
parents:
2281
diff
changeset
|
185 common.checkURI(self.args) |
2199
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
186 self.host.bridge.psNodeConfigurationSet( |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
187 self.args.service, |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
188 self.args.node, |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
189 {self.getKeyName(k): v for k,v in self.args.fields}, |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
190 self.profile, |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
191 callback=self.psNodeConfigurationSetCb, |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
192 errback=self.psNodeConfigurationSetEb) |
ea0d0a4e2ad8
jp (pubsub/node): added set command
Goffi <goffi@goffi.org>
parents:
2197
diff
changeset
|
193 |
2197
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
194 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
195 class NodeAffiliationsGet(base.CommandBase): |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
196 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
197 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
198 base.CommandBase.__init__(self, host, 'get', use_output=C.OUTPUT_DICT, use_pubsub_node_req=True, help=_(u'retrieve node affiliations (for node owner)')) |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
199 self.need_loop=True |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
200 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
201 def add_parser_options(self): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
202 pass |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
203 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
204 def psNodeAffiliationsGetCb(self, affiliations): |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
205 self.output(affiliations) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
206 self.host.quit() |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
207 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
208 def psNodeAffiliationsGetEb(self, failure_): |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
209 self.disp(u"can't get node affiliations: {reason}".format( |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
210 reason=failure_), error=True) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
211 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
212 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
213 def start(self): |
2279
e2f96cd1887b
jp (cmd_pubsub): xmpp: uri handling, first draft
Goffi <goffi@goffi.org>
parents:
2276
diff
changeset
|
214 common.checkURI(self.args) |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
215 self.host.bridge.psNodeAffiliationsGet( |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
216 self.args.service, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
217 self.args.node, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
218 self.profile, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
219 callback=self.psNodeAffiliationsGetCb, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
220 errback=self.psNodeAffiliationsGetEb) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
221 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
222 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
223 class NodeAffiliationsSet(base.CommandBase): |
2207
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
224 |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
225 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
226 base.CommandBase.__init__(self, host, 'set', use_pubsub_node_req=True, use_verbose=True, help=_(u'set affiliations (for node owner)')) |
2207
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
227 self.need_loop=True |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
228 |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
229 def add_parser_options(self): |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
230 # XXX: we use optional argument syntax for a required one because list of list of 2 elements |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
231 # (uses to construct dicts) don't work with positional arguments |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
232 self.parser.add_argument("-a", |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
233 "--affiliation", |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
234 dest="affiliations", |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
235 metavar=('JID', 'AFFILIATION'), |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
236 required=True, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
237 type=base.unicode_decoder, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
238 action="append", |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
239 nargs=2, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
240 help=_(u"entity/affiliation couple(s)")) |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
241 |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
242 def psNodeAffiliationsSetCb(self): |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
243 self.disp(_(u"affiliations have been set"), 1) |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
244 self.host.quit() |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
245 |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
246 def psNodeAffiliationsSetEb(self, failure_): |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
247 self.disp(u"can't set node affiliations: {reason}".format( |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
248 reason=failure_), error=True) |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
249 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
250 |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
251 def start(self): |
2292
bd4d8c73b1d3
jp (pubsub/node/affiliations/set): call checkURI
Goffi <goffi@goffi.org>
parents:
2290
diff
changeset
|
252 common.checkURI(self.args) |
2207
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
253 affiliations = dict(self.args.affiliations) |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
254 self.host.bridge.psNodeAffiliationsSet( |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
255 self.args.service, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
256 self.args.node, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
257 affiliations, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
258 self.profile, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
259 callback=self.psNodeAffiliationsSetCb, |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
260 errback=self.psNodeAffiliationsSetEb) |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
261 |
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
262 |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
263 class NodeAffiliations(base.CommandBase): |
2207
d662bdd682b2
jp (pubsub/node) added pubsub/node/affiliations/set command
Goffi <goffi@goffi.org>
parents:
2204
diff
changeset
|
264 subcommands = (NodeAffiliationsGet, NodeAffiliationsSet) |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
265 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
266 def __init__(self, host): |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
267 super(NodeAffiliations, self).__init__(host, 'affiliations', use_profile=False, help=_(u'set or retrieve node affiliations')) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
268 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
269 |
2339
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
270 class NodeSubscriptionsGet(base.CommandBase): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
271 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
272 def __init__(self, host): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
273 base.CommandBase.__init__(self, host, 'get', use_output=C.OUTPUT_DICT, use_pubsub_node_req=True, help=_(u'retrieve node subscriptions (for node owner)')) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
274 self.need_loop=True |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
275 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
276 def add_parser_options(self): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
277 pass |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
278 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
279 def psNodeSubscriptionsGetCb(self, subscriptions): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
280 self.output(subscriptions) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
281 self.host.quit() |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
282 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
283 def psNodeSubscriptionsGetEb(self, failure_): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
284 self.disp(u"can't get node subscriptions: {reason}".format( |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
285 reason=failure_), error=True) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
286 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
287 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
288 def start(self): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
289 common.checkURI(self.args) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
290 self.host.bridge.psNodeSubscriptionsGet( |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
291 self.args.service, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
292 self.args.node, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
293 self.profile, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
294 callback=self.psNodeSubscriptionsGetCb, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
295 errback=self.psNodeSubscriptionsGetEb) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
296 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
297 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
298 class StoreSubscriptionAction(argparse.Action): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
299 """Action which handle subscription parameter for owner |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
300 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
301 list is given by pairs: jid and subscription state |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
302 if subscription state is not specified, it default to "subscribed" |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
303 """ |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
304 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
305 def __call__(self, parser, namespace, values, option_string): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
306 dest_dict = getattr(namespace, self.dest) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
307 while values: |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
308 jid_s = values.pop(0) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
309 try: |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
310 subscription = values.pop(0) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
311 except IndexError: |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
312 subscription = 'subscribed' |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
313 if subscription not in ALLOWED_SUBSCRIPTIONS_OWNER: |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
314 parser.error(_(u"subscription must be one of {}").format(u', '.join(ALLOWED_SUBSCRIPTIONS_OWNER))) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
315 dest_dict[jid_s] = subscription |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
316 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
317 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
318 class NodeSubscriptionsSet(base.CommandBase): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
319 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
320 def __init__(self, host): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
321 base.CommandBase.__init__(self, host, 'set', use_pubsub_node_req=True, use_verbose=True, help=_(u'set/modify subscriptions (for node owner)')) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
322 self.need_loop=True |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
323 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
324 def add_parser_options(self): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
325 # XXX: we use optional argument syntax for a required one because list of list of 2 elements |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
326 # (uses to construct dicts) don't work with positional arguments |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
327 self.parser.add_argument("-S", |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
328 "--subscription", |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
329 dest="subscriptions", |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
330 default={}, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
331 nargs='+', |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
332 metavar=('JID [SUSBSCRIPTION]'), |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
333 required=True, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
334 type=base.unicode_decoder, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
335 action=StoreSubscriptionAction, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
336 help=_(u"entity/subscription couple(s)")) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
337 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
338 def psNodeSubscriptionsSetCb(self): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
339 self.disp(_(u"subscriptions have been set"), 1) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
340 self.host.quit() |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
341 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
342 def psNodeSubscriptionsSetEb(self, failure_): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
343 self.disp(u"can't set node subscriptions: {reason}".format( |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
344 reason=failure_), error=True) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
345 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
346 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
347 def start(self): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
348 common.checkURI(self.args) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
349 self.host.bridge.psNodeSubscriptionsSet( |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
350 self.args.service, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
351 self.args.node, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
352 self.args.subscriptions, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
353 self.profile, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
354 callback=self.psNodeSubscriptionsSetCb, |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
355 errback=self.psNodeSubscriptionsSetEb) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
356 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
357 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
358 class NodeSubscriptions(base.CommandBase): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
359 subcommands = (NodeSubscriptionsGet, NodeSubscriptionsSet) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
360 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
361 def __init__(self, host): |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
362 super(NodeSubscriptions, self).__init__(host, 'subscriptions', use_profile=False, help=_(u'get or modify node subscriptions')) |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
363 |
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
364 |
2197
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
365 class Node(base.CommandBase): |
2339
d94e932be8b3
jp (pubsub/node): added subscriptions subcommand:
Goffi <goffi@goffi.org>
parents:
2320
diff
changeset
|
366 subcommands = (NodeInfo, NodeCreate, NodeDelete, NodeSet, NodeAffiliations, NodeSubscriptions) |
2197
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
367 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
368 def __init__(self, host): |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
369 super(Node, self).__init__(host, 'node', use_profile=False, help=_('node handling')) |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
370 |
e0e06391ce91
jp (pubsub): added pubsub/node/info command to retrieve node configuration
Goffi <goffi@goffi.org>
parents:
2195
diff
changeset
|
371 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
372 class Get(base.CommandBase): |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
373 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
374 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
375 base.CommandBase.__init__(self, host, 'get', use_output=C.OUTPUT_LIST_XML, use_pubsub_node_req=True, help=_(u'get pubsub item(s)')) |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
376 self.need_loop=True |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
377 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
378 def add_parser_options(self): |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
379 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, action='append', default=[], dest='items', |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
380 help=_(u"item(s) id(s) to get (default: request all items)")) |
2214
4e06cd44e667
jp (pubsub/get): --service is now optional argument, and sub_id now use "-S" short option
Goffi <goffi@goffi.org>
parents:
2207
diff
changeset
|
381 self.parser.add_argument("-S", "--sub-id", type=base.unicode_decoder, default=u'', |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
382 help=_(u"subscription id")) |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
383 self.parser.add_argument("-m", "--max", type=int, default=10, help=_(u"maximum number of items to get ({} to get all items)".format(C.NO_LIMIT))) |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
384 # TODO: a key(s) argument to select keys to display |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
385 # TODO: add MAM filters |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
386 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
387 |
2274
27f469d40a83
jp (pubsub): psItemGet has been renamed to psItemsGet as several items are gotten
Goffi <goffi@goffi.org>
parents:
2239
diff
changeset
|
388 def psItemsGetCb(self, ps_result): |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
389 self.output(ps_result[0]) |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
390 self.host.quit(C.EXIT_OK) |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
391 |
2274
27f469d40a83
jp (pubsub): psItemGet has been renamed to psItemsGet as several items are gotten
Goffi <goffi@goffi.org>
parents:
2239
diff
changeset
|
392 def psItemsGetEb(self, failure_): |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
393 self.disp(u"can't get pubsub items: {reason}".format( |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
394 reason=failure_), error=True) |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
395 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
396 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
397 def start(self): |
2279
e2f96cd1887b
jp (cmd_pubsub): xmpp: uri handling, first draft
Goffi <goffi@goffi.org>
parents:
2276
diff
changeset
|
398 common.checkURI(self.args) |
2274
27f469d40a83
jp (pubsub): psItemGet has been renamed to psItemsGet as several items are gotten
Goffi <goffi@goffi.org>
parents:
2239
diff
changeset
|
399 self.host.bridge.psItemsGet( |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
400 self.args.service, |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
401 self.args.node, |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
402 self.args.max, |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
403 self.args.items, |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
404 self.args.sub_id, |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
405 {}, |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
406 self.profile, |
2274
27f469d40a83
jp (pubsub): psItemGet has been renamed to psItemsGet as several items are gotten
Goffi <goffi@goffi.org>
parents:
2239
diff
changeset
|
407 callback=self.psItemsGetCb, |
27f469d40a83
jp (pubsub): psItemGet has been renamed to psItemsGet as several items are gotten
Goffi <goffi@goffi.org>
parents:
2239
diff
changeset
|
408 errback=self.psItemsGetEb) |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
409 |
2281
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
410 class Delete(base.CommandBase): |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
411 |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
412 def __init__(self, host): |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
413 base.CommandBase.__init__(self, host, 'delete', use_pubsub_node_req=True, help=_(u'delete an item')) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
414 self.need_loop=True |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
415 |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
416 def add_parser_options(self): |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
417 self.parser.add_argument("item", nargs='?', type=base.unicode_decoder, help=_(u"item to delete")) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
418 self.parser.add_argument("-f", "--force", action='store_true', help=_(u"delete without confirmation")) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
419 self.parser.add_argument("-n", "--notify", action='store_true', help=_(u"notify deletion")) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
420 |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
421 def psItemsDeleteCb(self): |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
422 self.disp(_(u'item {item_id} has been deleted').format(item_id=self.args.item)) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
423 self.host.quit(C.EXIT_OK) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
424 |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
425 def start(self): |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
426 common.checkURI(self.args) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
427 if not self.args.item: |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
428 self.parser.error(_(u"You need to specify an item to delete")) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
429 if not self.args.force: |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
430 message = _(u"Are you sure to delete item {item_id} ?").format(item_id=self.args.item) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
431 res = raw_input("{} (y/N)? ".format(message)) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
432 if res not in ("y", "Y"): |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
433 self.disp(_(u"Item deletion cancelled")) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
434 self.host.quit(2) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
435 self.host.bridge.psRetractItem( |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
436 self.args.service, |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
437 self.args.node, |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
438 self.args.item, |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
439 self.args.notify, |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
440 self.profile, |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
441 callback=self.psItemsDeleteCb, |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
442 errback=partial(self.errback, |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
443 msg=_(u"can't delete item: {}"), |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
444 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
4af1805cc6df
jp (pubsub/delete): delete command implementation (to delete an item)
Goffi <goffi@goffi.org>
parents:
2280
diff
changeset
|
445 |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
446 |
2275
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
447 class Edit(base.CommandBase, common.BaseEdit): |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
448 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
449 def __init__(self, host): |
2276
5cd45a79775b
jp (common): added --last-item to take last item when no item id is found/given
Goffi <goffi@goffi.org>
parents:
2275
diff
changeset
|
450 base.CommandBase.__init__(self, host, 'edit', use_verbose=True, use_pubsub=True, help=_(u'edit an existing or new pubsub item')) |
2275
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
451 common.BaseEdit.__init__(self, self.host, PUBSUB_TMP_DIR) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
452 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
453 def add_parser_options(self): |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
454 self.parser.add_argument("item", type=base.unicode_decoder, nargs='?', default=u'new', help=_(u"URL of the item to edit, or keyword")) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
455 common.BaseEdit.add_parser_options(self) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
456 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
457 def edit(self, content_file_path, content_file_obj): |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
458 # we launch editor |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
459 self.runEditor("pubsub_editor_args", content_file_path, content_file_obj) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
460 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
461 def publish(self, content): |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
462 published_id = self.host.bridge.psItemSend(self.pubsub_service, self.pubsub_node, content, self.pubsub_item or '', {}, self.profile) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
463 if published_id: |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
464 self.disp(u"Item published at {pub_id}".format(pub_id=published_id)) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
465 else: |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
466 self.disp(u"Item published") |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
467 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
468 def getItemData(self, service, node, item): |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
469 try: |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
470 from lxml import etree |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
471 except ImportError: |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
472 self.disp(u"lxml module must be installed to use edit, please install it with \"pip install lxml\"", error=True) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
473 self.host.quit(1) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
474 items = [item] if item is not None else [] |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
475 item_raw = self.host.bridge.psItemsGet(service, node, 1, items, "", {}, self.profile)[0][0] |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
476 parser = etree.XMLParser(remove_blank_text=True) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
477 item_elt = etree.fromstring(item_raw, parser) |
2280
4bc9a2c2d6c9
jp (pubsub, common): fixed last item edition (keep item id instead of creating a new one)
Goffi <goffi@goffi.org>
parents:
2279
diff
changeset
|
478 item_id = item_elt.get('id') |
2275
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
479 try: |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
480 payload = item_elt[0] |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
481 except IndexError: |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
482 self.disp(_(u'Item has not payload'), 1) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
483 return u'' |
2280
4bc9a2c2d6c9
jp (pubsub, common): fixed last item edition (keep item id instead of creating a new one)
Goffi <goffi@goffi.org>
parents:
2279
diff
changeset
|
484 return etree.tostring(payload, encoding="unicode", pretty_print=True), item_id |
2275
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
485 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
486 def start(self): |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
487 self.pubsub_service, self.pubsub_node, self.pubsub_item, content_file_path, content_file_obj = self.getItemPath(self.args.item) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
488 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
489 self.edit(content_file_path, content_file_obj) |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
490 |
64e99bf0dfa2
jp (pubsub/edit): new edit subcommand, which work in a same way as for blog
Goffi <goffi@goffi.org>
parents:
2274
diff
changeset
|
491 |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
492 class Affiliations(base.CommandBase): |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
493 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
494 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
495 base.CommandBase.__init__(self, host, 'affiliations', use_output=C.OUTPUT_DICT, use_pubsub=True, help=_(u'retrieve all affiliations on a service')) |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
496 self.need_loop=True |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
497 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
498 def add_parser_options(self): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
499 pass |
2204
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
500 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
501 def psAffiliationsGetCb(self, affiliations): |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
502 self.output(affiliations) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
503 self.host.quit() |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
504 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
505 def psAffiliationsGetEb(self, failure_): |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
506 self.disp(u"can't get node affiliations: {reason}".format( |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
507 reason=failure_), error=True) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
508 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
509 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
510 def start(self): |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
511 self.host.bridge.psAffiliationsGet( |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
512 self.args.service, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
513 self.args.node, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
514 self.profile, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
515 callback=self.psAffiliationsGetCb, |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
516 errback=self.psAffiliationsGetEb) |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
517 |
afc703419186
jp (pubsub): added affiliations and node/affiliations/get:
Goffi <goffi@goffi.org>
parents:
2199
diff
changeset
|
518 |
2316 | 519 class Search(base.CommandBase): |
520 """this command to a search without using MAM, i.e. by checking every items if dound by itself, so it may be heavy in resources both for server and client""" | |
521 RE_FLAGS = re.MULTILINE | re.UNICODE | |
522 EXEC_ACTIONS = (u'exec', u'external') | |
523 | |
524 def __init__(self, host): | |
525 base.CommandBase.__init__(self, host, 'search', use_output=C.OUTPUT_XML, use_pubsub=True, use_verbose=True, help=_(u'search items corresponding to filters')) | |
526 self.need_loop=True | |
527 | |
528 @property | |
529 def etree(self): | |
530 """load lxml.etree only if needed""" | |
531 if self._etree is None: | |
532 from lxml import etree | |
533 self._etree = etree | |
534 return self._etree | |
535 | |
536 def filter_opt(self, value, type_): | |
537 value = base.unicode_decoder(value) | |
538 return (type_, value) | |
539 | |
540 def filter_flag(self, value, type_): | |
541 value = C.bool(value) | |
542 return (type_, value) | |
543 | |
544 def add_parser_options(self): | |
545 self.parser.add_argument("-i", "--item", action="append", default=[], dest='items', type=base.unicode_decoder, help=_(u"item id(s)")) | |
546 self.parser.add_argument("-D", "--max-depth", type=int, default=0, help=_(u"maximum depth of recursion (will search linked nodes if > 0, default: 0)")) | |
547 self.parser.add_argument("-m", "--max", type=int, default=30, help=_(u"maximum number of items to get per node ({} to get all items, default: 30)".format(C.NO_LIMIT))) | |
548 self.parser.add_argument("-N", "--namespace", action='append', nargs=2, default=[], | |
549 metavar="NAME NAMESPACE", help=_(u"namespace to use for xpath")) | |
550 | |
551 # filters | |
552 filter_text = partial(self.filter_opt, type_=u'text') | |
553 filter_re = partial(self.filter_opt, type_=u'regex') | |
554 filter_xpath = partial(self.filter_opt, type_=u'xpath') | |
555 filter_python = partial(self.filter_opt, type_=u'python') | |
556 filters = self.parser.add_argument_group(_(u'filters'), _(u'only items corresponding to following filters will be kept')) | |
557 filters.add_argument("-t", "--text", | |
558 action='append', dest='filters', type=filter_text, | |
559 metavar='TEXT', | |
560 help=_(u"full text filter, item must contain this string (XML included)")) | |
561 filters.add_argument("-r", "--regex", | |
562 action='append', dest='filters', type=filter_re, | |
563 metavar='EXPRESSION', | |
564 help=_(u"like --text but using a regular expression")) | |
565 filters.add_argument("-x", "--xpath", | |
566 action='append', dest='filters', type=filter_xpath, | |
567 metavar='XPATH', | |
568 help=_(u"filter items which has elements matching this xpath")) | |
569 filters.add_argument("-P", "--python", | |
570 action='append', dest='filters', type=filter_python, | |
571 metavar='PYTHON_CODE', | |
572 help=_(u'Python expression which much return a bool (True to keep item, False to reject it). "item" is raw text item, "item_xml" is lxml\'s etree.Element')) | |
573 | |
574 # filters flags | |
575 flag_case = partial(self.filter_flag, type_=u'ignore-case') | |
576 flag_invert = partial(self.filter_flag, type_=u'invert') | |
577 flag_dotall = partial(self.filter_flag, type_=u'dotall') | |
578 flag_matching = partial(self.filter_flag, type_=u'only-matching') | |
579 flags = self.parser.add_argument_group(_(u'filters flags'), _(u'filters modifiers (change behaviour of following filters)')) | |
580 flags.add_argument("-C", "--ignore-case", | |
581 action='append', dest='filters', type=flag_case, | |
582 const=('ignore-case', True), nargs='?', | |
583 metavar='BOOLEAN', | |
584 help=_(u"(don't) ignore case in following filters (default: case sensitive)")) | |
585 flags.add_argument("-I", "--invert", | |
586 action='append', dest='filters', type=flag_invert, | |
587 const=('invert', True), nargs='?', | |
588 metavar='BOOLEAN', | |
589 help=_(u"(don't) invert effect of following filters (default: don't invert)")) | |
590 flags.add_argument("-A", "--dot-all", | |
591 action='append', dest='filters', type=flag_dotall, | |
592 const=('dotall', True), nargs='?', | |
593 metavar='BOOLEAN', | |
594 help=_(u"(don't) use DOTALL option for regex (default: don't use)")) | |
595 flags.add_argument("-o", "--only-matching", | |
596 action='append', dest='filters', type=flag_matching, | |
597 const=('only-matching', True), nargs='?', | |
598 metavar='BOOLEAN', | |
599 help=_(u"keep only the matching part of the item")) | |
600 | |
601 # action | |
602 self.parser.add_argument("action", | |
603 default="print", | |
604 nargs='?', | |
605 choices=('print', 'exec', 'external'), | |
606 help=_(u"action to do on found items (default: print)")) | |
607 self.parser.add_argument("command", nargs=argparse.REMAINDER) | |
608 | |
609 def psItemsGetEb(self, failure_, service, node): | |
610 self.disp(u"can't get pubsub items at {service} (node: {node}): {reason}".format( | |
611 service=service, | |
612 node=node, | |
613 reason=failure_), error=True) | |
614 self.to_get -= 1 | |
615 | |
616 def getItems(self, depth, service, node, items): | |
617 search = partial(self.search, depth=depth) | |
618 errback = partial(self.psItemsGetEb, service=service, node=node) | |
619 self.host.bridge.psItemsGet( | |
620 service, | |
621 node, | |
622 self.args.max, | |
623 [], | |
624 "", | |
625 {}, | |
626 self.profile, | |
627 callback=search, | |
628 errback=errback | |
629 ) | |
630 self.to_get += 1 | |
631 | |
632 def _checkPubsubURL(self, match, found_nodes): | |
633 """check that the matched URL is an xmpp: one | |
634 | |
635 @param found_nodes(list[unicode]): found_nodes | |
636 this list will be filled while xmpp: URIs are discovered | |
637 """ | |
638 url = match.group(0) | |
639 if url.startswith(u'xmpp'): | |
640 try: | |
641 url_data = uri.parseXMPPUri(url) | |
642 except ValueError: | |
643 return | |
644 if url_data[u'type'] == u'pubsub': | |
645 found_node = {u'service': url_data[u'path'], | |
646 u'node': url_data[u'node']} | |
647 if u'item' in url_data: | |
648 found_node[u'item'] = url_data[u'item'] | |
649 found_nodes.append(found_node) | |
650 | |
651 def getSubNodes(self, item, depth): | |
652 """look for pubsub URIs in item, and getItems on the linked nodes""" | |
653 found_nodes = [] | |
654 checkURI = partial(self._checkPubsubURL, found_nodes=found_nodes) | |
655 strings.RE_URL.sub(checkURI, item) | |
656 for data in found_nodes: | |
657 self.getItems(depth+1, | |
658 data[u'service'], | |
659 data[u'node'], | |
660 [data[u'item']] if u'item' in data else [] | |
661 ) | |
662 | |
663 def parseXml(self, item): | |
664 try: | |
665 return self.etree.fromstring(item) | |
666 except self.etree.XMLSyntaxError: | |
667 self.disp(_(u"item doesn't looks like XML, you have probably used --only-matching somewhere before and we have no more XML"), error=True) | |
668 self.host.quit(C.EXIT_BAD_ARG) | |
669 | |
670 def filter(self, item): | |
671 """apply filters given on command line | |
672 | |
673 if only-matching is used, item may be modified | |
674 @return (tuple[bool, unicode]): a tuple with: | |
675 - keep: True if item passed the filters | |
676 - item: it is returned in case of modifications | |
677 """ | |
678 ignore_case = False | |
679 invert = False | |
680 dotall = False | |
681 only_matching = False | |
682 item_xml = None | |
683 for type_, value in self.args.filters: | |
684 keep = True | |
685 | |
686 ## filters | |
687 | |
688 if type_ == u'text': | |
689 if ignore_case: | |
690 if value.lower() not in item.lower(): | |
691 keep = False | |
692 else: | |
693 if value not in item: | |
694 keep = False | |
695 if keep and only_matching: | |
696 # doesn't really make sens to keep a fixed string | |
697 # so we raise an error | |
698 self.host.disp(_(u"--only-matching used with fixed --text string, are you sure?"), error=True) | |
699 self.host.quit(C.EXIT_BAD_ARG) | |
700 elif type_ == u'regex': | |
701 flags = self.RE_FLAGS | |
702 if ignore_case: | |
703 flags |= re.IGNORECASE | |
704 if dotall: | |
705 flags |= re.DOTALL | |
706 match = re.search(value, item, flags) | |
707 keep = match != None | |
708 if keep and only_matching: | |
709 item = match.group() | |
710 item_xml = None | |
711 elif type_ == u'xpath': | |
712 if item_xml is None: | |
713 item_xml = self.parseXml(item) | |
714 try: | |
715 elts = item_xml.xpath(value, namespaces=self.args.namespace) | |
716 except self.etree.XPathEvalError as e: | |
717 self.disp(_(u"can't use xpath: {reason}").format(reason=e), error=True) | |
718 self.host.quit(C.EXIT_BAD_ARG) | |
719 keep = bool(elts) | |
720 if keep and only_matching: | |
721 item_xml = elts[0] | |
722 try: | |
723 item = self.etree.tostring(item_xml, encoding='unicode') | |
724 except TypeError: | |
725 # we have a string only, not an element | |
726 item = unicode(item_xml) | |
727 item_xml = None | |
728 elif type_ == u'python': | |
729 if item_xml is None: | |
730 item_xml = self.parseXml(item) | |
731 cmd_ns = {u'item': item, | |
732 u'item_xml': item_xml | |
733 } | |
734 try: | |
735 keep = eval(value, cmd_ns) | |
736 except SyntaxError as e: | |
737 self.disp(unicode(e), error=True) | |
738 self.host.quit(C.EXIT_BAD_ARG) | |
739 | |
740 ## flags | |
741 | |
742 elif type_ == u'ignore-case': | |
743 ignore_case = value | |
744 elif type_ == u'invert': | |
745 invert = value | |
746 # we need to continue, else loop would end here | |
747 continue | |
748 elif type_ == u'dotall': | |
749 dotall = value | |
750 elif type_ == u'only-matching': | |
751 only_matching = value | |
752 else: | |
753 raise exceptions.InternalError(_(u"unknown filter type {type}").format(type=type_)) | |
754 | |
755 if invert: | |
756 keep = not keep | |
757 if not keep: | |
758 return False, item | |
759 | |
760 return True, item | |
761 | |
762 def doItemAction(self, item, metadata): | |
763 """called when item has been kepts and the action need to be done | |
764 | |
765 @param item(unicode): accepted item | |
766 """ | |
767 action = self.args.action | |
768 if action == u'print' or self.host.verbosity > 0: | |
769 try: | |
770 self.output(item) | |
771 except self.etree.XMLSyntaxError: | |
772 # item is not valid XML, but a string | |
773 # can happen when --only-matching is used | |
774 self.disp(item) | |
775 if action in self.EXEC_ACTIONS: | |
776 item_elt = self.parseXml(item) | |
777 if action == u'exec': | |
778 use = {'service': metadata[u'service'], | |
779 'node': metadata[u'node'], | |
780 'item': item_elt.get('id'), | |
2318
ddb67c186f61
jp (pubsub/search): profile is transmited to subcommand for "exec" action
Goffi <goffi@goffi.org>
parents:
2317
diff
changeset
|
781 'profile': self.profile |
2316 | 782 } |
2317
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
783 # we need to send a copy of self.args.command |
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
784 # else it would be modified |
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
785 parser_args, use_args = arg_tools.get_use_args(self.host, |
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
786 self.args.command, |
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
787 use, |
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
788 verbose=self.host.verbosity > 1 |
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
789 ) |
f4e05600577b
jp (arg_tools): args is not modified anymore in get_use_args + fixed args returned + parser_args are returned separatly (return is now a tuple)
Goffi <goffi@goffi.org>
parents:
2316
diff
changeset
|
790 cmd_args = sys.argv[0:1] + parser_args + use_args |
2316 | 791 else: |
792 cmd_args = self.args.command | |
793 | |
794 | |
795 self.disp(u'COMMAND: {command}'.format( | |
796 command = u' '.join([arg_tools.escape(a) for a in cmd_args])), 2) | |
797 if action == u'exec': | |
798 ret = subprocess.call(cmd_args) | |
799 else: | |
800 p = subprocess.Popen(cmd_args, stdin=subprocess.PIPE) | |
2320
f4a0723042ee
jp (pubsub/search): fixed encoding for stdin in external commands
Goffi <goffi@goffi.org>
parents:
2318
diff
changeset
|
801 p.communicate(item.encode('utf-8')) |
2316 | 802 ret = p.wait() |
803 if ret != 0: | |
804 self.disp(A.color(C.A_FAILURE, _(u"executed command failed with exit code {code}").format(code=ret))) | |
805 | |
806 def search(self, items_data, depth): | |
807 """callback of getItems | |
808 | |
809 this method filters items, get sub nodes if needed, | |
810 do the requested action, and exit the command when everything is done | |
811 @param items_data(tuple): result of getItems | |
812 @param depth(int): current depth level | |
813 0 for first node, 1 for first children, and so on | |
814 """ | |
815 items, metadata = items_data | |
816 for item in items: | |
817 if depth < self.args.max_depth: | |
818 self.getSubNodes(item, depth) | |
819 keep, item = self.filter(item) | |
820 if not keep: | |
821 continue | |
822 self.doItemAction(item, metadata) | |
823 | |
824 # we check if we got all getItems results | |
825 self.to_get -= 1 | |
826 if self.to_get == 0: | |
827 # yes, we can quit | |
828 self.host.quit() | |
829 assert self.to_get > 0 | |
830 | |
831 def start(self): | |
832 if self.args.command: | |
833 if self.args.action not in self.EXEC_ACTIONS: | |
834 self.parser.error(_(u"Command can only be used with {actions} actions").format( | |
835 actions=u', '.join(self.EXEC_ACTIONS))) | |
836 else: | |
837 if self.args.action in self.EXEC_ACTIONS: | |
838 self.parser.error(_(u"you need to specify a command to execute")) | |
839 if not self.args.node: | |
840 # TODO: handle get service affiliations when node is not set | |
841 self.parser.error(_(u"empty node is not handled yet")) | |
842 # to_get is increased on each get and decreased on each answer | |
843 # when it reach 0 again, the command is finished | |
844 self.to_get = 0 | |
845 self._etree = None | |
846 if self.args.filters is None: | |
847 self.args.filters = [] | |
848 self.args.namespace = dict(self.args.namespace + [('pubsub', "http://jabber.org/protocol/pubsub")]) | |
849 common.checkURI(self.args) | |
850 self.getItems(0, self.args.service, self.args.node, self.args.items) | |
851 | |
852 | |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
853 class Uri(base.CommandBase): |
2224
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
854 |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
855 def __init__(self, host): |
2235
4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
Goffi <goffi@goffi.org>
parents:
2224
diff
changeset
|
856 base.CommandBase.__init__(self, host, 'uri', use_profile=False, use_pubsub_node_req=True, help=_(u'build URI')) |
2224
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
857 self.need_loop=True |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
858 |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
859 def add_parser_options(self): |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
860 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, help=_(u"item to link")) |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
861 self.parser.add_argument("-p", "--profile", type=base.unicode_decoder, default=C.PROF_KEY_DEFAULT, help=_(u"profile (used when no server is specified)")) |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
862 |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
863 def display_uri(self, jid_): |
2239
17502e74c046
jp (pubsub/uri): fixed URI generation
Goffi <goffi@goffi.org>
parents:
2235
diff
changeset
|
864 uri_args = {} |
2224
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
865 if not self.args.service: |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
866 self.args.service = jid.JID(jid_).bare |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
867 |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
868 for key in ('node', 'service', 'item'): |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
869 value = getattr(self.args, key) |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
870 if key == 'service': |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
871 key = 'path' |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
872 if value: |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
873 uri_args[key] = value |
2239
17502e74c046
jp (pubsub/uri): fixed URI generation
Goffi <goffi@goffi.org>
parents:
2235
diff
changeset
|
874 self.disp(uri.buildXMPPUri(u'pubsub', **uri_args)) |
2224
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
875 self.host.quit() |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
876 |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
877 def start(self): |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
878 if not self.args.service: |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
879 self.host.bridge.asyncGetParamA( |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
880 u'JabberID', |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
881 u'Connection', |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
882 profile_key=self.args.profile, |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
883 callback=self.display_uri, |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
884 errback=partial(self.errback, |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
885 msg=_(u"can't retrieve jid: {}"), |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
886 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
887 else: |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
888 self.display_uri(None) |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
889 |
87fcd4a7c7e4
jp (pubsub): added uri command to build pubsub URI
Goffi <goffi@goffi.org>
parents:
2221
diff
changeset
|
890 |
2308
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
891 class HookCreate(base.CommandBase): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
892 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
893 def __init__(self, host): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
894 base.CommandBase.__init__(self, host, 'create', use_pubsub_node_req=True, help=_(u'create a Pubsub hook')) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
895 self.need_loop=True |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
896 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
897 def add_parser_options(self): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
898 self.parser.add_argument('-t', '--type', default=u'python', choices=('python', 'python_file', 'python_code'), help=_(u"hook type")) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
899 self.parser.add_argument('-P', '--persistent', action='store_true', help=_(u"make hook persistent across restarts")) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
900 self.parser.add_argument("hook_arg", type=base.unicode_decoder, help=_(u"argument of the hook (depend of the type)")) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
901 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
902 @staticmethod |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
903 def checkArgs(self): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
904 if self.args.type == u'python_file': |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
905 self.args.hook_arg = os.path.abspath(self.args.hook_arg) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
906 if not os.path.isfile(self.args.hook_arg): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
907 self.parser.error(_(u"{path} is not a file").format(path=self.args.hook_arg)) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
908 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
909 def start(self): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
910 common.checkURI(self.args) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
911 self.checkArgs(self) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
912 self.host.bridge.psHookAdd( |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
913 self.args.service, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
914 self.args.node, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
915 self.args.type, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
916 self.args.hook_arg, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
917 self.args.persistent, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
918 self.profile, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
919 callback=self.host.quit, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
920 errback=partial(self.errback, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
921 msg=_(u"can't create hook: {}"), |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
922 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
923 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
924 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
925 class HookDelete(base.CommandBase): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
926 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
927 def __init__(self, host): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
928 base.CommandBase.__init__(self, host, 'delete', use_pubsub_node_req=True, help=_(u'delete a Pubsub hook')) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
929 self.need_loop=True |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
930 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
931 def add_parser_options(self): |
2316 | 932 self.parser.add_argument('-t', '--type', default=u'', choices=('', 'python', 'python_file', 'python_code'), help=_(u"hook type to remove, empty to remove all (default: remove all)")) |
933 self.parser.add_argument('-a', '--arg', dest='hook_arg', type=base.unicode_decoder, default=u'', help=_(u"argument of the hook to remove, empty to remove all (default: remove all)")) | |
2308
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
934 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
935 def psHookRemoveCb(self, nb_deleted): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
936 self.disp(_(u'{nb_deleted} hook(s) have been deleted').format( |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
937 nb_deleted = nb_deleted)) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
938 self.host.quit() |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
939 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
940 def start(self): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
941 common.checkURI(self.args) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
942 HookCreate.checkArgs(self) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
943 self.host.bridge.psHookRemove( |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
944 self.args.service, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
945 self.args.node, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
946 self.args.type, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
947 self.args.hook_arg, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
948 self.profile, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
949 callback=self.psHookRemoveCb, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
950 errback=partial(self.errback, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
951 msg=_(u"can't delete hook: {}"), |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
952 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
953 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
954 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
955 class HookList(base.CommandBase): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
956 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
957 def __init__(self, host): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
958 base.CommandBase.__init__(self, host, 'list', use_output=C.OUTPUT_LIST_DICT, help=_(u'list hooks of a profile')) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
959 self.need_loop = True |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
960 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
961 def add_parser_options(self): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
962 pass |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
963 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
964 def psHookListCb(self, data): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
965 if not data: |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
966 self.disp(_(u'No hook found.')) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
967 self.output(data) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
968 self.host.quit() |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
969 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
970 def start(self): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
971 self.host.bridge.psHookList( |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
972 self.profile, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
973 callback=self.psHookListCb, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
974 errback=partial(self.errback, |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
975 msg=_(u"can't list hooks: {}"), |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
976 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
977 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
978 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
979 class Hook(base.CommandBase): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
980 subcommands = (HookCreate, HookDelete, HookList) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
981 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
982 def __init__(self, host): |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
983 super(Hook, self).__init__(host, 'hook', use_profile=False, help=_('trigger action on Pubsub notifications')) |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
984 |
0b21d87c91cf
jp (pubsub/hook): added create/delete/list hook command to handle new Pubsub hook feature
Goffi <goffi@goffi.org>
parents:
2292
diff
changeset
|
985 |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
986 class Pubsub(base.CommandBase): |
2316 | 987 subcommands = (Get, Delete, Edit, Node, Affiliations, Search, Hook, Uri) |
2191
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
988 |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
989 def __init__(self, host): |
a1a8233f89e8
jp(pubsub/get): pubsub/get command, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
990 super(Pubsub, self).__init__(host, 'pubsub', use_profile=False, help=_('PubSub nodes/items management')) |