コード例 #1
0
    def status_message(ws, state):
        state = state[:2].upper() if state else '?'
        progress = ws.progress if ws.progress is not None else '?'

        status = '[%s%s]' % (
            str_pad(state, 2, trim=True),
            str_pad(progress, 3, 'right', trim=True)
        )

        metadata_key = None

        if ws.metadata and ws.guid:
            metadata_key = (ws.guid.agent, ws.guid.sid)

            if type(metadata_key) is tuple:
                metadata_key = ', '.join(repr(x) for x in metadata_key)

        title = '%s (%s)' % (ws.title, metadata_key)

        def build(message_format):
            return '%s %s [%s]' % (status, message_format % title, ', '.join([
                '%s: %r' % (key, value)
                for key, value in [
                    ('u', ws.user.title if ws and ws.user else None),
                    ('c', ws.client.name if ws and ws.client else None),
                    ('s', ws.metadata.section.title if ws and ws.metadata and ws.metadata.section else None),
                    ('a', ws.client.address if ws and ws.client else None)
                ]
            ]))

        return build
コード例 #2
0
    def status_message(session, state):
        state = state[:2].upper() if state else '?'
        progress = session.progress if session.progress is not None else '?'

        status = '[%s%s]' % (
            str_pad(state, 2, trim=True),
            str_pad(progress, 3, 'right', trim=True)
        )

        metadata_key = None

        if session.metadata and session.metadata.get('key'):
            metadata_key = session.metadata['key']

            if type(metadata_key) is tuple:
                metadata_key = ', '.join(repr(x) for x in metadata_key)

        title = '%s (%s)' % (session.get_title(), metadata_key)

        def build(message_format):
            return '%s %s' % (status, message_format % title)

        return build
コード例 #3
0
 def get_status_label(progress, state):
     return '[%s%s]' % (
         str_pad(state[:2].upper() if state else '?', 2),
         str_pad(progress if progress is not None else '?', 3, 'right')
     )