jp (ticket): new "get" subcommand, to retrieve ticket(s)
This commit is contained in:
parent
0cbcd566ce
commit
219232761f
1 changed files with 39 additions and 1 deletions
|
|
@ -20,13 +20,51 @@
|
||||||
|
|
||||||
import base
|
import base
|
||||||
from sat.core.i18n import _
|
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 json
|
||||||
|
import os
|
||||||
|
|
||||||
__commands__ = ["Ticket"]
|
__commands__ = ["Ticket"]
|
||||||
|
|
||||||
FIELDS_MAP = u'mapping'
|
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):
|
class Import(base.CommandAnswering):
|
||||||
# TODO: factorize with blog/import
|
# TODO: factorize with blog/import
|
||||||
|
|
||||||
|
|
@ -92,7 +130,7 @@ class Import(base.CommandAnswering):
|
||||||
|
|
||||||
|
|
||||||
class Ticket(base.CommandBase):
|
class Ticket(base.CommandBase):
|
||||||
subcommands = (Import,)
|
subcommands = (Get, Import)
|
||||||
|
|
||||||
def __init__(self, host):
|
def __init__(self, host):
|
||||||
super(Ticket, self).__init__(host, 'ticket', use_profile=False, help=_('tickets handling'))
|
super(Ticket, self).__init__(host, 'ticket', use_profile=False, help=_('tickets handling'))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue