annotate frontends/src/jp/cmd_merge_request.py @ 2455:7b02372f8734

template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
author Goffi <goffi@goffi.org>
date Mon, 04 Dec 2017 00:45:07 +0100
parents 124f5db998f2
children 0046283a285d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # jp: a SàT command line tool
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009-2017 Jérôme Poisson (goffi@goffi.org)
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 import base
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.i18n import _
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from sat_frontends.jp import common
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from sat_frontends.jp.constants import Const as C
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from functools import partial
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 import os.path
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 __commands__ = ["MergeRequest"]
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 class Set(base.CommandBase):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 def __init__(self, host):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 base.CommandBase.__init__(self, host, 'set', use_pubsub=True, help=_(u'publish or update a merge request'))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 self.need_loop=True
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 def add_parser_options(self):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, default=u'', help=_(u"id or URL of the request to update, or nothing for a new one"))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 self.parser.add_argument("-r", "--repository", metavar="PATH", type=base.unicode_decoder, default=u'.', help=_(u"path of the repository (DEFAULT: current directory)"))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 def mergeRequestSetCb(self, published_id):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 if published_id:
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 self.disp(u"Merge request published at {pub_id}".format(pub_id=published_id))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 else:
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self.disp(u"Merge request published")
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self.host.quit(C.EXIT_OK)
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 def start(self):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 common.checkURI(self.args)
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 repository = os.path.expanduser(os.path.abspath(self.args.repository))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 extra = {'update': 'true'} if self.args.item else {}
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 self.host.bridge.mergeRequestSet(
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 self.args.service,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 self.args.node,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 repository,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 u'auto',
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 {},
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 u'',
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 self.args.item,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 extra,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 self.profile,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 callback=self.mergeRequestSetCb,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 errback=partial(self.errback,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 msg=_(u"can't create merge request: {}"),
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 exit_code=C.EXIT_BRIDGE_ERRBACK))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
67
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 class MergeRequest(base.CommandBase):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 subcommands = (Set,)
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
70
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 def __init__(self, host):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 super(MergeRequest, self).__init__(host, 'merge-request', use_profile=False, help=_('merge-request management'))