Mercurial > libervia-backend
annotate frontends/src/jp/cmd_forums.py @ 2558:501b0f827f63
jp (merge-request,common): fixed URIFinder when metadata are not needed:
new "meta_map" attribute which allows to select destination argument name, or to discard unused metadata.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Apr 2018 08:23:22 +0200 |
parents | 772447ec070f |
children |
rev | line source |
---|---|
2485
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # jp: a SàT command line tool |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 import base |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 from sat.core.i18n import _ |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from sat_frontends.jp.constants import Const as C |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from sat_frontends.jp import common |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from sat.tools.common.ansi import ANSI as A |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from functools import partial |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 import json |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 __commands__ = ["Forums"] |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 FORUMS_TMP_DIR = u"forums" |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 class Edit(base.CommandBase, common.BaseEdit): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 use_items=False |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 def __init__(self, host): |
2532 | 38 base.CommandBase.__init__(self, host, 'edit', use_pubsub=True, use_draft=True, use_verbose=True, help=_(u'edit forums')) |
2485
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 common.BaseEdit.__init__(self, self.host, FORUMS_TMP_DIR) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 self.need_loop=True |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 def add_parser_options(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 self.parser.add_argument("-k", "--key", type=base.unicode_decoder, default=u'', |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 help=_(u"forum key (DEFAULT: default forums)")) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 def getTmpSuff(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 """return suffix used for content file""" |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 return u'json' |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 def forumsSetCb(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 self.disp(_(u'forums have been edited'), 1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 self.host.quit() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 def publish(self, forums_raw): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 self.host.bridge.forumsSet( |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 forums_raw, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 self.args.service, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 self.args.node, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 self.args.key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 self.profile, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 callback=self.forumsSetCb, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 errback=partial(self.errback, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 msg=_(u"can't set forums: {}"), |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 def forumsGetCb(self, forums_json): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 content_file_obj, content_file_path = self.getTmpFile() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 forums_json = forums_json.strip() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 if forums_json: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 # we loads and dumps to have pretty printed json |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 forums = json.loads(forums_json) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 json.dump(forums, content_file_obj, ensure_ascii=False, indent=4) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 content_file_obj.seek(0) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 self.runEditor("forums_editor_args", content_file_path, content_file_obj) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 def forumsGetEb(self, failure_): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 # FIXME: error handling with bridge is broken, need to be properly fixed |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 if failure_.condition == u'item-not-found': |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 self.forumsGetCb(u'') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 self.errback(failure_, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 msg=_(u"can't get forums structure: {}"), |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 exit_code=C.EXIT_BRIDGE_ERRBACK) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 def start(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 self.host.bridge.forumsGet( |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 self.args.service, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 self.args.node, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 self.args.key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 self.profile, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 callback=self.forumsGetCb, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 errback=self.forumsGetEb) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 class Get(base.CommandBase): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 def __init__(self, host): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 extra_outputs = {'default': self.default_output} |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 base.CommandBase.__init__(self, host, 'get', use_output=C.OUTPUT_COMPLEX, extra_outputs=extra_outputs, use_pubsub=True, use_verbose=True, help=_(u'get forums structure')) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 self.need_loop=True |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 def add_parser_options(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 self.parser.add_argument("-k", "--key", type=base.unicode_decoder, default=u'', |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 help=_(u"forum key (DEFAULT: default forums)")) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 def default_output(self, forums, level=0): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 for forum in forums: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 keys = list(forum.keys()) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 keys.sort() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 try: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 keys.remove(u'title') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 except ValueError: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 pass |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 keys.insert(0, u'title') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 try: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 keys.remove(u'sub-forums') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 except ValueError: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 pass |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 keys.append(u'sub-forums') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 for key in keys: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 value = forum[key] |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 if key == 'sub-forums': |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 self.default_output(value, level+1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 if self.host.verbosity < 1 and key != u'title': |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 continue |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 head_color = C.A_LEVEL_COLORS[level % len(C.A_LEVEL_COLORS)] |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 self.disp(A.color(level * 4 * u' ', |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 head_color, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 A.RESET, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 u': ', |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 value)) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 def forumsGetCb(self, forums_raw): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 if not forums_raw: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 self.disp(_(u'no schema found'), 1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 self.host.quit(1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 forums = json.loads(forums_raw) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 self.output(forums) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 self.host.quit() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 def start(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 self.host.bridge.forumsGet( |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 self.args.service, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 self.args.node, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 self.args.key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 self.profile, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 callback=self.forumsGetCb, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 errback=partial(self.errback, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 msg=_(u"can't get forums: {}"), |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 class Forums(base.CommandBase): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 subcommands = (Get, Edit) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 def __init__(self, host): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 super(Forums, self).__init__(host, 'forums', use_profile=False, help=_(u'Forums structure edition')) |