# because there are a few dependencies that are outside setuptools's ken (Python and
# platform), and because setuptools might fail to find something even though import finds
# it:
- import OpenSSL, allmydata, foolscap, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec, zope.interface
+ import OpenSSL, allmydata, foolscap.api, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec, zope.interface
d1 = {
'pyOpenSSL': (OpenSSL.__version__, os.path.dirname(OpenSSL.__file__)),
'allmydata-tahoe': (allmydata.__version__, os.path.dirname(allmydata.__file__)),
- 'foolscap': (foolscap.__version__, os.path.dirname(foolscap.__file__)),
+ 'foolscap': (foolscap.api.__version__, os.path.dirname(foolscap.__file__)),
'Nevow': (nevow.__version__, os.path.dirname(nevow.__file__)),
'pycryptopp': (pycryptopp.__version__, os.path.dirname(pycryptopp.__file__)),
'setuptools': (setuptools.__version__, os.path.dirname(setuptools.__file__)),
from zope.interface import implements
from twisted.internet import reactor
from twisted.application.internet import TimerService
-from foolscap import Referenceable
+from foolscap.api import Referenceable
from foolscap.logging import log
from pycryptopp.publickey import rsa
from zope.interface import implements
from twisted.application import service
from twisted.internet import defer
-from foolscap import Referenceable
+from foolscap.api import Referenceable
from allmydata.interfaces import RIControlClient
from allmydata.util import fileutil, mathutil
from allmydata.immutable import upload, download
from zope.interface import implements
from twisted.internet import defer
-from foolscap.eventual import fireEventually
+from foolscap.api import fireEventually
import simplejson
from allmydata.mutable.common import NotMutableError
from allmydata.mutable.filenode import MutableFileNode
#import amdicon
import amdlogo
-import foolscap
+from foolscap.api import Tub
from twisted.python import usage
class AuthError(Exception):
def get_nodeid():
CERTFILE = "node.pem"
certfile = os.path.join(get_basedir(), "private", CERTFILE)
- tub = foolscap.Tub(certFile=certfile)
+ tub = Tub(certFile=certfile)
return tub.getTubID()
def get_nickname():
-from foolscap import DeadReferenceError
+from foolscap.api import DeadReferenceError
from twisted.internet import defer
from allmydata import hashtree
from allmydata.check_results import CheckResults
from twisted.internet import defer
from twisted.internet.interfaces import IPushProducer, IConsumer
from twisted.application import service
-from foolscap import DeadReferenceError
-from foolscap.eventual import eventually
+from foolscap.api import DeadReferenceError, eventually
from allmydata.util import base32, deferredutil, hashutil, log, mathutil
from allmydata.util.assertutil import _assert, precondition
import time
from zope.interface import implements
from twisted.internet import defer
-from foolscap import eventual
+from foolscap.api import fireEventually
from allmydata import uri
from allmydata.storage.server import si_b2a
from allmydata.hashtree import HashTree
}
self._start_total_timestamp = time.time()
- d = eventual.fireEventually()
+ d = fireEventually()
d.addCallback(lambda res: self.start_all_shareholders())
# consistency will cause objects to live for longer than you might
# normally expect.
- return eventual.fireEventually(res)
+ return fireEventually(res)
def start_all_shareholders(self):
from twisted.internet import defer
from twisted.internet.interfaces import IPushProducer, IConsumer
from twisted.protocols import basic
-from foolscap.eventual import eventually
+from foolscap.api import eventually
from allmydata.interfaces import IFileNode, IFileURI, ICheckable, \
IDownloadTarget, IUploadResults
from allmydata.util import dictutil, log, base32
from zope.interface import implements
from twisted.application import service
from twisted.internet import defer
-from foolscap import Referenceable, DeadReferenceError
-from foolscap.eventual import eventually
+from foolscap.api import Referenceable, DeadReferenceError, eventually
import allmydata # for __full_version__
from allmydata import interfaces, uri
from allmydata.storage.server import si_b2a
from twisted.python import failure
from twisted.internet import defer
from twisted.application import service
-from foolscap import Referenceable, Copyable, RemoteCopy
-from foolscap import eventual
+from foolscap.api import Referenceable, Copyable, RemoteCopy, fireEventually
from allmydata.util.hashutil import file_renewal_secret_hash, \
file_cancel_secret_hash, bucket_renewal_secret_hash, \
# actually synchronous too, we'd blow the stack unless we stall for a
# tick. Once you accept a Deferred from IUploadable.read(), you must
# be prepared to have it fire immediately too.
- d.addCallback(eventual.fireEventually)
+ d.addCallback(fireEventually)
def _good(plaintext):
# and encrypt it..
# o/' over the fields we go, hashing all the way, sHA! sHA! sHA! o/'
from zope.interface import Interface
-from foolscap.schema import StringConstraint, ListOf, TupleOf, SetOf, DictOf, \
- ChoiceOf, IntegerConstraint, Any
-from foolscap import RemoteInterface, Referenceable
+from foolscap.api import StringConstraint, ListOf, TupleOf, SetOf, DictOf, \
+ ChoiceOf, IntegerConstraint, Any, RemoteInterface, Referenceable
HASH_SIZE=32
from base64 import b32decode
from zope.interface import implements
from twisted.application import service
-from foolscap import Referenceable
+from foolscap.api import Referenceable
from allmydata.interfaces import InsufficientVersionError
from allmydata.introducer.interfaces import RIIntroducerSubscriberClient, \
IIntroducerClient
from zope.interface import Interface
-from foolscap.schema import StringConstraint, TupleOf, SetOf, DictOf, Any
-from foolscap import RemoteInterface
+from foolscap.api import StringConstraint, TupleOf, SetOf, DictOf, Any, \
+ RemoteInterface
FURL = StringConstraint(1000)
# Announcements are (FURL, service_name, remoteinterface_name,
from base64 import b32decode
from zope.interface import implements
from twisted.application import service
-from foolscap import Referenceable
+from foolscap.api import Referenceable
from allmydata.util import log, idlib
from allmydata.introducer.interfaces import RIIntroducerSubscriberClient, \
IIntroducerClient, RIIntroducerPublisherAndSubscriberService
import time, os.path
from zope.interface import implements
from twisted.application import service
-from foolscap import Referenceable
+from foolscap.api import Referenceable
import allmydata
from allmydata import node
from allmydata.util import log
import os
import time
-import foolscap
+from foolscap.api import Referenceable, Tub
from zope.interface import implements
from twisted.internet import reactor
from twisted.application import service
from pycryptopp.publickey import rsa
from allmydata.interfaces import RIKeyGenerator
-class KeyGenerator(service.MultiService, foolscap.Referenceable):
+class KeyGenerator(service.MultiService, Referenceable):
implements(RIKeyGenerator)
pool_size = 16 # no. keys to keep on hand in the pool
def __init__(self, basedir='.', display_furl=True, default_key_size=2048):
service.MultiService.__init__(self)
self.basedir = basedir
- self.tub = foolscap.Tub(certFile=os.path.join(self.basedir, 'key_generator.pem'))
+ self.tub = Tub(certFile=os.path.join(self.basedir, 'key_generator.pem'))
self.tub.setServiceParent(self)
self.key_generator = KeyGenerator(default_key_size=default_key_size)
self.key_generator.setServiceParent(self)
from zope.interface import implements
from twisted.internet import defer, reactor
-from foolscap.eventual import eventually
+from foolscap.api import eventually
from allmydata.interfaces import IMutableFileNode, IMutableFileURI, \
ICheckable, ICheckResults, NotEnoughSharesError
from allmydata.util import hashutil, log
from allmydata import hashtree, codec
from allmydata.storage.server import si_b2a
from pycryptopp.cipher.aes import AES
-from foolscap.eventual import eventually
+from foolscap.api import eventually
from common import MODE_WRITE, MODE_CHECK, DictOfSets, \
UncoordinatedWriteError, NotEnoughServersError
from zope.interface import implements
from twisted.internet import defer
from twisted.python import failure
-from foolscap import DeadReferenceError
-from foolscap.eventual import eventually, fireEventually
+from foolscap.api import DeadReferenceError, eventually, fireEventually
from allmydata.interfaces import IRetrieveStatus, NotEnoughSharesError
from allmydata.util import hashutil, idlib, log
from allmydata import hashtree, codec
from itertools import count
from twisted.internet import defer
from twisted.python import failure
-from foolscap import DeadReferenceError
-from foolscap.eventual import eventually
+from foolscap.api import DeadReferenceError, eventually
from allmydata.util import base32, hashutil, idlib, log, rrefutil
from allmydata.storage.server import si_b2a
from allmydata.interfaces import IServermapUpdaterStatus
from twisted.python import log as twlog
from twisted.application import service
from twisted.internet import defer, reactor
-from foolscap import Tub, eventual
+from foolscap.api import Tub, eventually, app_versions
import foolscap.logging.log
from allmydata import get_package_versions, get_package_versions_string
from allmydata.util import log
from allmydata.util import fileutil, iputil, observer
from allmydata.util.assertutil import precondition, _assert
-from foolscap.logging import app_versions
-
# Add our application versions to the data that Foolscap's LogPublisher
# reports.
for thing, things_version in get_package_versions().iteritems():
except EnvironmentError:
pass
# Delay until the reactor is running.
- eventual.eventually(self._startService)
+ eventually(self._startService)
def _startService(self):
precondition(reactor.running)
from twisted.application import service
from twisted.application.internet import TimerService
from zope.interface import implements
-import foolscap
-from foolscap.eventual import eventually
+from foolscap.api import eventually, DeadReferenceError, Referenceable, Tub
from twisted.internet.error import ConnectionDone, ConnectionLost
-from foolscap import DeadReferenceError
from allmydata.util import log
from allmydata.interfaces import RIStatsProvider, RIStatsGatherer, IStatsProducer
return s
-class StatsProvider(foolscap.Referenceable, service.MultiService):
+class StatsProvider(Referenceable, service.MultiService):
implements(RIStatsProvider)
def __init__(self, node, gatherer_furl):
gatherer.callRemoteOnly('provide', self, nickname or '')
-class StatsGatherer(foolscap.Referenceable, service.MultiService):
+class StatsGatherer(Referenceable, service.MultiService):
implements(RIStatsGatherer)
poll_interval = 60
self.timer.setServiceParent(self)
def get_tubid(self, rref):
- return foolscap.SturdyRef(rref.tracker.getURL()).getTubRef().getTubID()
+ return rref.getRemoteTubID()
def remote_provide(self, provider, nickname):
tubid = self.get_tubid(provider)
def __init__(self, basedir=".", verbose=False):
service.MultiService.__init__(self)
self.basedir = basedir
- self.tub = foolscap.Tub(certFile=os.path.join(self.basedir,
- "stats_gatherer.pem"))
+ self.tub = Tub(certFile=os.path.join(self.basedir,
+ "stats_gatherer.pem"))
self.tub.setServiceParent(self)
self.tub.setOption("logLocalFailures", True)
self.tub.setOption("logRemoteFailures", True)
import os, stat, struct, time
-from foolscap import Referenceable
+from foolscap.api import Referenceable
from zope.interface import implements
from allmydata.interfaces import RIBucketWriter, RIBucketReader
import os, re, weakref, struct, time
-from foolscap import Referenceable
+from foolscap.api import Referenceable
from twisted.application import service
from zope.interface import implements
from allmydata.immutable import upload
from allmydata.scripts import create_node
from allmydata.util import fileutil, pollmixin
-import foolscap
-from foolscap import eventual
+from foolscap.api import Tub, fireEventually, flushEventualQueue
from twisted.python import log
class StallableHTTPGetterDiscarder(tw_client.HTTPPageGetter):
self.sparent = service.MultiService()
self.sparent.startService()
self.proc = None
- self.tub = foolscap.Tub()
+ self.tub = Tub()
self.tub.setServiceParent(self.sparent)
self.mode = mode
self.failed = False
#logfile = open(os.path.join(self.testdir, "log"), "w")
#flo = log.FileLogObserver(logfile)
#log.startLoggingWithObserver(flo.emit, setStdout=False)
- d = eventual.fireEventually()
+ d = fireEventually()
d.addCallback(lambda res: self.setUp())
d.addCallback(lambda res: self.record_initial_memusage())
d.addCallback(lambda res: self.make_nodes())
if self.proc:
d.addCallback(lambda res: self.kill_client())
d.addCallback(lambda res: self.sparent.stopService())
- d.addCallback(lambda res: eventual.flushEventualQueue())
+ d.addCallback(lambda res: flushEventualQueue())
def _close_statsfile(res):
self.statsfile.close()
d.addCallback(_close_statsfile)
from twisted.internet import reactor, defer
from twisted.python import log
from twisted.application import service
-from foolscap import Tub, eventual
+from foolscap.api import Tub, fireEventually
MB = 1000000
def run(self):
print "STARTING"
- d = eventual.fireEventually()
+ d = fireEventually()
d.addCallback(lambda res: self.setUp())
d.addCallback(lambda res: self.do_test())
d.addBoth(self.tearDown)
from twisted.python import failure
from twisted.application import service
from twisted.web.error import Error as WebError
-from foolscap.eventual import flushEventualQueue, fireEventually
+from foolscap.api import flushEventualQueue, fireEventually
from allmydata import uri, dirnode, client
from allmydata.introducer.server import IntroducerNode
from allmydata.interfaces import IURI, IMutableFileNode, IFileNode, \
import sha
from twisted.application import service
from twisted.internet import reactor
-from foolscap import Referenceable
-from foolscap.eventual import fireEventually
+from foolscap.api import Referenceable, fireEventually
from base64 import b32encode
from allmydata import uri as tahoe_uri
from allmydata.client import Client
from allmydata import client
from allmydata.introducer.client import IntroducerClient
from allmydata.util import base32
-from foolscap.eventual import flushEventualQueue
+from foolscap.api import flushEventualQueue
import common_util as testutil
class FakeIntroducerClient(IntroducerClient):
from twisted.trial import unittest
from twisted.application import service
from twisted.internet import defer
-from foolscap import eventual
+from foolscap.api import eventually, fireEventually
from allmydata.util import fileutil, hashutil, pollmixin
from allmydata.storage.server import StorageServer, si_b2a
def process_bucket(self, cycle, prefix, prefixdir, storage_index_b32):
self.all_buckets.append(storage_index_b32)
def finished_cycle(self, cycle):
- eventual.eventually(self.finished_d.callback, None)
+ eventually(self.finished_d.callback, None)
class PacedCrawler(ShareCrawler):
cpu_slice = 500 # make sure it can complete in a single slice
if self.yield_cb:
self.yield_cb()
def finished_cycle(self, cycle):
- eventual.eventually(self.finished_d.callback, None)
+ eventually(self.finished_d.callback, None)
class ConsumingCrawler(ShareCrawler):
cpu_slice = 0.5
d = c.finished_d
def _finished_first_cycle(ignored):
- return eventual.fireEventually(c.counter)
+ return fireEventually(c.counter)
d.addCallback(_finished_first_cycle)
def _check(old_counter):
# the crawler should do any work after it's been stopped
from twisted.internet import defer, reactor
from twisted.internet.interfaces import IConsumer
from twisted.python.failure import Failure
-from foolscap import eventual
+from foolscap.api import fireEventually
from allmydata import hashtree, uri
from allmydata.immutable import encode, upload, download
from allmydata.util import hashutil
def _start(self):
if self.mode == "lost-early":
f = Failure(LostPeerError("I went away early"))
- return eventual.fireEventually(f)
+ return fireEventually(f)
return defer.succeed(self)
def put_header(self):
def put_block(self, segmentnum, data):
if self.mode == "lost-early":
f = Failure(LostPeerError("I went away early"))
- return eventual.fireEventually(f)
+ return fireEventually(f)
def _try():
assert not self.closed
assert segmentnum not in self.blocks
from twisted.trial import unittest
from twisted.application import service
-from foolscap import Tub, eventual
+from foolscap.api import Tub, fireEventually, flushEventualQueue
from foolscap.logging import log
from allmydata.storage.server import si_b2a
return []
def flush_but_dont_ignore(res):
- d = eventual.flushEventualQueue()
+ d = flushEventualQueue()
def _done(ignored):
return res
d.addCallback(_done)
return d
def wait_a_few_turns(ignored=None):
- d = eventual.fireEventually()
- d.addCallback(eventual.fireEventually)
- d.addCallback(eventual.fireEventually)
- d.addCallback(eventual.fireEventually)
- d.addCallback(eventual.fireEventually)
- d.addCallback(eventual.fireEventually)
+ d = fireEventually()
+ d.addCallback(fireEventually)
+ d.addCallback(fireEventually)
+ d.addCallback(fireEventually)
+ d.addCallback(fireEventually)
+ d.addCallback(fireEventually)
return d
def upload_data(uploader, data, convergence):
def tearDown(self):
d = self.s.stopService()
- d.addCallback(eventual.fireEventually)
+ d.addCallback(fireEventually)
d.addBoth(flush_but_dont_ignore)
return d
from twisted.internet import defer
from twisted.python import log
-from foolscap import Tub, Referenceable
-from foolscap.eventual import fireEventually, flushEventualQueue
+from foolscap.api import Tub, Referenceable, fireEventually, flushEventualQueue
from twisted.application import service
from allmydata.interfaces import InsufficientVersionError
from allmydata.introducer.client import IntroducerClient
from twisted.trial import unittest
from twisted.application import service
-from foolscap import Tub, eventual
+from foolscap.api import Tub, fireEventually, flushEventualQueue
from allmydata import key_generator
from allmydata.util import pollmixin
from pycryptopp.publickey import rsa
def flush_but_dont_ignore(res):
- d = eventual.flushEventualQueue()
+ d = flushEventualQueue()
def _done(ignored):
return res
d.addCallback(_done)
t.setServiceParent(self.parent)
t.listenOn("tcp:0")
t.setLocationAutomatically()
- return eventual.fireEventually()
+ return fireEventually()
def tearDown(self):
d = self.parent.stopService()
- d.addCallback(eventual.fireEventually)
+ d.addCallback(fireEventually)
d.addBoth(flush_but_dont_ignore)
return d
return len(kgs.key_generator.keypool) == kgs.key_generator.pool_size
# first wait for key gen pool to fill up
- d = eventual.fireEventually()
+ d = fireEventually()
d.addCallback(p, 'waiting for pool to fill up')
d.addCallback(lambda junk: self.poll(keypool_full))
FileTooLargeError, NotEnoughSharesError, IRepairResults
from allmydata.monitor import Monitor
from allmydata.test.common import ShouldFailMixin
-from foolscap.eventual import eventually, fireEventually
+from foolscap.api import eventually, fireEventually
from foolscap.logging import log
import sha
from twisted.internet import defer
from twisted.python import log
-from foolscap.eventual import flushEventualQueue
+from foolscap.api import flushEventualQueue
from twisted.application import service
from allmydata.node import Node, formatTimeTahoeStyle
from allmydata.util import fileutil
from twisted.internet import defer
from twisted.application import service
-from foolscap import eventual
+from foolscap.api import fireEventually
import itertools
from allmydata import interfaces
from allmydata.util import fileutil, hashutil, base32, pollmixin, time_format
# cpu_slice=0 will force it to yield right after it processes the
# first prefix
- d = eventual.fireEventually()
+ d = fireEventually()
def _check(ignored):
# are we really right after the first prefix?
state = ss.bucket_counter.get_state()
ss.bucket_counter.cpu_slice = 0
ss.setServiceParent(self.s)
- d = eventual.fireEventually()
+ d = fireEventually()
def _after_first_prefix(ignored):
ss.bucket_counter.cpu_slice = 100.0 # finish as fast as possible
DAY = 24*60*60
- d = eventual.fireEventually()
+ d = fireEventually()
# now examine the state right after the first bucket has been
# processed.
ss.setServiceParent(self.s)
- d = eventual.fireEventually()
+ d = fireEventually()
# examine the state right after the first bucket has been processed
def _after_first_bucket(ignored):
p = lc.get_progress()
ss.setServiceParent(self.s)
- d = eventual.fireEventually()
+ d = fireEventually()
# examine the state right after the first bucket has been processed
def _after_first_bucket(ignored):
p = lc.get_progress()
ss.setServiceParent(self.s)
- d = eventual.fireEventually()
+ d = fireEventually()
def _check(ignored):
# this should fire after the first bucket is complete, but before
# the first prefix is complete, so the progress-measurer won't
ss.setServiceParent(self.s)
- d = eventual.fireEventually()
+ d = fireEventually()
# now examine the state right after the first bucket has been
# processed.
from allmydata.monitor import Monitor
from allmydata.mutable.common import NotMutableError
from allmydata.mutable import layout as mutable_layout
-from foolscap import DeadReferenceError
+from foolscap.api import DeadReferenceError
from twisted.python.failure import Failure
from twisted.web.client import getPage
from twisted.web.error import Error
from twisted.python.failure import Failure
from twisted.python import log
from twisted.internet import defer
-from foolscap import eventual
+from foolscap.api import fireEventually
import allmydata # for __full_version__
from allmydata import uri, monitor
def _call():
meth = getattr(self, methname)
return meth(*args, **kwargs)
- d = eventual.fireEventually()
+ d = fireEventually()
d.addCallback(lambda res: _call())
return d
def _call():
meth = getattr(self, "remote_" + methname)
return meth(*args, **kwargs)
- d = eventual.fireEventually()
+ d = fireEventually()
d.addCallback(lambda res: _call())
return d
from twisted.internet import defer
-from foolscap.eventual import eventually
+from foolscap.api import eventually
class ConcurrencyLimiter:
"""I implement a basic concurrency limiter. Add work to it in the form of
# -*- test-case-name: allmydata.test.test_observer -*-
from twisted.internet import defer
-from foolscap.eventual import eventually
+from foolscap.api import eventually
"""The idiom we use is for the observed object to offer a method named
'when_something', which returns a deferred. That deferred will be fired when
import exceptions
-from foolscap.tokens import Violation
+from foolscap.api import Violation
class ServerFailure(exceptions.Exception):
# If the server returns a Failure instead of the normal response to a
from nevow import url, rend, inevow, tags as T
from nevow.inevow import IRequest
-from foolscap.eventual import fireEventually
+from foolscap.api import fireEventually
from allmydata.util import base32, time_format
from allmydata.uri import from_string_dirnode
import time
from nevow import rend, inevow
-from foolscap.referenceable import SturdyRef
+from foolscap.api import SturdyRef
from twisted.internet import address
import allmydata
import simplejson