Mercurial > libervia-backend
annotate frontends/src/jp/cmd_forums.py @ 2509:d485e9416493
core (memory/cache): common cache:
host has now a common_cache attribute for data which can be shared between profiles. client.cache is for private data
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Mar 2018 17:40:09 +0100 |
parents | 512c443a58ba |
children | 772447ec070f |
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): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 base.CommandBase.__init__(self, host, 'edit', use_pubsub=True, use_verbose=True, help=_(u'edit forums')) |
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 common.BaseEdit.add_parser_options(self) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 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
|
45 help=_(u"forum key (DEFAULT: default forums)")) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 def getTmpSuff(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 """return suffix used for content file""" |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 return u'json' |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 def forumsSetCb(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 self.disp(_(u'forums have been edited'), 1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 self.host.quit() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 def publish(self, forums_raw): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 self.host.bridge.forumsSet( |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 forums_raw, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 self.args.service, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 self.args.node, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 self.args.key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 self.profile, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 callback=self.forumsSetCb, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 errback=partial(self.errback, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 msg=_(u"can't set forums: {}"), |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 def forumsGetCb(self, forums_json): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 content_file_obj, content_file_path = self.getTmpFile() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 forums_json = forums_json.strip() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 if forums_json: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 # we loads and dumps to have pretty printed json |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 forums = json.loads(forums_json) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 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
|
74 content_file_obj.seek(0) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 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
|
76 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 def forumsGetEb(self, failure_): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 # 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
|
79 if failure_.condition == u'item-not-found': |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 self.forumsGetCb(u'') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 self.errback(failure_, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 msg=_(u"can't get forums structure: {}"), |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 exit_code=C.EXIT_BRIDGE_ERRBACK) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 def start(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 common.checkURI(self.args) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 self.host.bridge.forumsGet( |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 self.args.service, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 self.args.node, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 self.args.key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 self.profile, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 callback=self.forumsGetCb, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 errback=self.forumsGetEb) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 |
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 class Get(base.CommandBase): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 def __init__(self, host): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 extra_outputs = {'default': self.default_output} |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 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
|
102 self.need_loop=True |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 def add_parser_options(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 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
|
106 help=_(u"forum key (DEFAULT: default forums)")) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 def default_output(self, forums, level=0): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 for forum in forums: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 keys = list(forum.keys()) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 keys.sort() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 try: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 keys.remove(u'title') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 except ValueError: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 pass |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 keys.insert(0, u'title') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 try: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 keys.remove(u'sub-forums') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 except ValueError: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 pass |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 keys.append(u'sub-forums') |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 for key in keys: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 value = forum[key] |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 if key == 'sub-forums': |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 self.default_output(value, level+1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 else: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 if self.host.verbosity < 1 and key != u'title': |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 continue |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 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
|
133 self.disp(A.color(level * 4 * u' ', |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 head_color, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 A.RESET, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 u': ', |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 value)) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 def forumsGetCb(self, forums_raw): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 if not forums_raw: |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 self.disp(_(u'no schema found'), 1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 self.host.quit(1) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 forums = json.loads(forums_raw) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 self.output(forums) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 self.host.quit() |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 def start(self): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 common.checkURI(self.args) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 self.host.bridge.forumsGet( |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 self.args.service, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 self.args.node, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 self.args.key, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 self.profile, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 callback=self.forumsGetCb, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 errback=partial(self.errback, |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 msg=_(u"can't get forums: {}"), |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 exit_code=C.EXIT_BRIDGE_ERRBACK)) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 |
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 class Forums(base.CommandBase): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 subcommands = (Get, Edit) |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 def __init__(self, host): |
512c443a58ba
jp (forums): forums handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 super(Forums, self).__init__(host, 'forums', use_profile=False, help=_(u'Forums structure edition')) |