コード例 #1
0
    def status(self):
        from supervisor.medusa.util import english_bytes

        def nice_bytes(n):
            return ''.join(english_bytes(n))

        handler_stats = [_f for _f in map(maybe_status, self.handlers) if _f]

        if self.total_clients:
            ratio = self.total_requests.as_long() / float(
                self.total_clients.as_long())
        else:
            ratio = 0.0

        return producers.composite_producer([
            producers.lines_producer([
                '<h2>%s</h2>' % self.SERVER_IDENT,
                '<br>Listening on: <b>Host:</b> %s' % self.server_name,
                '<b>Port:</b> %d' % self.port,
                '<p><ul>'
                '<li>Total <b>Clients:</b> %s' % self.total_clients,
                '<b>Requests:</b> %s' % self.total_requests,
                '<b>Requests/Client:</b> %.1f' % ratio,
                '<li>Total <b>Bytes In:</b> %s' %
                (nice_bytes(self.bytes_in.as_long())),
                '<b>Bytes Out:</b> %s' %
                (nice_bytes(self.bytes_out.as_long())),
                '<li>Total <b>Exceptions:</b> %s' % self.exceptions,
                '</ul><p>'
                '<b>Extension List</b><ul>',
            ])
        ] + handler_stats + [producers.simple_producer('</ul>')])
コード例 #2
0
ファイル: http_server.py プロジェクト: lmcdonough/supervisor
    def status (self):
        from supervisor.medusa.status_handler import english_bytes
        def nice_bytes (n):
            return ''.join(english_bytes (n))

        handler_stats = [_f for _f in map (maybe_status, self.handlers) if _f]

        if self.total_clients:
            ratio = self.total_requests.as_long() / float(self.total_clients.as_long())
        else:
            ratio = 0.0

        return producers.composite_producer (
                [producers.lines_producer (
                        ['<h2>%s</h2>'                                                  % self.SERVER_IDENT,
                        '<br>Listening on: <b>Host:</b> %s'             % self.server_name,
                        '<b>Port:</b> %d'                                               % self.port,
                         '<p><ul>'
                         '<li>Total <b>Clients:</b> %s'                 % self.total_clients,
                         '<b>Requests:</b> %s'                                  % self.total_requests,
                         '<b>Requests/Client:</b> %.1f'                 % ratio,
                         '<li>Total <b>Bytes In:</b> %s'        % (nice_bytes (self.bytes_in.as_long())),
                         '<b>Bytes Out:</b> %s'                         % (nice_bytes (self.bytes_out.as_long())),
                         '<li>Total <b>Exceptions:</b> %s'              % self.exceptions,
                         '</ul><p>'
                         '<b>Extension List</b><ul>',
                         ])] + handler_stats + [producers.simple_producer('</ul>')]
                )
コード例 #3
0
ファイル: ftp_server.py プロジェクト: lwoydziak/supervisor
 def cmd_help (self, line):
     """give help information"""
     # find all the methods that match 'cmd_xxxx',
     # use their docstrings for the help response.
     attrs = dir(self.__class__)
     help_lines = []
     for attr in attrs:
         if attr[:4] == 'cmd_':
             x = getattr (self, attr)
             if type(x) == type(self.cmd_help):
                 if x.__doc__:
                     help_lines.append ('\t%s\t%s' % (attr[4:], x.__doc__))
     if help_lines:
         self.push ('214-The following commands are recognized\r\n')
         self.push_with_producer (producers.lines_producer (help_lines))
         self.push ('214\r\n')
     else:
         self.push ('214-\r\n\tHelp Unavailable\r\n214\r\n')
コード例 #4
0
    def status(self):
        def nice_bytes(n):
            return ''.join(status_handler.english_bytes(n))

        return producers.lines_producer([
            '<h2>%s</h2>' % self.SERVER_IDENT,
            '<br>Listening on <b>Host:</b> %s' % self.hostname,
            '<b>Port:</b> %d' % self.port,
            '<br>Sessions',
            '<b>Total:</b> %s' % self.total_sessions,
            '<b>Current:</b> %d' %
            (self.total_sessions.as_long() - self.closed_sessions.as_long()),
            '<br>Files',
            '<b>Sent:</b> %s' % self.total_files_out,
            '<b>Received:</b> %s' % self.total_files_in,
            '<br>Bytes',
            '<b>Sent:</b> %s' % nice_bytes(self.total_bytes_out.as_long()),
            '<b>Received:</b> %s' % nice_bytes(self.total_bytes_in.as_long()),
            '<br>Exceptions: %s' % self.total_exceptions,
        ])
コード例 #5
0
ファイル: ftp_server.py プロジェクト: GulsahKose/supervisor
    def status (self):

        def nice_bytes (n):
            return ''.join(status_handler.english_bytes(n))

        return producers.lines_producer (
                ['<h2>%s</h2>'                          % self.SERVER_IDENT,
                 '<br>Listening on <b>Host:</b> %s' % self.hostname,
                 '<b>Port:</b> %d'                      % self.port,
                 '<br>Sessions',
                 '<b>Total:</b> %s'                     % self.total_sessions,
                 '<b>Current:</b> %d'           % (self.total_sessions.as_long() - self.closed_sessions.as_long()),
                 '<br>Files',
                 '<b>Sent:</b> %s'                      % self.total_files_out,
                 '<b>Received:</b> %s'          % self.total_files_in,
                 '<br>Bytes',
                 '<b>Sent:</b> %s'                      % nice_bytes (self.total_bytes_out.as_long()),
                 '<b>Received:</b> %s'          % nice_bytes (self.total_bytes_in.as_long()),
                 '<br>Exceptions: %s'           % self.total_exceptions,
                 ]
                )
コード例 #6
0
 def check_composite (self):
     p1 = producers.simple_producer('a'*66, buffer_size = 5)
     p2 = producers.lines_producer(['b']*65)
     p = producers.composite_producer([p1, p2])
     self._check_all(p, 'a'*66 + 'b\r\n'*65)
コード例 #7
0
 def check_lines (self):
     p = producers.lines_producer(['a']* 65)
     self._check_all(p, 'a\r\n'*65)
コード例 #8
0
 def check_composite (self):
     p1 = producers.simple_producer('a'*66, buffer_size = 5)
     p2 = producers.lines_producer(['b']*65)
     p = producers.composite_producer([p1, p2])
     self._check_all(p, 'a'*66 + 'b\r\n'*65)
コード例 #9
0
 def check_lines (self):
     p = producers.lines_producer(['a']* 65)
     self._check_all(p, 'a\r\n'*65)