changeset 2602:41db2f58c753

jp (ticket): new "get" subcommand, to retrieve ticket(s)
author Goffi <goffi@goffi.org>
date Fri, 01 Jun 2018 12:17:06 +0200
parents 12bf089f0bf3
children 5d4ac5415b40
files sat_frontends/jp/cmd_ticket.py
diffstat 1 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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'))