From 4373956a3f692b3cd42c2bae98c4abe70d0da981 Mon Sep 17 00:00:00 2001 From: sunshine Date: Mon, 2 Aug 2004 13:55:41 +0000 Subject: [PATCH] Updated Python I2P version 0.91 by sunshine --- apps/sam/python/doc/epydoc/calldoc.py | 18 + apps/sam/python/doc/epydoc/makedoc.py | 35 ++ apps/sam/python/doc/pydoc/i2p.eep.html | 40 -- apps/sam/python/doc/pydoc/i2p.html | 90 ----- apps/sam/python/doc/pydoc/i2p.router.html | 38 -- apps/sam/python/doc/pydoc/i2p.sam.html | 374 ------------------ apps/sam/python/doc/pydoc/i2p.samclasses.html | 314 --------------- apps/sam/python/doc/pydoc/makedoc.py | 36 -- 8 files changed, 53 insertions(+), 892 deletions(-) create mode 100644 apps/sam/python/doc/epydoc/calldoc.py create mode 100644 apps/sam/python/doc/epydoc/makedoc.py delete mode 100644 apps/sam/python/doc/pydoc/i2p.eep.html delete mode 100644 apps/sam/python/doc/pydoc/i2p.html delete mode 100644 apps/sam/python/doc/pydoc/i2p.router.html delete mode 100644 apps/sam/python/doc/pydoc/i2p.sam.html delete mode 100644 apps/sam/python/doc/pydoc/i2p.samclasses.html delete mode 100644 apps/sam/python/doc/pydoc/makedoc.py diff --git a/apps/sam/python/doc/epydoc/calldoc.py b/apps/sam/python/doc/epydoc/calldoc.py new file mode 100644 index 000000000..0cc8d730f --- /dev/null +++ b/apps/sam/python/doc/epydoc/calldoc.py @@ -0,0 +1,18 @@ +#!/usr/local/bin/python + +# +# Call the command line interface for Epydoc. +# + +# We have to do some path magic to prevent Python from getting +# confused about the difference between this epydoc module, and the +# real epydoc package. So sys.path[0], which contains the directory +# of the script. +import sys, os.path +script_path = os.path.abspath(sys.path[0]) +sys.path = [p for p in sys.path if + os.path.abspath(p) != script_path] + +from epydoc.cli import cli +cli() + diff --git a/apps/sam/python/doc/epydoc/makedoc.py b/apps/sam/python/doc/epydoc/makedoc.py new file mode 100644 index 000000000..7af6fc464 --- /dev/null +++ b/apps/sam/python/doc/epydoc/makedoc.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python + +""" +Make epydoc HTML documentation in the 'html' subdirectory. +""" + +import epydoc as epydoc_ +import inspect +import os, sys + +def epydoc(args): + """Run epydoc (command line) with given argument string.""" + os.system('python calldoc.py ' + args) + +def makedoc(): + """Make all epydoc HTML documentation for Python I2P library.""" + modlist = [ + 'i2p', + 'i2p.eep', + 'i2p.tunnel', + 'i2p.router', + 'i2p.socket', + 'i2p.select', + 'i2p.samclasses', + 'i2p.CGIHTTPServer', + 'i2p.SimpleHTTPServer', + 'i2p.BaseHTTPServer', + 'i2p.SocketServer', + 'i2p.pylib' + ] + modlist.reverse() + epydoc('--html ' + ' '.join(modlist)) + +if __name__ == '__main__': + makedoc() diff --git a/apps/sam/python/doc/pydoc/i2p.eep.html b/apps/sam/python/doc/pydoc/i2p.eep.html deleted file mode 100644 index 553ef3d9e..000000000 --- a/apps/sam/python/doc/pydoc/i2p.eep.html +++ /dev/null @@ -1,40 +0,0 @@ - - -Python: module i2p.eep - - - - -
 
- 
i2p.eep
index
d:\code\i2p\i2p\eep.py
-

