# HG changeset patch # User Goffi # Date 1527848226 -7200 # Node ID 41db2f58c7538c12480b49b810a2aee5eb62d89a # Parent 12bf089f0bf3be7d3eccb3f89a0e2a00cbe74e89 jp (ticket): new "get" subcommand, to retrieve ticket(s) diff -r 12bf089f0bf3 -r 41db2f58c753 sat_frontends/jp/cmd_ticket.py --- a/sat_frontends/jp/cmd_ticket.py Fri Jun 01 12:15:38 2018 +0200 +++ b/sat_frontends/jp/cmd_ticket.py Fri Jun 01 12:17:06 2018 +0200 @@ -20,13 +20,51 @@ import base from sat.core.i18n import _ +from sat_frontends.jp import common +from sat_frontends.jp.constants import Const as C +from functools import partial import json +import os __commands__ = ["Ticket"] FIELDS_MAP = u'mapping' +class Get(base.CommandBase): + + def __init__(self, host): + base.CommandBase.__init__(self, host, 'get', use_verbose=True, + use_pubsub=True, pubsub_flags={C.MULTI_ITEMS}, + pubsub_defaults = {u'service': _(u'auto'), u'node': _(u'auto')}, + use_output=C.OUTPUT_LIST_XMLUI, help=_(u'get tickets')) + self.need_loop=True + + def add_parser_options(self): + pass + + def ticketsGetCb(self, tickets_data): + self.output(tickets_data[0]) + self.host.quit(C.EXIT_OK) + + def getTickets(self): + self.host.bridge.ticketsGet( + self.args.service, + self.args.node, + self.args.max, + self.args.items, + u'', + {}, + self.profile, + callback=self.ticketsGetCb, + errback=partial(self.errback, + msg=_(u"can't get tickets: {}"), + exit_code=C.EXIT_BRIDGE_ERRBACK)) + + def start(self): + common.URIFinder(self, os.getcwd(), 'tickets', self.getTickets, meta_map={}) + + class Import(base.CommandAnswering): # TODO: factorize with blog/import @@ -92,7 +130,7 @@ class Ticket(base.CommandBase): - subcommands = (Import,) + subcommands = (Get, Import) def __init__(self, host): super(Ticket, self).__init__(host, 'ticket', use_profile=False, help=_('tickets handling'))