Beispiel #1
0
 def format_duration(self, with_ansi = False):
     try:
         duration_str = (str(self.c.duration) + 'ms').rjust(6)
         if with_ansi:
             return ansi.get('yellow') + duration_str + ansi.get('none')
         else:
             return duration_str
     except Exception as ex:
         ansi.echo("red WARNING: Could not compute duration of conversation, error was '%s'" % ex)
         return ''
Beispiel #2
0
 def format_response_status(self, with_ansi = False):
     # print status of correlated response on top, if available
     # TODO: refactor to separate method "print_conversation_header"
     result = ''
     response = self.c.response
     if response is not None:
         result = "[%s %s]" % (response.status, response.reason)
         if with_ansi:
             if int(response.status) < 400:
                 status_color = 'green'
             else:
                 status_color = 'red'
             result = ansi.get("%s %s" % (status_color, result), end = '') + ansi.get('none', end = '')
     return result