Eeproxy Python API

-

- - - - - -
 
-Modules
       
urllib2
-

- - - - - -
 
-Functions
       
urlget(url, eepaddr='127.0.0.1:4444')
Get contents of an eepsite.
-Example: urlget('http://duck.i2p/').
-
urlopen(url, eepaddr='127.0.0.1:4444')
Like urllib2.urlopen(url), but only works for eep-sites.
-Example: f = urlopen('http://duck.i2p/index.html')
-

- - - - - -
 
-Data
       eepaddr = '127.0.0.1:4444'
- \ No newline at end of file diff --git a/apps/sam/python/doc/pydoc/i2p.html b/apps/sam/python/doc/pydoc/i2p.html deleted file mode 100644 index 3b884e22e..000000000 --- a/apps/sam/python/doc/pydoc/i2p.html +++ /dev/null @@ -1,90 +0,0 @@ - - -Python: package i2p - - - - -
 
- 
i2p
index
d:\code\i2p\i2p\__init__.py
-

i2p -- I2P Python interface

-

- - - - - -
 
-Package Contents
       
eep
-
router
-
sam
-
samclasses
-

- - - - - -
 
-Classes
       
-
exceptions.Exception -
-
-
Error -
-
-
RouterError -
-
-
-
-
-

- - - - - - - -
 
-class Error(exceptions.Exception)
   Base class for all I2P errors.
 
 Methods inherited from exceptions.Exception:
-
__getitem__(...)
- -
__init__(...)
- -
__str__(...)
- -

- - - - - - - -
 
-class RouterError(Error)
   Could not connect to router.
 
 
Method resolution order:
-
RouterError
-
Error
-
exceptions.Exception
-
-
-Methods inherited from exceptions.Exception:
-
__getitem__(...)
- -
__init__(...)
- -
__str__(...)
- -

- - - - - -
 
-Data
       __all__ = ['Error', 'RouterError', 'sam', 'eep', 'router']
- \ No newline at end of file diff --git a/apps/sam/python/doc/pydoc/i2p.router.html b/apps/sam/python/doc/pydoc/i2p.router.html deleted file mode 100644 index e4b888345..000000000 --- a/apps/sam/python/doc/pydoc/i2p.router.html +++ /dev/null @@ -1,38 +0,0 @@ - - -Python: module i2p.router - - - - -
 
- 
i2p.router
index
d:\code\i2p\i2p\router.py
-

Router Control API for Python

-

- - - - - -
 
-Modules
       
i2p
-os
-
socket
-sys
-
threading
-time
-
urllib2
-

- - - - - -
 
-Data
       check_addrlist = ['127.0.0.1:7656', '127.0.0.1:4444']
-our_router = False
-our_router_lock = <thread.lock object at 0x008AD0F0>
-router_config = 'router.config'
- \ No newline at end of file diff --git a/apps/sam/python/doc/pydoc/i2p.sam.html b/apps/sam/python/doc/pydoc/i2p.sam.html deleted file mode 100644 index dcf9e2029..000000000 --- a/apps/sam/python/doc/pydoc/i2p.sam.html +++ /dev/null @@ -1,374 +0,0 @@ - - -Python: module i2p.sam - - - - -
 
- 
i2p.sam
index
d:\code\i2p\i2p\sam.py
-

SAM Python API

-

- - - - - -
 
-Modules
       
Queue
-copy
-i2p
-
select
-socket
-i2p.samclasses
-
thread
-threading
-time
-

- - - - - -
 
-Classes
       
-
i2p.Error(exceptions.Exception) -
-
-
Error -
-
-
BlockError -
ClosedError -
NetworkError -
Timeout -
-
-
-
-
Poll -
Socket -
Tunnel -
-
-
TunnelClient -
TunnelServer -
-
-
-

- - - - - - - -
 
-class BlockError(Error)
   Socket call would have blocked.
 
 
