def status (self): def nice_bytes (n): return string.join (status_handler.english_bytes (n)) handler_stats = filter (None, map (maybe_status, self.handlers)) if self.total_clients: ratio = self.total_requests.as_long() / float(self.total_clients.as_long()) else: ratio = 0.0 return producers.composite_producer ( fifo ([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>')] ) )
def status (self): def nice_bytes (n): return string.join (status_handler.english_bytes (n)) handler_stats = filter (None, map (maybe_status, self.handlers)) 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>')] )
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')
def status(self): def nice_bytes(n): return string.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, ])
def status (self): def nice_bytes (n): return string.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, ] )