/usr/lib/python2.6/site-packages/supervisor/medusa
NameSizeModeActions
auth_handler.py47390644editdlrm
auth_handler.pyc45130644editdlrm
auth_handler.pyo45130644editdlrm
chat_server.py45350644editdlrm
chat_server.pyc64270644editdlrm
chat_server.pyo64270644editdlrm
counter.py14400644editdlrm
counter.pyc20390644editdlrm
counter.pyo20390644editdlrm
default_handler.py63310644editdlrm
default_handler.pyc50340644editdlrm
default_handler.pyo50340644editdlrm
event_loop.py29810644editdlrm
event_loop.pyc35130644editdlrm
event_loop.pyo35130644editdlrm
filesys.py112060644editdlrm
filesys.pyc135980644editdlrm
filesys.pyo135980644editdlrm
ftp_server.py405520644editdlrm
ftp_server.pyc347270644editdlrm
ftp_server.pyo347270644editdlrm
http_date.py34150644editdlrm
http_date.pyc34680644editdlrm
http_date.pyo34680644editdlrm
http_server.py252170644editdlrm
http_server.pyc214680644editdlrm
http_server.pyo214680644editdlrm
logger.py80000644editdlrm
logger.pyc109900644editdlrm
logger.pyo109900644editdlrm
medusa_gif.py27720644editdlrm
medusa_gif.pyc11560644editdlrm
medusa_gif.pyo11560644editdlrm
monitor.py110540644editdlrm
monitor.pyc122850644editdlrm
monitor.pyo122850644editdlrm
monitor_client.py32730644editdlrm
monitor_client.pyc53900644editdlrm
monitor_client.pyo53900644editdlrm
monitor_client_win32.py13340644editdlrm
monitor_client_win32.pyc20940644editdlrm
monitor_client_win32.pyo20940644editdlrm
m_syslog.py73510644editdlrm
m_syslog.pyc40060644editdlrm
m_syslog.pyo40060644editdlrm
producers.py94390644editdlrm
producers.pyc116340644editdlrm
producers.pyo116340644editdlrm
put_handler.py33240644editdlrm
put_handler.pyc35110644editdlrm
put_handler.pyo35110644editdlrm
redirecting_handler.py14030644editdlrm
redirecting_handler.pyc21590644editdlrm
redirecting_handler.pyo21590644editdlrm
resolver.py155590644editdlrm
resolver.pyc124010644editdlrm
resolver.pyo124010644editdlrm
rpc_client.py96750644editdlrm
rpc_client.pyc103460644editdlrm
rpc_client.pyo103460644editdlrm
rpc_server.py99530644editdlrm
rpc_server.pyc95360644editdlrm
rpc_server.pyo95360644editdlrm
script_handler.py65540644editdlrm
script_handler.pyc66510644editdlrm
script_handler.pyo66510644editdlrm
setup.py4960644editdlrm
setup.pyc7290644editdlrm
setup.pyo7290644editdlrm
status_handler.py93520644editdlrm
status_handler.pyc96720644editdlrm
status_handler.pyo96720644editdlrm
unix_user_handler.py23120644editdlrm
unix_user_handler.pyc23610644editdlrm
unix_user_handler.pyo23610644editdlrm
virtual_handler.py17240644editdlrm
virtual_handler.pyc31640644editdlrm
virtual_handler.pyo31640644editdlrm
xmlrpc_handler.py29440644editdlrm
xmlrpc_handler.pyc37840644editdlrm
xmlrpc_handler.pyo37840644editdlrm
__init__.py1280644editdlrm
__init__.pyc2770644editdlrm
__init__.pyo2770644editdlrm
Edit: /usr/lib/python2.6/site-packages/supervisor/medusa/chat_server.py (4535B)
# -*- Mode: Python -*- # # Author: Sam Rushing # Copyright 1997-2000 by Sam Rushing # All Rights Reserved. # RCS_ID = '$Id: chat_server.py,v 1.1.1.1 2006/06/26 06:36:05 chrism Exp $' import string VERSION = string.split(RCS_ID)[2] import socket import asyncore import asynchat import status_handler class chat_channel (asynchat.async_chat): def __init__ (self, server, sock, addr): asynchat.async_chat.__init__ (self, sock) self.server = server self.addr = addr self.set_terminator ('\r\n') self.data = '' self.nick = None self.push ('nickname?: ') def collect_incoming_data (self, data): self.data = self.data + data def found_terminator (self): line = self.data self.data = '' if self.nick is None: self.nick = string.split (line)[0] if not self.nick: self.nick = None self.push ('huh? gimmee a nickname: ') else: self.greet() else: if not line: pass elif line[0] != '/': self.server.push_line (self, line) else: self.handle_command (line) def greet (self): self.push ('Hello, %s\r\n' % self.nick) num_channels = len(self.server.channels)-1 if num_channels == 0: self.push ('[Kinda lonely in here... you\'re the only caller!]\r\n') else: self.push ('[There are %d other callers]\r\n' % (len(self.server.channels)-1)) nicks = map (lambda x: x.get_nick(), self.server.channels.keys()) self.push (string.join (nicks, '\r\n ') + '\r\n') self.server.push_line (self, '[joined]') def handle_command (self, command): import types command_line = string.split(command) name = 'cmd_%s' % command_line[0][1:] if hasattr (self, name): # make sure it's a method... method = getattr (self, name) if type(method) == type(self.handle_command): method (command_line[1:]) else: self.push ('unknown command: %s' % command_line[0]) def cmd_quit (self, args): self.server.push_line (self, '[left]') self.push ('Goodbye!\r\n') self.close_when_done() # alias for '/quit' - '/q' cmd_q = cmd_quit def push_line (self, nick, line): self.push ('%s: %s\r\n' % (nick, line)) def handle_close (self): self.close() def close (self): del self.server.channels[self] asynchat.async_chat.close (self) def get_nick (self): if self.nick is not None: return self.nick else: return 'Unknown' class chat_server (asyncore.dispatcher): SERVER_IDENT = 'Chat Server (V%s)' % VERSION channel_class = chat_channel spy = 1 def __init__ (self, ip='', port=8518): asyncore.dispatcher.__init__(self) self.port = port self.create_socket (socket.AF_INET, socket.SOCK_STREAM) self.bind ((ip, port)) print '%s started on port %d' % (self.SERVER_IDENT, port) self.listen (5) self.channels = {} self.count = 0 def handle_accept (self): conn, addr = self.accept() self.count = self.count + 1 print 'client #%d - %s:%d' % (self.count, addr[0], addr[1]) self.channels[self.channel_class (self, conn, addr)] = 1 def push_line (self, from_channel, line): nick = from_channel.get_nick() if self.spy: print '%s: %s' % (nick, line) for c in self.channels.keys(): if c is not from_channel: c.push ('%s: %s\r\n' % (nick, line)) def status (self): lines = [ '

%s

' % self.SERVER_IDENT, '
Listening on Port: %d' % self.port, '
Total Sessions: %d' % self.count, '
Current Sessions: %d' % (len(self.channels)) ] return status_handler.lines_producer (lines) def writable (self): return 0 if __name__ == '__main__': import sys if len(sys.argv) > 1: port = string.atoi (sys.argv[1]) else: port = 8518 s = chat_server ('', port) asyncore.loop()