Method resolution order:
-
BlockError
-
Error
-
i2p.Error
-
exceptions.Exception
-
-
-Methods inherited from exceptions.Exception:
-
__getitem__(...)
- -
__init__(...)
- -
__str__(...)
- -

- - - - - - - -
 
-class ClosedError(Error)
   A command was used on a socket that closed gracefully.
 
 
Method resolution order:
-
ClosedError
-
Error
-
i2p.Error
-
exceptions.Exception
-
-
-Methods inherited from exceptions.Exception:
-
__getitem__(...)
- -
__init__(...)
- -
__str__(...)
- -

- - - - - - - -
 
-class Error(i2p.Error)
   Base class for all SAM errors.
 
 
Method resolution order:
-
Error
-
i2p.Error
-
exceptions.Exception
-
-
-Methods inherited from exceptions.Exception:
-
__getitem__(...)
- -
__init__(...)
- -
__str__(...)
- -

- - - - - - - -
 
-class NetworkError(Error)
   Network error occurred within I2P.
-The error object is a 2-tuple: (errtag, errdesc).
-errtag is a SAM error string,
-errdesc is a human readable error description.
 
 
Method resolution order:
-
NetworkError
-
Error
-
i2p.Error
-
exceptions.Exception
-
-
-Methods inherited from exceptions.Exception:
-
__getitem__(...)
- -
__init__(...)
- -
__str__(...)
- -

- - - - - - - -
 
-class Poll
   Class implementing poll interface.  Works for Python sockets
-and SAM sockets.
 
 Methods defined here:
-
__init__(self)
- -
poll(self, timeout=None)
- -
register(self, fd, eventmask=13)
- -
unregister(self, fd)
- -

- - - - - - - -
 
-class Socket
   A socket object.
 
 Methods defined here:
-
__deepcopy__(self, memo)
- -
__init__(self, session, type, samaddr='127.0.0.1:7656', **kwargs)
Equivalent to socket().
- -
accept(self)
- -
bind(self, address)
- -
close(self)
- -
connect(self, address)
- -
connect_ex(self, address)
- -
getpeername(self)
- -
getsockname(self)
- -
gettimeout(self)
- -
listen(self, backlog)
- -
makefile(self, mode='r', bufsize=-1)
- -
recv(self, bufsize, flags=0)
- -
recvfrom(self, bufsize, flags=0)
For a datagram or raw socket, bufsize = -1 indicates that the
-entire packet should be retrieved.
- -
send(self, string, flags=0)
- -
sendall(self, string, flags=0)
- -
sendto(self, string, flags, address)
- -
setblocking(self, flag)
- -
settimeout(self, value)
- -
-Properties defined here:
-
dest
-
Local I2P Destination of socket
-
-
session
-
Session name
-
-
type
-
Socket type: SOCK_STREAM, SOCK_DGRAM, or SOCK_RAW.
-
-

- - - - - - - -
 
-class Timeout(Error)
   Time out occurred for a socket which had timeouts enabled
-via a prior call to settimeout().
 
 
Method resolution order:
-
Timeout
-
Error
-
i2p.Error
-
exceptions.Exception
-
-
-Methods inherited from exceptions.Exception:
-
__getitem__(...)
- -
__init__(...)
- -
__str__(...)
- -

- - - - - -
 
-class Tunnel
    Methods defined here:
-
__init__(self, receive, make_send, nconnect=-1, timeout=60.0)
Tunnel relays connections from a 'receive' socket to one
-or more 'send' sockets.  The receive socket must be bound
-and listening.  For each incoming connection, a new send
-socket is created by calling make_send().  Data is then
-exchanged between the created streams until one socket is
-closed.  nconnect is the maximum number of simultaneous
-connections (-1 for infinite), and timeout is the time that
-a single connection can last for (None allows a connection
-to last forever).

