/
usr
/
lib
/
python2.6
/
site-packages
/
supervisor
/
medusa
/
/usr/lib/python2.6/site-packages/supervisor/medusa
mkdir
upload
Name
Size
Mode
Actions
auth_handler.py
4739
0644
edit
dl
rm
auth_handler.pyc
4513
0644
edit
dl
rm
auth_handler.pyo
4513
0644
edit
dl
rm
chat_server.py
4535
0644
edit
dl
rm
chat_server.pyc
6427
0644
edit
dl
rm
chat_server.pyo
6427
0644
edit
dl
rm
counter.py
1440
0644
edit
dl
rm
counter.pyc
2039
0644
edit
dl
rm
counter.pyo
2039
0644
edit
dl
rm
default_handler.py
6331
0644
edit
dl
rm
default_handler.pyc
5034
0644
edit
dl
rm
default_handler.pyo
5034
0644
edit
dl
rm
event_loop.py
2981
0644
edit
dl
rm
event_loop.pyc
3513
0644
edit
dl
rm
event_loop.pyo
3513
0644
edit
dl
rm
filesys.py
11206
0644
edit
dl
rm
filesys.pyc
13598
0644
edit
dl
rm
filesys.pyo
13598
0644
edit
dl
rm
ftp_server.py
40552
0644
edit
dl
rm
ftp_server.pyc
34727
0644
edit
dl
rm
ftp_server.pyo
34727
0644
edit
dl
rm
http_date.py
3415
0644
edit
dl
rm
http_date.pyc
3468
0644
edit
dl
rm
http_date.pyo
3468
0644
edit
dl
rm
http_server.py
25217
0644
edit
dl
rm
http_server.pyc
21468
0644
edit
dl
rm
http_server.pyo
21468
0644
edit
dl
rm
logger.py
8000
0644
edit
dl
rm
logger.pyc
10990
0644
edit
dl
rm
logger.pyo
10990
0644
edit
dl
rm
medusa_gif.py
2772
0644
edit
dl
rm
medusa_gif.pyc
1156
0644
edit
dl
rm
medusa_gif.pyo
1156
0644
edit
dl
rm
monitor.py
11054
0644
edit
dl
rm
monitor.pyc
12285
0644
edit
dl
rm
monitor.pyo
12285
0644
edit
dl
rm
monitor_client.py
3273
0644
edit
dl
rm
monitor_client.pyc
5390
0644
edit
dl
rm
monitor_client.pyo
5390
0644
edit
dl
rm
monitor_client_win32.py
1334
0644
edit
dl
rm
monitor_client_win32.pyc
2094
0644
edit
dl
rm
monitor_client_win32.pyo
2094
0644
edit
dl
rm
m_syslog.py
7351
0644
edit
dl
rm
m_syslog.pyc
4006
0644
edit
dl
rm
m_syslog.pyo
4006
0644
edit
dl
rm
producers.py
9439
0644
edit
dl
rm
producers.pyc
11634
0644
edit
dl
rm
producers.pyo
11634
0644
edit
dl
rm
put_handler.py
3324
0644
edit
dl
rm
put_handler.pyc
3511
0644
edit
dl
rm
put_handler.pyo
3511
0644
edit
dl
rm
redirecting_handler.py
1403
0644
edit
dl
rm
redirecting_handler.pyc
2159
0644
edit
dl
rm
redirecting_handler.pyo
2159
0644
edit
dl
rm
resolver.py
15559
0644
edit
dl
rm
resolver.pyc
12401
0644
edit
dl
rm
resolver.pyo
12401
0644
edit
dl
rm
rpc_client.py
9675
0644
edit
dl
rm
rpc_client.pyc
10346
0644
edit
dl
rm
rpc_client.pyo
10346
0644
edit
dl
rm
rpc_server.py
9953
0644
edit
dl
rm
rpc_server.pyc
9536
0644
edit
dl
rm
rpc_server.pyo
9536
0644
edit
dl
rm
script_handler.py
6554
0644
edit
dl
rm
script_handler.pyc
6651
0644
edit
dl
rm
script_handler.pyo
6651
0644
edit
dl
rm
setup.py
496
0644
edit
dl
rm
setup.pyc
729
0644
edit
dl
rm
setup.pyo
729
0644
edit
dl
rm
status_handler.py
9352
0644
edit
dl
rm
status_handler.pyc
9672
0644
edit
dl
rm
status_handler.pyo
9672
0644
edit
dl
rm
unix_user_handler.py
2312
0644
edit
dl
rm
unix_user_handler.pyc
2361
0644
edit
dl
rm
unix_user_handler.pyo
2361
0644
edit
dl
rm
virtual_handler.py
1724
0644
edit
dl
rm
virtual_handler.pyc
3164
0644
edit
dl
rm
virtual_handler.pyo
3164
0644
edit
dl
rm
xmlrpc_handler.py
2944
0644
edit
dl
rm
xmlrpc_handler.pyc
3784
0644
edit
dl
rm
xmlrpc_handler.pyo
3784
0644
edit
dl
rm
__init__.py
128
0644
edit
dl
rm
__init__.pyc
277
0644
edit
dl
rm
__init__.pyo
277
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/supervisor/medusa/producers.py
(9439B)
# -*- Mode: Python -*- RCS_ID = '$Id: producers.py,v 1.1.1.1 2006/06/26 06:36:05 chrism Exp $' """ A collection of producers. Each producer implements a particular feature: They can be combined in various ways to get interesting and useful behaviors. For example, you can feed dynamically-produced output into the compressing producer, then wrap this with the 'chunked' transfer-encoding producer. """ import string from asynchat import find_prefix_at_end class simple_producer: "producer for a string" def __init__ (self, data, buffer_size=1024): self.data = data self.buffer_size = buffer_size def more (self): if len (self.data) > self.buffer_size: result = self.data[:self.buffer_size] self.data = self.data[self.buffer_size:] return result else: result = self.data self.data = '' return result class scanning_producer: "like simple_producer, but more efficient for large strings" def __init__ (self, data, buffer_size=1024): self.data = data self.buffer_size = buffer_size self.pos = 0 def more (self): if self.pos < len(self.data): lp = self.pos rp = min ( len(self.data), self.pos + self.buffer_size ) result = self.data[lp:rp] self.pos = self.pos + len(result) return result else: return '' class lines_producer: "producer for a list of lines" def __init__ (self, lines): self.lines = lines def more (self): if self.lines: chunk = self.lines[:50] self.lines = self.lines[50:] return string.join (chunk, '\r\n') + '\r\n' else: return '' class buffer_list_producer: "producer for a list of strings" # i.e., data == string.join (buffers, '') def __init__ (self, buffers): self.index = 0 self.buffers = buffers def more (self): if self.index >= len(self.buffers): return '' else: data = self.buffers[self.index] self.index = self.index + 1 return data class file_producer: "producer wrapper for file[-like] objects" # match http_channel's outgoing buffer size out_buffer_size = 1<<16 def __init__ (self, file): self.done = 0 self.file = file def more (self): if self.done: return '' else: data = self.file.read (self.out_buffer_size) if not data: self.file.close() del self.file self.done = 1 return '' else: return data # A simple output producer. This one does not [yet] have # the safety feature builtin to the monitor channel: runaway # output will not be caught. # don't try to print from within any of the methods # of this object. class output_producer: "Acts like an output file; suitable for capturing sys.stdout" def __init__ (self): self.data = '' def write (self, data): lines = string.splitfields (data, '\n') data = string.join (lines, '\r\n') self.data = self.data + data def writeline (self, line): self.data = self.data + line + '\r\n' def writelines (self, lines): self.data = self.data + string.joinfields ( lines, '\r\n' ) + '\r\n' def flush (self): pass def softspace (self, *args): pass def more (self): if self.data: result = self.data[:512] self.data = self.data[512:] return result else: return '' class composite_producer: "combine a fifo of producers into one" def __init__ (self, producers): self.producers = producers def more (self): while len(self.producers): p = self.producers[0] d = p.more() if d: return d else: self.producers.pop(0) else: return '' class globbing_producer: """ 'glob' the output from a producer into a particular buffer size. helps reduce the number of calls to send(). [this appears to gain about 30% performance on requests to a single channel] """ def __init__ (self, producer, buffer_size=1<<16): self.producer = producer self.buffer = '' self.buffer_size = buffer_size def more (self): while len(self.buffer) < self.buffer_size: data = self.producer.more() if data: self.buffer = self.buffer + data else: break r = self.buffer self.buffer = '' return r class hooked_producer: """ A producer that will call <function> when it empties,. with an argument of the number of bytes produced. Useful for logging/instrumentation purposes. """ def __init__ (self, producer, function): self.producer = producer self.function = function self.bytes = 0 def more (self): if self.producer: result = self.producer.more() if not result: self.producer = None self.function (self.bytes) else: self.bytes = self.bytes + len(result) return result else: return '' # HTTP 1.1 emphasizes that an advertised Content-Length header MUST be # correct. In the face of Strange Files, it is conceivable that # reading a 'file' may produce an amount of data not matching that # reported by os.stat() [text/binary mode issues, perhaps the file is # being appended to, etc..] This makes the chunked encoding a True # Blessing, and it really ought to be used even with normal files. # How beautifully it blends with the concept of the producer. class chunked_producer: """A producer that implements the 'chunked' transfer coding for HTTP/1.1. Here is a sample usage: request['Transfer-Encoding'] = 'chunked' request.push ( producers.chunked_producer (your_producer) ) request.done() """ def __init__ (self, producer, footers=None): self.producer = producer self.footers = footers def more (self): if self.producer: data = self.producer.more() if data: return '%x\r\n%s\r\n' % (len(data), data) else: self.producer = None if self.footers: return string.join ( ['0'] + self.footers, '\r\n' ) + '\r\n\r\n' else: return '0\r\n\r\n' else: return '' # Unfortunately this isn't very useful right now (Aug 97), because # apparently the browsers don't do on-the-fly decompression. Which # is sad, because this could _really_ speed things up, especially for # low-bandwidth clients (i.e., most everyone). try: import zlib except ImportError: zlib = None class compressed_producer: """ Compress another producer on-the-fly, using ZLIB [Unfortunately, none of the current browsers seem to support this] """ # Note: It's not very efficient to have the server repeatedly # compressing your outgoing files: compress them ahead of time, or # use a compress-once-and-store scheme. However, if you have low # bandwidth and low traffic, this may make more sense than # maintaining your source files compressed. # # Can also be used for compressing dynamically-produced output. def __init__ (self, producer, level=5): self.producer = producer self.compressor = zlib.compressobj (level) def more (self): if self.producer: cdata = '' # feed until we get some output while not cdata: data = self.producer.more() if not data: self.producer = None return self.compressor.flush() else: cdata = self.compressor.compress (data) return cdata else: return '' class escaping_producer: "A producer that escapes a sequence of characters" " Common usage: escaping the CRLF.CRLF sequence in SMTP, NNTP, etc..." def __init__ (self, producer, esc_from='\r\n.', esc_to='\r\n..'): self.producer = producer self.esc_from = esc_from self.esc_to = esc_to self.buffer = '' self.find_prefix_at_end = find_prefix_at_end def more (self): esc_from = self.esc_from esc_to = self.esc_to buffer = self.buffer + self.producer.more() if buffer: buffer = string.replace (buffer, esc_from, esc_to) i = self.find_prefix_at_end (buffer, esc_from) if i: # we found a prefix self.buffer = buffer[-i:] return buffer[:-i] else: # no prefix, return it all self.buffer = '' return buffer else: return buffer
Save
cmd:
run