def make_router_link_query(self) :
        props = {'count':      '100',
                 'operation':  'QUERY',
                 'entityType': 'org.apache.qpid.dispatch.router.link',
                 'name':       'self',
                 'type':       'org.amqp.management'
                 }
        attrs = []
        attrs.append(UNICODE('linkType'))
        attrs.append(UNICODE('linkDir'))
        attrs.append(UNICODE('deliveryCount'))
        attrs.append(UNICODE('priority'))

        msg_body = {}
        msg_body['attributeNames'] = attrs
        return Message(body=msg_body, properties=props, reply_to=self.reply_addr)
Ejemplo n.º 2
0
    def table(self, title, heads, rows):
        """ Print a table with autosized columns """

        # Pad the rows to the number of heads
        for row in rows:
            diff = len(heads) - len(row)
            for idx in range(diff):
                row.append("")

        print("%s" % title)
        if len(rows) == 0:
            return
        colWidth = []
        col = 0
        line = self.tablePrefix
        for head in heads:
            width = len(head)
            for row in rows:
                text = UNICODE(row[col])
                cellWidth = len(text)
                if cellWidth > width:
                    width = cellWidth
            colWidth.append(width + self.tableSpacing)
            line = line + head
            if col < len(heads) - 1:
                for i in range(colWidth[col] - len(head)):
                    line = line + " "
            col = col + 1
        print(line)
        line = self.tablePrefix
        for width in colWidth:
            for i in range(width):
                line = line + "="
        print(line)

        for row in rows:
            line = self.tablePrefix
            col = 0
            for width in colWidth:
                text = UNICODE(row[col])
                line = line + text
                if col < len(heads) - 1:
                    for i in range(width - len(text)):
                        line = line + " "
                col = col + 1
            print(line)
 def setup_first_links(self, event):
     self.first_sender = event.container.create_sender(
         self.first_conn, self.first_address)
     if self.dynamic:
         self.first_receiver = event.container.create_receiver(
             self.first_conn,
             dynamic=True,
             options=DynamicNodeProperties(
                 {"x-opt-qd.address": UNICODE(self.first_address)}))
     else:
         self.first_receiver = event.container.create_receiver(
             self.first_conn, self.first_address)
Ejemplo n.º 4
0
    def tableCsv(self, title, heads, rows):
        """
    Print a table with CSV format.
    """
        def csvEscape(text):
            """
      Given a unicode text field, return the quoted CSV format for it
      :param text: a header field or a table row field
      :return:
      """
            if len(text) == 0:
                return ""
            else:
                text = text.replace(CSV_CONFIG.STRING_QUOTE,
                                    CSV_CONFIG.STRING_QUOTE * 2)
                return CSV_CONFIG.STRING_QUOTE + text + CSV_CONFIG.STRING_QUOTE

        print("%s" % title)
        if len(rows) == 0:
            return

        print(','.join([csvEscape(UNICODE(head)) for head in heads]))
        for row in rows:
            print(','.join([csvEscape(UNICODE(item)) for item in row]))
    def make_router_link_query(self):
        props = {
            'count': '100',
            'operation': 'QUERY',
            'entityType': 'org.apache.qpid.dispatch.router.link',
            'name': 'self',
            'type': 'org.amqp.management'
        }
        attrs = []
        attrs.append(UNICODE('linkType'))
        attrs.append(UNICODE('linkDir'))
        attrs.append(UNICODE('linkName'))
        attrs.append(UNICODE('owningAddr'))
        attrs.append(UNICODE('capacity'))
        attrs.append(UNICODE('undeliveredCount'))
        attrs.append(UNICODE('unsettledCount'))
        attrs.append(UNICODE('acceptedCount'))
        attrs.append(UNICODE('rejectedCount'))
        attrs.append(UNICODE('releasedCount'))
        attrs.append(UNICODE('modifiedCount'))

        msg_body = {}
        msg_body['attributeNames'] = attrs
        return Message(body=msg_body,
                       properties=props,
                       reply_to=self.reply_addr)