-Sockets must accept stream traffic and support the Python
-socket interface.  A separate daemonic thread is created to
-manage the tunnel.  For high performance, make_send() should
-make a socket and connect in non-blocking mode (you should
-catch and discard the sam.BlockError or socket.error due to
-executing connect on a non-blocking socket).

-Security Note:
-A firewall is needed to maintain the end user's anonymity.
-An attacker could keep a tunnel socket open by pinging it
-regularly.  The accepted sockets from 'receive' must prevent
-this by closing down eventually.

-Socket errors do not cause the Tunnel to shut down.
- -
close(self)
Close all connections made for this tunnel.
- -

- - - - - -
 
-class TunnelClient(Tunnel)
    Methods defined here:
-
__init__(self, session, port, dest, samaddr='127.0.0.1:7656', nconnect=-1, timeout=None, **kwargs)
Tunnels localhost:port --> I2P Destination dest.

-A session named 'session' is created locally, for purposes
-of routing to 'dest'.  nconnect and timeout are the maximum
-number of connections and maximum time per connection.  All
-other arguments are passed to sam.socket().  This call blocks
-until the tunnel is ready.
- -
-Properties defined here:
-
dest
-
get = 'Local Destination used for routing.'
-
-
remotedest
-
Remote Destination.
-
-
session
-
get = 'Session name for local Destination.'
-
-
-Methods inherited from Tunnel:
-
close(self)
Close all connections made for this tunnel.
- -

- - - - - -
 
-class TunnelServer(Tunnel)
    Methods defined here:
-
__init__(self, session, port, samaddr='127.0.0.1:7656', nconnect=-1, timeout=None, **kwargs)
Tunnels incoming SAM streams --> localhost:port.

-nconnect and timeout are the maximum number of connections
-and maximum time per connection.  All other arguments are
-passed to sam.socket().  This call blocks until the tunnel
-is ready.
- -
-Properties defined here:
-
dest
-
I2P Destination of server.
-
-
session
-
Session name for server.
-
-
-Methods inherited from Tunnel:
-
close(self)
Close all connections made for this tunnel.
- -

- - - - - -
 
-Data
       MAX_DGRAM = 31744
-MAX_RAW = 32768
-MSG_DONTWAIT = 128
-MSG_PEEK = 2
-MSG_WAITALL = 64
-POLLERR = 8
-POLLHUP = 16
-POLLIN = 1
-POLLNVAL = 32
-POLLOUT = 4
-POLLPRI = 1
-SOCK_DGRAM = 2
-SOCK_RAW = 3
-SOCK_STREAM = 1
-samaddr = '127.0.0.1:7656'
-samver = 1.0
- \ No newline at end of file diff --git a/apps/sam/python/doc/pydoc/i2p.samclasses.html b/apps/sam/python/doc/pydoc/i2p.samclasses.html deleted file mode 100644 index 111b1e48a..000000000 --- a/apps/sam/python/doc/pydoc/i2p.samclasses.html +++ /dev/null @@ -1,314 +0,0 @@ - - -Python: module i2p.samclasses - - - - -
 
- 
i2p.samclasses
index
d:\code\i2p\i2p\samclasses.py
-

Lower-level SAM API, interfaces with SAM Bridge.

-For internal use only.

-Use the higher level i2p.sam module for your own programs.

-For details on SAM, see "Simple Anonymous Messaging (SAM) v1.0,"
-as published by jrandom.

-Class Overview:

-  SAMTerminal:     Message sender/reader, talks to SAM Bridge
-                   through a single socket.
-  StringBuffer:    Queue for character data.
-  BaseSession:     SAM session classes are derived from this.
-  StreamSession:   Manipulate a SAM stream session through a
-                   threadsafe, high-level interface.
-  DatagramSession: SAM datagram session, threadsafe, high level.
-  RawSession:      SAM raw session, threadsafe, high level.

-Note that a 'None' timeout is an infinite timeout: it
-blocks forever if necessary.

