summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--net-p2p/py-kenosis/Makefile64
-rw-r--r--net-p2p/py-kenosis/distinfo2
-rw-r--r--net-p2p/py-kenosis/files/patch-kenosis_setup.py11
-rw-r--r--net-p2p/py-kenosis/files/python2.3-Queue.py206
-rw-r--r--net-p2p/py-kenosis/pkg-descr12
-rw-r--r--net-p2p/py-kenosis/pkg-plist125
-rw-r--r--net/Makefile1
-rw-r--r--net/py-kenosis/Makefile64
-rw-r--r--net/py-kenosis/distinfo2
-rw-r--r--net/py-kenosis/files/patch-kenosis_setup.py11
-rw-r--r--net/py-kenosis/files/python2.3-Queue.py206
-rw-r--r--net/py-kenosis/pkg-descr12
-rw-r--r--net/py-kenosis/pkg-plist125
13 files changed, 841 insertions, 0 deletions
diff --git a/net-p2p/py-kenosis/Makefile b/net-p2p/py-kenosis/Makefile
new file mode 100644
index 000000000000..6b116102cc6d
--- /dev/null
+++ b/net-p2p/py-kenosis/Makefile
@@ -0,0 +1,64 @@
+# New ports collection makefile for: kenosis
+# Date created: Thu Jan 13 01:15:19 UTC 2005
+# Whom: Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>
+#
+# $FreeBSD$
+#
+
+PORTNAME= kenosis
+PORTVERSION= 0.92
+CATEGORIES= net python
+MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
+MASTER_SITE_SUBDIR= ${PORTNAME}
+PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER= lioux@FreeBSD.org
+COMMENT= A fully-distributed p2p RPC system built on top of XMLRPC
+
+RUN_DEPENDS= \
+ ${LOCALBASE}/lib/${PYTHON_VERSION}/site-packages/xmlrpclib.py:${PORTSDIR}/net/py-xmlrpclib
+
+USE_PYTHON= yes
+USE_PYDISTUTILS= yes
+PYSETUP= ${PORTNAME}_setup.py
+
+USE_REINPLACE= yes
+
+post-extract:
+# Avoid name collision and move ds inside kenosis package
+# it is only used by kenosis anyway
+ @${MV} ${WRKSRC}/ds ${WRKSRC}/${PORTNAME}
+# Contributed by Eric Ries <eric.ries@aya.yale.edu> - kenosis developer
+# Queue.py changed API from python 2.3 to 2.4
+# use Queue.py from python 2.3 while kenosis developers fix this
+ @${CP} ${FILESDIR}/python2.3-Queue.py \
+ ${WRKSRC}/${PORTNAME}/Queue.py
+
+post-patch:
+# ds was moved inside kenosis package
+# use local copy of Queue
+# point at correct python
+ @${FIND} ${WRKSRC} -type f -print0 \
+ | ${XARGS} -0 -n 5 -x \
+ ${REINPLACE_CMD} -E \
+ -e 's|from[[:space:]]+ds|from ${PORTNAME}.ds|' \
+ -e 's|import[[:space:]]+Queue|from ${PORTNAME} import Queue|' \
+ -e 's|/usr/bin/python|${PYTHON_CMD}|' \
+ -e 's|/usr/bin/env[[:space:]]+python|${PYTHON_CMD}|'
+# remove all .bak files
+ @${FIND} ${WRKSRC} -name "*.bak" -type f -print0 \
+ | ${XARGS} -0 -n 5 -x \
+ ${RM} -f
+# Contributed by Eric Ries <eric.ries@aya.yale.edu> - kenosis developer
+# set default time out to 20
+ @${REINPLACE_CMD} -E \
+ -e 's|(socket.setdefaulttimeout)\([[:digit:]]+\)|\1(20)|' \
+ ${WRKSRC}/${PORTNAME}/node.py
+
+post-install:
+# fix post-install permissions
+ @${FIND} ${PYTHON_SITELIBDIR} -type f -print0 \
+ | ${XARGS} -0 -n 5 -x \
+ ${CHMOD} ${SHAREMODE}
+
+.include <bsd.port.mk>
diff --git a/net-p2p/py-kenosis/distinfo b/net-p2p/py-kenosis/distinfo
new file mode 100644
index 000000000000..222d5f763ba0
--- /dev/null
+++ b/net-p2p/py-kenosis/distinfo
@@ -0,0 +1,2 @@
+MD5 (kenosis-0.92.tar.gz) = 969f5fd77b57743c07336b796fc7c01d
+SIZE (kenosis-0.92.tar.gz) = 107101
diff --git a/net-p2p/py-kenosis/files/patch-kenosis_setup.py b/net-p2p/py-kenosis/files/patch-kenosis_setup.py
new file mode 100644
index 000000000000..32ab818eaddf
--- /dev/null
+++ b/net-p2p/py-kenosis/files/patch-kenosis_setup.py
@@ -0,0 +1,11 @@
+--- kenosis_setup.py.orig Fri Jan 7 04:16:32 2005
++++ kenosis_setup.py Thu Jan 13 00:22:56 2005
+@@ -15,7 +15,6 @@
+ url = "http://kenosis.sf.net/",
+ license = "MIT",
+
+- packages = ["bt", "bt.BitTorrent", "ds", "kenosis", "kenosis.dns"],
++ packages = ["kenosis", "kenosis.ds", "kenosis.dns"],
+ )
+
+-print("Upload to upload.sf.net/incoming by running: ncftpput upload.sf.net incoming dist/kenosis-%s.tar.gz" % kenosis.version)
diff --git a/net-p2p/py-kenosis/files/python2.3-Queue.py b/net-p2p/py-kenosis/files/python2.3-Queue.py
new file mode 100644
index 000000000000..980aee619ddc
--- /dev/null
+++ b/net-p2p/py-kenosis/files/python2.3-Queue.py
@@ -0,0 +1,206 @@
+"""A multi-producer, multi-consumer queue."""
+
+from time import time as _time, sleep as _sleep
+
+__all__ = ['Empty', 'Full', 'Queue']
+
+class Empty(Exception):
+ "Exception raised by Queue.get(block=0)/get_nowait()."
+ pass
+
+class Full(Exception):
+ "Exception raised by Queue.put(block=0)/put_nowait()."
+ pass
+
+class Queue:
+ def __init__(self, maxsize=0):
+ """Initialize a queue object with a given maximum size.
+
+ If maxsize is <= 0, the queue size is infinite.
+ """
+ try:
+ import thread
+ except ImportError:
+ import dummy_thread as thread
+ self._init(maxsize)
+ self.mutex = thread.allocate_lock()
+ self.esema = thread.allocate_lock()
+ self.esema.acquire()
+ self.fsema = thread.allocate_lock()
+
+ def qsize(self):
+ """Return the approximate size of the queue (not reliable!)."""
+ self.mutex.acquire()
+ n = self._qsize()
+ self.mutex.release()
+ return n
+
+ def empty(self):
+ """Return True if the queue is empty, False otherwise (not reliable!)."""
+ self.mutex.acquire()
+ n = self._empty()
+ self.mutex.release()
+ return n
+
+ def full(self):
+ """Return True if the queue is full, False otherwise (not reliable!)."""
+ self.mutex.acquire()
+ n = self._full()
+ self.mutex.release()
+ return n
+
+ def put(self, item, block=True, timeout=None):
+ """Put an item into the queue.
+
+ If optional args 'block' is true and 'timeout' is None (the default),
+ block if necessary until a free slot is available. If 'timeout' is
+ a positive number, it blocks at most 'timeout' seconds and raises
+ the Full exception if no free slot was available within that time.
+ Otherwise ('block' is false), put an item on the queue if a free slot
+ is immediately available, else raise the Full exception ('timeout'
+ is ignored in that case).
+ """
+ if block:
+ if timeout is None:
+ # blocking, w/o timeout, i.e. forever
+ self.fsema.acquire()
+ elif timeout >= 0:
+ # waiting max. 'timeout' seconds.
+ # this code snipped is from threading.py: _Event.wait():
+ # Balancing act: We can't afford a pure busy loop, so we
+ # have to sleep; but if we sleep the whole timeout time,
+ # we'll be unresponsive. The scheme here sleeps very
+ # little at first, longer as time goes on, but never longer
+ # than 20 times per second (or the timeout time remaining).
+ delay = 0.0005 # 500 us -> initial delay of 1 ms
+ endtime = _time() + timeout
+ while True:
+ if self.fsema.acquire(0):
+ break
+ remaining = endtime - _time()
+ if remaining <= 0: #time is over and no slot was free
+ raise Full
+ delay = min(delay * 2, remaining, .05)
+ _sleep(delay) #reduce CPU usage by using a sleep
+ else:
+ raise ValueError("'timeout' must be a positive number")
+ elif not self.fsema.acquire(0):
+ raise Full
+ self.mutex.acquire()
+ release_fsema = True
+ try:
+ was_empty = self._empty()
+ self._put(item)
+ # If we fail before here, the empty state has
+ # not changed, so we can skip the release of esema
+ if was_empty:
+ self.esema.release()
+ # If we fail before here, the queue can not be full, so
+ # release_full_sema remains True
+ release_fsema = not self._full()
+ finally:
+ # Catching system level exceptions here (RecursionDepth,
+ # OutOfMemory, etc) - so do as little as possible in terms
+ # of Python calls.
+ if release_fsema:
+ self.fsema.release()
+ self.mutex.release()
+
+ def put_nowait(self, item):
+ """Put an item into the queue without blocking.
+
+ Only enqueue the item if a free slot is immediately available.
+ Otherwise raise the Full exception.
+ """
+ return self.put(item, False)
+
+ def get(self, block=True, timeout=None):
+ """Remove and return an item from the queue.
+
+ If optional args 'block' is true and 'timeout' is None (the default),
+ block if necessary until an item is available. If 'timeout' is
+ a positive number, it blocks at most 'timeout' seconds and raises
+ the Empty exception if no item was available within that time.
+ Otherwise ('block' is false), return an item if one is immediately
+ available, else raise the Empty exception ('timeout' is ignored
+ in that case).
+ """
+ if block:
+ if timeout is None:
+ # blocking, w/o timeout, i.e. forever
+ self.esema.acquire()
+ elif timeout >= 0:
+ # waiting max. 'timeout' seconds.
+ # this code snipped is from threading.py: _Event.wait():
+ # Balancing act: We can't afford a pure busy loop, so we
+ # have to sleep; but if we sleep the whole timeout time,
+ # we'll be unresponsive. The scheme here sleeps very
+ # little at first, longer as time goes on, but never longer
+ # than 20 times per second (or the timeout time remaining).
+ delay = 0.0005 # 500 us -> initial delay of 1 ms
+ endtime = _time() + timeout
+ while 1:
+ if self.esema.acquire(0):
+ break
+ remaining = endtime - _time()
+ if remaining <= 0: #time is over and no element arrived
+ raise Empty
+ delay = min(delay * 2, remaining, .05)
+ _sleep(delay) #reduce CPU usage by using a sleep
+ else:
+ raise ValueError("'timeout' must be a positive number")
+ elif not self.esema.acquire(0):
+ raise Empty
+ self.mutex.acquire()
+ release_esema = True
+ try:
+ was_full = self._full()
+ item = self._get()
+ # If we fail before here, the full state has
+ # not changed, so we can skip the release of fsema
+ if was_full:
+ self.fsema.release()
+ # Failure means empty state also unchanged - release_esema
+ # remains True.
+ release_esema = not self._empty()
+ finally:
+ if release_esema:
+ self.esema.release()
+ self.mutex.release()
+ return item
+
+ def get_nowait(self):
+ """Remove and return an item from the queue without blocking.
+
+ Only get an item if one is immediately available. Otherwise
+ raise the Empty exception.
+ """
+ return self.get(False)
+
+ # Override these methods to implement other queue organizations
+ # (e.g. stack or priority queue).
+ # These will only be called with appropriate locks held
+
+ # Initialize the queue representation
+ def _init(self, maxsize):
+ self.maxsize = maxsize
+ self.queue = []
+
+ def _qsize(self):
+ return len(self.queue)
+
+ # Check whether the queue is empty
+ def _empty(self):
+ return not self.queue
+
+ # Check whether the queue is full
+ def _full(self):
+ return self.maxsize > 0 and len(self.queue) == self.maxsize
+
+ # Put a new item in the queue
+ def _put(self, item):
+ self.queue.append(item)
+
+ # Get an item from the queue
+ def _get(self):
+ return self.queue.pop(0)
diff --git a/net-p2p/py-kenosis/pkg-descr b/net-p2p/py-kenosis/pkg-descr
new file mode 100644
index 000000000000..6fbcc2e540ed
--- /dev/null
+++ b/net-p2p/py-kenosis/pkg-descr
@@ -0,0 +1,12 @@
+[ excerpt from developer's web site ]
+
+Kenosis is a fully-distributed p2p RPC system built on top of
+XMLRPC. Nodes are automatically connected to each other via a
+Kademlia-style network (http://citeseer.ist.psu.edu/529075.html) and
+can route RPC requests efficiently to any online node. Kenosis does
+not rely on a central server - any Kenosis node can effectively join
+the network ("bootstrap") from any connected node.
+
+WWW: http://kenosis.sourceforge.net/
+
+-- lioux@FreeBSD.org
diff --git a/net-p2p/py-kenosis/pkg-plist b/net-p2p/py-kenosis/pkg-plist
new file mode 100644
index 000000000000..39197ede53ca
--- /dev/null
+++ b/net-p2p/py-kenosis/pkg-plist
@@ -0,0 +1,125 @@
+%%PYTHON_SITELIBDIR%%/kenosis/Queue.py
+%%PYTHON_SITELIBDIR%%/kenosis/Queue.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/Queue.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/__init__.py
+%%PYTHON_SITELIBDIR%%/kenosis/__init__.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/__init__.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/address.py
+%%PYTHON_SITELIBDIR%%/kenosis/address.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/address.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/addresstest.py
+%%PYTHON_SITELIBDIR%%/kenosis/addresstest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/addresstest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dns/__init__.py
+%%PYTHON_SITELIBDIR%%/kenosis/dns/__init__.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dns/__init__.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dns/example.zone.py
+%%PYTHON_SITELIBDIR%%/kenosis/dns/example.zone.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dns/example.zone.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dns/kenosisdns.tac.py
+%%PYTHON_SITELIBDIR%%/kenosis/dns/kenosisdns.tac.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dns/kenosisdns.tac.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dnstest.py
+%%PYTHON_SITELIBDIR%%/kenosis/dnstest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dnstest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/__init__.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/__init__.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/__init__.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetools.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetools.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetools.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetoolstest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetoolstest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetoolstest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/coverage.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/coverage.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/coverage.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsbase.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsbase.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsbase.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfile.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfile.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfile.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfiletest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfiletest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfiletest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueue.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueue.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueue.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueuetest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueuetest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueuetest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsrandom.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsrandom.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsrandom.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsreload.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsreload.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsreload.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthread.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthread.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthread.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthreadtest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthreadtest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthreadtest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstime.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstime.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstime.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstraceback.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstraceback.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstraceback.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsunittest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsunittest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsunittest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/generatortest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/generatortest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/generatortest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/http.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/http.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/http.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/id.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/id.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/id.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/message.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/message.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/message.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mock.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mock.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mock.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mocktask.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mocktask.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mocktask.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/task.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/task.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/task.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/tasktest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/tasktest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/tasktest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/testall.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/testall.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/testall.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/ui.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/ui.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/ui.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/weakmethod.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/weakmethod.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/weakmethod.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/kim.py
+%%PYTHON_SITELIBDIR%%/kenosis/kim.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/kim.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/node.py
+%%PYTHON_SITELIBDIR%%/kenosis/node.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/node.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/nodetest.py
+%%PYTHON_SITELIBDIR%%/kenosis/nodetest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/nodetest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/test.py
+%%PYTHON_SITELIBDIR%%/kenosis/test.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/test.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/xmlrpclib_transport.py
+%%PYTHON_SITELIBDIR%%/kenosis/xmlrpclib_transport.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/xmlrpclib_transport.pyo
+@dirrm %%PYTHON_SITELIBDIR%%/kenosis/ds
+@dirrm %%PYTHON_SITELIBDIR%%/kenosis/dns
+@dirrm %%PYTHON_SITELIBDIR%%/kenosis
+@unexec rmdir %D/%%PYTHON_SITELIBDIR%% 2>/dev/null || true
+@unexec rmdir %D/%%PYTHON_LIBDIR%% 2>/dev/null || true
diff --git a/net/Makefile b/net/Makefile
index 146539aef882..4258089aa076 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -602,6 +602,7 @@
SUBDIR += py-fngrab
SUBDIR += py-google
SUBDIR += py-jabber
+ SUBDIR += py-kenosis
SUBDIR += py-ldap2
SUBDIR += py-libnet
SUBDIR += py-medusa
diff --git a/net/py-kenosis/Makefile b/net/py-kenosis/Makefile
new file mode 100644
index 000000000000..6b116102cc6d
--- /dev/null
+++ b/net/py-kenosis/Makefile
@@ -0,0 +1,64 @@
+# New ports collection makefile for: kenosis
+# Date created: Thu Jan 13 01:15:19 UTC 2005
+# Whom: Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>
+#
+# $FreeBSD$
+#
+
+PORTNAME= kenosis
+PORTVERSION= 0.92
+CATEGORIES= net python
+MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
+MASTER_SITE_SUBDIR= ${PORTNAME}
+PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER= lioux@FreeBSD.org
+COMMENT= A fully-distributed p2p RPC system built on top of XMLRPC
+
+RUN_DEPENDS= \
+ ${LOCALBASE}/lib/${PYTHON_VERSION}/site-packages/xmlrpclib.py:${PORTSDIR}/net/py-xmlrpclib
+
+USE_PYTHON= yes
+USE_PYDISTUTILS= yes
+PYSETUP= ${PORTNAME}_setup.py
+
+USE_REINPLACE= yes
+
+post-extract:
+# Avoid name collision and move ds inside kenosis package
+# it is only used by kenosis anyway
+ @${MV} ${WRKSRC}/ds ${WRKSRC}/${PORTNAME}
+# Contributed by Eric Ries <eric.ries@aya.yale.edu> - kenosis developer
+# Queue.py changed API from python 2.3 to 2.4
+# use Queue.py from python 2.3 while kenosis developers fix this
+ @${CP} ${FILESDIR}/python2.3-Queue.py \
+ ${WRKSRC}/${PORTNAME}/Queue.py
+
+post-patch:
+# ds was moved inside kenosis package
+# use local copy of Queue
+# point at correct python
+ @${FIND} ${WRKSRC} -type f -print0 \
+ | ${XARGS} -0 -n 5 -x \
+ ${REINPLACE_CMD} -E \
+ -e 's|from[[:space:]]+ds|from ${PORTNAME}.ds|' \
+ -e 's|import[[:space:]]+Queue|from ${PORTNAME} import Queue|' \
+ -e 's|/usr/bin/python|${PYTHON_CMD}|' \
+ -e 's|/usr/bin/env[[:space:]]+python|${PYTHON_CMD}|'
+# remove all .bak files
+ @${FIND} ${WRKSRC} -name "*.bak" -type f -print0 \
+ | ${XARGS} -0 -n 5 -x \
+ ${RM} -f
+# Contributed by Eric Ries <eric.ries@aya.yale.edu> - kenosis developer
+# set default time out to 20
+ @${REINPLACE_CMD} -E \
+ -e 's|(socket.setdefaulttimeout)\([[:digit:]]+\)|\1(20)|' \
+ ${WRKSRC}/${PORTNAME}/node.py
+
+post-install:
+# fix post-install permissions
+ @${FIND} ${PYTHON_SITELIBDIR} -type f -print0 \
+ | ${XARGS} -0 -n 5 -x \
+ ${CHMOD} ${SHAREMODE}
+
+.include <bsd.port.mk>
diff --git a/net/py-kenosis/distinfo b/net/py-kenosis/distinfo
new file mode 100644
index 000000000000..222d5f763ba0
--- /dev/null
+++ b/net/py-kenosis/distinfo
@@ -0,0 +1,2 @@
+MD5 (kenosis-0.92.tar.gz) = 969f5fd77b57743c07336b796fc7c01d
+SIZE (kenosis-0.92.tar.gz) = 107101
diff --git a/net/py-kenosis/files/patch-kenosis_setup.py b/net/py-kenosis/files/patch-kenosis_setup.py
new file mode 100644
index 000000000000..32ab818eaddf
--- /dev/null
+++ b/net/py-kenosis/files/patch-kenosis_setup.py
@@ -0,0 +1,11 @@
+--- kenosis_setup.py.orig Fri Jan 7 04:16:32 2005
++++ kenosis_setup.py Thu Jan 13 00:22:56 2005
+@@ -15,7 +15,6 @@
+ url = "http://kenosis.sf.net/",
+ license = "MIT",
+
+- packages = ["bt", "bt.BitTorrent", "ds", "kenosis", "kenosis.dns"],
++ packages = ["kenosis", "kenosis.ds", "kenosis.dns"],
+ )
+
+-print("Upload to upload.sf.net/incoming by running: ncftpput upload.sf.net incoming dist/kenosis-%s.tar.gz" % kenosis.version)
diff --git a/net/py-kenosis/files/python2.3-Queue.py b/net/py-kenosis/files/python2.3-Queue.py
new file mode 100644
index 000000000000..980aee619ddc
--- /dev/null
+++ b/net/py-kenosis/files/python2.3-Queue.py
@@ -0,0 +1,206 @@
+"""A multi-producer, multi-consumer queue."""
+
+from time import time as _time, sleep as _sleep
+
+__all__ = ['Empty', 'Full', 'Queue']
+
+class Empty(Exception):
+ "Exception raised by Queue.get(block=0)/get_nowait()."
+ pass
+
+class Full(Exception):
+ "Exception raised by Queue.put(block=0)/put_nowait()."
+ pass
+
+class Queue:
+ def __init__(self, maxsize=0):
+ """Initialize a queue object with a given maximum size.
+
+ If maxsize is <= 0, the queue size is infinite.
+ """
+ try:
+ import thread
+ except ImportError:
+ import dummy_thread as thread
+ self._init(maxsize)
+ self.mutex = thread.allocate_lock()
+ self.esema = thread.allocate_lock()
+ self.esema.acquire()
+ self.fsema = thread.allocate_lock()
+
+ def qsize(self):
+ """Return the approximate size of the queue (not reliable!)."""
+ self.mutex.acquire()
+ n = self._qsize()
+ self.mutex.release()
+ return n
+
+ def empty(self):
+ """Return True if the queue is empty, False otherwise (not reliable!)."""
+ self.mutex.acquire()
+ n = self._empty()
+ self.mutex.release()
+ return n
+
+ def full(self):
+ """Return True if the queue is full, False otherwise (not reliable!)."""
+ self.mutex.acquire()
+ n = self._full()
+ self.mutex.release()
+ return n
+
+ def put(self, item, block=True, timeout=None):
+ """Put an item into the queue.
+
+ If optional args 'block' is true and 'timeout' is None (the default),
+ block if necessary until a free slot is available. If 'timeout' is
+ a positive number, it blocks at most 'timeout' seconds and raises
+ the Full exception if no free slot was available within that time.
+ Otherwise ('block' is false), put an item on the queue if a free slot
+ is immediately available, else raise the Full exception ('timeout'
+ is ignored in that case).
+ """
+ if block:
+ if timeout is None:
+ # blocking, w/o timeout, i.e. forever
+ self.fsema.acquire()
+ elif timeout >= 0:
+ # waiting max. 'timeout' seconds.
+ # this code snipped is from threading.py: _Event.wait():
+ # Balancing act: We can't afford a pure busy loop, so we
+ # have to sleep; but if we sleep the whole timeout time,
+ # we'll be unresponsive. The scheme here sleeps very
+ # little at first, longer as time goes on, but never longer
+ # than 20 times per second (or the timeout time remaining).
+ delay = 0.0005 # 500 us -> initial delay of 1 ms
+ endtime = _time() + timeout
+ while True:
+ if self.fsema.acquire(0):
+ break
+ remaining = endtime - _time()
+ if remaining <= 0: #time is over and no slot was free
+ raise Full
+ delay = min(delay * 2, remaining, .05)
+ _sleep(delay) #reduce CPU usage by using a sleep
+ else:
+ raise ValueError("'timeout' must be a positive number")
+ elif not self.fsema.acquire(0):
+ raise Full
+ self.mutex.acquire()
+ release_fsema = True
+ try:
+ was_empty = self._empty()
+ self._put(item)
+ # If we fail before here, the empty state has
+ # not changed, so we can skip the release of esema
+ if was_empty:
+ self.esema.release()
+ # If we fail before here, the queue can not be full, so
+ # release_full_sema remains True
+ release_fsema = not self._full()
+ finally:
+ # Catching system level exceptions here (RecursionDepth,
+ # OutOfMemory, etc) - so do as little as possible in terms
+ # of Python calls.
+ if release_fsema:
+ self.fsema.release()
+ self.mutex.release()
+
+ def put_nowait(self, item):
+ """Put an item into the queue without blocking.
+
+ Only enqueue the item if a free slot is immediately available.
+ Otherwise raise the Full exception.
+ """
+ return self.put(item, False)
+
+ def get(self, block=True, timeout=None):
+ """Remove and return an item from the queue.
+
+ If optional args 'block' is true and 'timeout' is None (the default),
+ block if necessary until an item is available. If 'timeout' is
+ a positive number, it blocks at most 'timeout' seconds and raises
+ the Empty exception if no item was available within that time.
+ Otherwise ('block' is false), return an item if one is immediately
+ available, else raise the Empty exception ('timeout' is ignored
+ in that case).
+ """
+ if block:
+ if timeout is None:
+ # blocking, w/o timeout, i.e. forever
+ self.esema.acquire()
+ elif timeout >= 0:
+ # waiting max. 'timeout' seconds.
+ # this code snipped is from threading.py: _Event.wait():
+ # Balancing act: We can't afford a pure busy loop, so we
+ # have to sleep; but if we sleep the whole timeout time,
+ # we'll be unresponsive. The scheme here sleeps very
+ # little at first, longer as time goes on, but never longer
+ # than 20 times per second (or the timeout time remaining).
+ delay = 0.0005 # 500 us -> initial delay of 1 ms
+ endtime = _time() + timeout
+ while 1:
+ if self.esema.acquire(0):
+ break
+ remaining = endtime - _time()
+ if remaining <= 0: #time is over and no element arrived
+ raise Empty
+ delay = min(delay * 2, remaining, .05)
+ _sleep(delay) #reduce CPU usage by using a sleep
+ else:
+ raise ValueError("'timeout' must be a positive number")
+ elif not self.esema.acquire(0):
+ raise Empty
+ self.mutex.acquire()
+ release_esema = True
+ try:
+ was_full = self._full()
+ item = self._get()
+ # If we fail before here, the full state has
+ # not changed, so we can skip the release of fsema
+ if was_full:
+ self.fsema.release()
+ # Failure means empty state also unchanged - release_esema
+ # remains True.
+ release_esema = not self._empty()
+ finally:
+ if release_esema:
+ self.esema.release()
+ self.mutex.release()
+ return item
+
+ def get_nowait(self):
+ """Remove and return an item from the queue without blocking.
+
+ Only get an item if one is immediately available. Otherwise
+ raise the Empty exception.
+ """
+ return self.get(False)
+
+ # Override these methods to implement other queue organizations
+ # (e.g. stack or priority queue).
+ # These will only be called with appropriate locks held
+
+ # Initialize the queue representation
+ def _init(self, maxsize):
+ self.maxsize = maxsize
+ self.queue = []
+
+ def _qsize(self):
+ return len(self.queue)
+
+ # Check whether the queue is empty
+ def _empty(self):
+ return not self.queue
+
+ # Check whether the queue is full
+ def _full(self):
+ return self.maxsize > 0 and len(self.queue) == self.maxsize
+
+ # Put a new item in the queue
+ def _put(self, item):
+ self.queue.append(item)
+
+ # Get an item from the queue
+ def _get(self):
+ return self.queue.pop(0)
diff --git a/net/py-kenosis/pkg-descr b/net/py-kenosis/pkg-descr
new file mode 100644
index 000000000000..6fbcc2e540ed
--- /dev/null
+++ b/net/py-kenosis/pkg-descr
@@ -0,0 +1,12 @@
+[ excerpt from developer's web site ]
+
+Kenosis is a fully-distributed p2p RPC system built on top of
+XMLRPC. Nodes are automatically connected to each other via a
+Kademlia-style network (http://citeseer.ist.psu.edu/529075.html) and
+can route RPC requests efficiently to any online node. Kenosis does
+not rely on a central server - any Kenosis node can effectively join
+the network ("bootstrap") from any connected node.
+
+WWW: http://kenosis.sourceforge.net/
+
+-- lioux@FreeBSD.org
diff --git a/net/py-kenosis/pkg-plist b/net/py-kenosis/pkg-plist
new file mode 100644
index 000000000000..39197ede53ca
--- /dev/null
+++ b/net/py-kenosis/pkg-plist
@@ -0,0 +1,125 @@
+%%PYTHON_SITELIBDIR%%/kenosis/Queue.py
+%%PYTHON_SITELIBDIR%%/kenosis/Queue.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/Queue.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/__init__.py
+%%PYTHON_SITELIBDIR%%/kenosis/__init__.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/__init__.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/address.py
+%%PYTHON_SITELIBDIR%%/kenosis/address.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/address.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/addresstest.py
+%%PYTHON_SITELIBDIR%%/kenosis/addresstest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/addresstest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dns/__init__.py
+%%PYTHON_SITELIBDIR%%/kenosis/dns/__init__.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dns/__init__.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dns/example.zone.py
+%%PYTHON_SITELIBDIR%%/kenosis/dns/example.zone.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dns/example.zone.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dns/kenosisdns.tac.py
+%%PYTHON_SITELIBDIR%%/kenosis/dns/kenosisdns.tac.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dns/kenosisdns.tac.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/dnstest.py
+%%PYTHON_SITELIBDIR%%/kenosis/dnstest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/dnstest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/__init__.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/__init__.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/__init__.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetools.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetools.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetools.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetoolstest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetoolstest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/cachetoolstest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/coverage.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/coverage.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/coverage.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsbase.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsbase.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsbase.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfile.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfile.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfile.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfiletest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfiletest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsfiletest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueue.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueue.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueue.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueuetest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueuetest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsqueuetest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsrandom.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsrandom.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsrandom.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsreload.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsreload.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsreload.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthread.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthread.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthread.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthreadtest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthreadtest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsthreadtest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstime.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstime.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstime.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstraceback.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstraceback.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dstraceback.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsunittest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsunittest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/dsunittest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/generatortest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/generatortest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/generatortest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/http.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/http.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/http.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/id.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/id.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/id.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/message.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/message.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/message.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mock.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mock.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mock.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mocktask.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mocktask.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/mocktask.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/task.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/task.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/task.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/tasktest.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/tasktest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/tasktest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/testall.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/testall.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/testall.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/ui.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/ui.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/ui.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/ds/weakmethod.py
+%%PYTHON_SITELIBDIR%%/kenosis/ds/weakmethod.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/ds/weakmethod.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/kim.py
+%%PYTHON_SITELIBDIR%%/kenosis/kim.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/kim.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/node.py
+%%PYTHON_SITELIBDIR%%/kenosis/node.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/node.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/nodetest.py
+%%PYTHON_SITELIBDIR%%/kenosis/nodetest.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/nodetest.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/test.py
+%%PYTHON_SITELIBDIR%%/kenosis/test.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/test.pyo
+%%PYTHON_SITELIBDIR%%/kenosis/xmlrpclib_transport.py
+%%PYTHON_SITELIBDIR%%/kenosis/xmlrpclib_transport.pyc
+%%PYTHON_SITELIBDIR%%/kenosis/xmlrpclib_transport.pyo
+@dirrm %%PYTHON_SITELIBDIR%%/kenosis/ds
+@dirrm %%PYTHON_SITELIBDIR%%/kenosis/dns
+@dirrm %%PYTHON_SITELIBDIR%%/kenosis
+@unexec rmdir %D/%%PYTHON_SITELIBDIR%% 2>/dev/null || true
+@unexec rmdir %D/%%PYTHON_LIBDIR%% 2>/dev/null || true