-Todo:
-  * Error handling is a huge mess.  Neaten it up.
-    Subclass a ErrorMixin class, then use set_error(e),
-    check_error(), get_error().
-  * Streams are a huge mess.  Neaten them up.
-  * This whole interface is a tad confusing.  Neaten it up.

-

- - - - - -
 
-Modules
       
Queue
-i2p
-random
-
shlex
-socket
-string
-
sys
-thread
-threading
-
time
-traceback
-

- - - - - -
 
-Classes
       
-
BaseSession -
-
-
DatagramSession -
RawSession -
StreamSession -
-
-
Deque -
-
-
StringBuffer -
-
-
SAMTerminal -
Stream -
-

- - - - - - - -
 
-class BaseSession
   Base session, from which StreamSessionDatagramSession,
-and RawSession are derived.
 
 Methods defined here:
-
__init__(self, addr='')
- -
close(self)
Close the session.
- -

- - - - - - - -
 
-class DatagramSession(BaseSession)
   Datagram session.  All methods are blocking and threadsafe.
 
 Methods defined here:
-
__init__(self, name, addr='', **kwargs)
- -
__len__(self)
Number of packets in read buffer.
- -
recv(self, timeout=None, peek=False)
Get a single packet.  Blocks for up to timeout seconds if
-n > 0 and no packet is available (timeout=None means wait
-forever).  If still no packet is available, raises BlockError
-or Timeout.  Returns the pair (data, address).  If peek is
-True, the data is not removed.
- -
send(self, s, dest)
Send packet with contents s to given destination.
- -
-Methods inherited from BaseSession:
-
close(self)
Close the session.
- -

- - - - - - - -
 
-class Deque
   A double-ended queue.
 
 Methods defined here:
-
__init__(self)
- -
__len__(self)
Number of items in the deque.
- -
pop_first(self)
Pop an item off the beginning of the deque, and return it.
- -
pop_last(self)
Pop an item off the end of the deque, and return it.
- -
push_first(self, obj)
Prepend obj to the beginning of the deque.
- -
push_last(self, obj)
Append obj to the end of the deque.
- -

- - - - - - - -
 
-class RawSession(BaseSession)
   Raw session.  All methods are blocking and threadsafe.
 
 Methods defined here:
-
__init__(self, name, addr='', **kwargs)
- -
__len__(self)
Number of packets in read buffer.
- -
recv(self, timeout=None, peek=False)
Identical to DatagramSocket.recv.  The from address is an
-empty string.
- -
send(self, s, dest)
Send packet with contents s to given destination.
- -
-Methods inherited from BaseSession:
-
close(self)
Close the session.
- -

- - - - - - - -
 
-class SAMTerminal
   Message-by-message communication with SAM through a single
-socket.  _on_* messages are dispatched to msgobj.
 
 Methods defined here:
-
__init__(self, addr, msgobj)
- -
check(self)
Raise an error if terminal was closed, otherwise do
-nothing.
- -
check_message(self, kwargs)
Raises an error if kwargs['RESULT'] != 'OK'.
- -
close(self)
Close the SAM terminal.
- -
on_message(self, msg, kwargs)
Process a SAM message that was received.  Dispatch to
-_on_MESSAGE_NAME(**kwargs).
- -
queue_get(self, q)
Identical to q.get() unless a call to check() fails,
-in which case the waiting is cut short with an error.
- -
send_message(self, msg)
Send a message to the SAM bridge.  A newline will be
-automatically added if none is present.
- -

- - - - - - - -
 
-class Stream
   Receives and sends data for an individual stream.
 
 Methods defined here:
-
__del__(self)
- -
__init__(self, parent, remotedest, id, didconnect=True)
- -
__len__(self)
Current length of read buffer.
- -
close(self)
Close the stream.  Threadsafe.
- -
on_close(self, e)
- -
on_receive(self, s)
- -
recv(self, n, timeout=None, peek=False, waitall=False)
Reads up to n bytes in a manner identical to socket.recv.
-Blocks for up to timeout seconds if n > 0 and no data is
-available (timeout=None means wait forever).  If still no data
-is available, raises BlockError or Timeout.  For a closed
-stream, recv will read the data stored in the buffer until
-EOF, at which point the read data will be truncated.  If peek
-is True, the data is not removed.  If waitall is True, reads
-exactly n bytes, or raises BlockError or Timeout as
-appropriate.  Returns data.
- -
send(self, s)
Sends the string s, blocking if necessary.
- -

- - - - - - - -
 
-class StreamSession(BaseSession)
   Stream session.  All methods are blocking and threadsafe.
 
 Methods defined here:
-
__init__(self, name, addr='', **kwargs)
- -
__len__(self)
Unconnected session; has no read data available.
- -
accept(self, timeout=None)
Wait for incoming connection, and return a Stream object
-for it.
- -
connect(self, dest, timeout=None)
Create a stream connected to remote destination 'dest'.  The
-id is random.  If the timeout is exceeded, do NOT raise an
-error; rather, return a Stream object with .didconnect set
-to False.
- -
listen(self, backlog)
Set maximum number of queued connections.
- -
-Methods inherited from BaseSession:
-
close(self)
Close the session.
- -

- - - - - - - -
 
-class StringBuffer(Deque)
   A FIFO for characters.  Strings can be efficiently
-appended to the end, and read from the beginning.

-Example:
-  B = StringBuffer('Hello W')
-  B.append('orld!')
-  print B.read(5)        # 'Hello'
-  print B.read()         # 'World!'
 
 Methods defined here:
-
__init__(self, s='')
- -
__len__(self)
- -
__repr__(self)
- -
__str__(self)
- -
append(self, s)
Append string data to the end of the buffer.
- -
peek(self, n=None)
Like read(), but do not remove the data that is returned.
- -
prepend(self, s)
Prepend string data to the beginning of the buffer.
- -
read(self, n=None)
Read n bytes of data (or less if less data available) from the
-beginning of the buffer.  The data is removed.  If n is
-omitted, read the entire buffer.
- -
-Methods inherited from Deque:
-
pop_first(self)
Pop an item off the beginning of the deque, and return it.
- -
pop_last(self)
Pop an item off the end of the deque, and return it.
- -
push_first(self, obj)
Prepend obj to the beginning of the deque.
- -
push_last(self, obj)
Append obj to the end of the deque.
- -

- - - - - -
 
-Data
       sam_log = False
- \ No newline at end of file diff --git a/apps/sam/python/doc/pydoc/makedoc.py b/apps/sam/python/doc/pydoc/makedoc.py deleted file mode 100644 index 73857ae2f..000000000 --- a/apps/sam/python/doc/pydoc/makedoc.py +++ /dev/null @@ -1,36 +0,0 @@ - -# ------------------------------------------------------------- -# makedoc.py: Make pydoc documentation for Python SAM API -# ------------------------------------------------------------- - -import os, inspect -import pydoc as pydoc_ - -def pydoc(args): - """Run pydoc (command line) with given argument string.""" - filename = inspect.getsourcefile(pydoc_) - os.system('python ' + filename + ' ' + args) - -def move(f1, f2): - """Moves filename f1 to filename f2, overwriting if f2 already exists.""" - try: os.remove(f2) - except: pass - os.rename(f1, f2) - -def makedoc(): - """Make all HTML documentation for Python I2P library.""" - modules = ['i2p', 'i2p.sam', 'i2p.eep', 'i2p.router', 'i2p.samclasses'] - - origdir = os.getcwd() - os.chdir('../..') - - for m in modules: - pydoc('-w ' + m) - - os.chdir(origdir) - - for m in modules: - move('../../' + m + '.html', './' + m + '.html') - -if __name__ == '__main__': - makedoc() \ No newline at end of file