switch all foolscap imports to use foolscap.api or foolscap.logging

This commit is contained in:
Brian Warner 2009-05-21 17:38:23 -07:00
parent 5d04c5b601
commit c9803d5217
45 changed files with 90 additions and 103 deletions

View File

@ -136,12 +136,12 @@ def get_package_versions_and_locations():
# because there are a few dependencies that are outside setuptools's ken (Python and # 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 # platform), and because setuptools might fail to find something even though import finds
# it: # 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 = { d1 = {
'pyOpenSSL': (OpenSSL.__version__, os.path.dirname(OpenSSL.__file__)), 'pyOpenSSL': (OpenSSL.__version__, os.path.dirname(OpenSSL.__file__)),
'allmydata-tahoe': (allmydata.__version__, os.path.dirname(allmydata.__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__)), 'Nevow': (nevow.__version__, os.path.dirname(nevow.__file__)),
'pycryptopp': (pycryptopp.__version__, os.path.dirname(pycryptopp.__file__)), 'pycryptopp': (pycryptopp.__version__, os.path.dirname(pycryptopp.__file__)),
'setuptools': (setuptools.__version__, os.path.dirname(setuptools.__file__)), 'setuptools': (setuptools.__version__, os.path.dirname(setuptools.__file__)),

View File

@ -5,7 +5,7 @@ from allmydata import node
from zope.interface import implements from zope.interface import implements
from twisted.internet import reactor from twisted.internet import reactor
from twisted.application.internet import TimerService from twisted.application.internet import TimerService
from foolscap import Referenceable from foolscap.api import Referenceable
from foolscap.logging import log from foolscap.logging import log
from pycryptopp.publickey import rsa from pycryptopp.publickey import rsa

View File

@ -3,7 +3,7 @@ import os, time
from zope.interface import implements from zope.interface import implements
from twisted.application import service from twisted.application import service
from twisted.internet import defer from twisted.internet import defer
from foolscap import Referenceable from foolscap.api import Referenceable
from allmydata.interfaces import RIControlClient from allmydata.interfaces import RIControlClient
from allmydata.util import fileutil, mathutil from allmydata.util import fileutil, mathutil
from allmydata.immutable import upload, download from allmydata.immutable import upload, download

View File

@ -3,7 +3,7 @@ import os, time, math
from zope.interface import implements from zope.interface import implements
from twisted.internet import defer from twisted.internet import defer
from foolscap.eventual import fireEventually from foolscap.api import fireEventually
import simplejson import simplejson
from allmydata.mutable.common import NotMutableError from allmydata.mutable.common import NotMutableError
from allmydata.mutable.filenode import MutableFileNode from allmydata.mutable.filenode import MutableFileNode

View File

@ -28,7 +28,7 @@ import allmydata
#import amdicon #import amdicon
import amdlogo import amdlogo
import foolscap from foolscap.api import Tub
from twisted.python import usage from twisted.python import usage
class AuthError(Exception): class AuthError(Exception):
@ -124,7 +124,7 @@ def write_root_cap(root_cap):
def get_nodeid(): def get_nodeid():
CERTFILE = "node.pem" CERTFILE = "node.pem"
certfile = os.path.join(get_basedir(), "private", CERTFILE) certfile = os.path.join(get_basedir(), "private", CERTFILE)
tub = foolscap.Tub(certFile=certfile) tub = Tub(certFile=certfile)
return tub.getTubID() return tub.getTubID()
def get_nickname(): def get_nickname():

View File

@ -1,4 +1,4 @@
from foolscap import DeadReferenceError from foolscap.api import DeadReferenceError
from twisted.internet import defer from twisted.internet import defer
from allmydata import hashtree from allmydata import hashtree
from allmydata.check_results import CheckResults from allmydata.check_results import CheckResults

View File

@ -3,8 +3,7 @@ from zope.interface import implements
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IPushProducer, IConsumer from twisted.internet.interfaces import IPushProducer, IConsumer
from twisted.application import service from twisted.application import service
from foolscap import DeadReferenceError from foolscap.api import DeadReferenceError, eventually
from foolscap.eventual import eventually
from allmydata.util import base32, deferredutil, hashutil, log, mathutil from allmydata.util import base32, deferredutil, hashutil, log, mathutil
from allmydata.util.assertutil import _assert, precondition from allmydata.util.assertutil import _assert, precondition

View File

@ -3,7 +3,7 @@
import time import time
from zope.interface import implements from zope.interface import implements
from twisted.internet import defer from twisted.internet import defer
from foolscap import eventual from foolscap.api import fireEventually
from allmydata import uri from allmydata import uri
from allmydata.storage.server import si_b2a from allmydata.storage.server import si_b2a
from allmydata.hashtree import HashTree from allmydata.hashtree import HashTree
@ -220,7 +220,7 @@ class Encoder(object):
} }
self._start_total_timestamp = time.time() self._start_total_timestamp = time.time()
d = eventual.fireEventually() d = fireEventually()
d.addCallback(lambda res: self.start_all_shareholders()) d.addCallback(lambda res: self.start_all_shareholders())
@ -278,7 +278,7 @@ class Encoder(object):
# consistency will cause objects to live for longer than you might # consistency will cause objects to live for longer than you might
# normally expect. # normally expect.
return eventual.fireEventually(res) return fireEventually(res)
def start_all_shareholders(self): def start_all_shareholders(self):

View File

@ -4,7 +4,7 @@ from zope.interface import implements
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IPushProducer, IConsumer from twisted.internet.interfaces import IPushProducer, IConsumer
from twisted.protocols import basic from twisted.protocols import basic
from foolscap.eventual import eventually from foolscap.api import eventually
from allmydata.interfaces import IFileNode, IFileURI, ICheckable, \ from allmydata.interfaces import IFileNode, IFileURI, ICheckable, \
IDownloadTarget, IUploadResults IDownloadTarget, IUploadResults
from allmydata.util import dictutil, log, base32 from allmydata.util import dictutil, log, base32

View File

@ -3,8 +3,7 @@ import os, stat, time, weakref
from zope.interface import implements from zope.interface import implements
from twisted.application import service from twisted.application import service
from twisted.internet import defer from twisted.internet import defer
from foolscap import Referenceable, DeadReferenceError from foolscap.api import Referenceable, DeadReferenceError, eventually
from foolscap.eventual import eventually
import allmydata # for __full_version__ import allmydata # for __full_version__
from allmydata import interfaces, uri from allmydata import interfaces, uri
from allmydata.storage.server import si_b2a from allmydata.storage.server import si_b2a

View File

@ -3,8 +3,7 @@ from zope.interface import implements
from twisted.python import failure from twisted.python import failure
from twisted.internet import defer from twisted.internet import defer
from twisted.application import service from twisted.application import service
from foolscap import Referenceable, Copyable, RemoteCopy from foolscap.api import Referenceable, Copyable, RemoteCopy, fireEventually
from foolscap import eventual
from allmydata.util.hashutil import file_renewal_secret_hash, \ from allmydata.util.hashutil import file_renewal_secret_hash, \
file_cancel_secret_hash, bucket_renewal_secret_hash, \ file_cancel_secret_hash, bucket_renewal_secret_hash, \
@ -529,7 +528,7 @@ class EncryptAnUploadable:
# actually synchronous too, we'd blow the stack unless we stall for a # actually synchronous too, we'd blow the stack unless we stall for a
# tick. Once you accept a Deferred from IUploadable.read(), you must # tick. Once you accept a Deferred from IUploadable.read(), you must
# be prepared to have it fire immediately too. # be prepared to have it fire immediately too.
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
def _good(plaintext): def _good(plaintext):
# and encrypt it.. # and encrypt it..
# o/' over the fields we go, hashing all the way, sHA! sHA! sHA! o/' # o/' over the fields we go, hashing all the way, sHA! sHA! sHA! o/'

View File

@ -1,8 +1,7 @@
from zope.interface import Interface from zope.interface import Interface
from foolscap.schema import StringConstraint, ListOf, TupleOf, SetOf, DictOf, \ from foolscap.api import StringConstraint, ListOf, TupleOf, SetOf, DictOf, \
ChoiceOf, IntegerConstraint, Any ChoiceOf, IntegerConstraint, Any, RemoteInterface, Referenceable
from foolscap import RemoteInterface, Referenceable
HASH_SIZE=32 HASH_SIZE=32

View File

@ -3,7 +3,7 @@ import re, time, sha
from base64 import b32decode from base64 import b32decode
from zope.interface import implements from zope.interface import implements
from twisted.application import service from twisted.application import service
from foolscap import Referenceable from foolscap.api import Referenceable
from allmydata.interfaces import InsufficientVersionError from allmydata.interfaces import InsufficientVersionError
from allmydata.introducer.interfaces import RIIntroducerSubscriberClient, \ from allmydata.introducer.interfaces import RIIntroducerSubscriberClient, \
IIntroducerClient IIntroducerClient

View File

@ -1,7 +1,7 @@
from zope.interface import Interface from zope.interface import Interface
from foolscap.schema import StringConstraint, TupleOf, SetOf, DictOf, Any from foolscap.api import StringConstraint, TupleOf, SetOf, DictOf, Any, \
from foolscap import RemoteInterface RemoteInterface
FURL = StringConstraint(1000) FURL = StringConstraint(1000)
# Announcements are (FURL, service_name, remoteinterface_name, # Announcements are (FURL, service_name, remoteinterface_name,

View File

@ -7,7 +7,7 @@ import re, time, sha
from base64 import b32decode from base64 import b32decode
from zope.interface import implements from zope.interface import implements
from twisted.application import service from twisted.application import service
from foolscap import Referenceable from foolscap.api import Referenceable
from allmydata.util import log, idlib from allmydata.util import log, idlib
from allmydata.introducer.interfaces import RIIntroducerSubscriberClient, \ from allmydata.introducer.interfaces import RIIntroducerSubscriberClient, \
IIntroducerClient, RIIntroducerPublisherAndSubscriberService IIntroducerClient, RIIntroducerPublisherAndSubscriberService

View File

@ -2,7 +2,7 @@
import time, os.path import time, os.path
from zope.interface import implements from zope.interface import implements
from twisted.application import service from twisted.application import service
from foolscap import Referenceable from foolscap.api import Referenceable
import allmydata import allmydata
from allmydata import node from allmydata import node
from allmydata.util import log from allmydata.util import log

View File

@ -2,7 +2,7 @@
import os import os
import time import time
import foolscap from foolscap.api import Referenceable, Tub
from zope.interface import implements from zope.interface import implements
from twisted.internet import reactor from twisted.internet import reactor
from twisted.application import service from twisted.application import service
@ -11,7 +11,7 @@ from allmydata.util import log
from pycryptopp.publickey import rsa from pycryptopp.publickey import rsa
from allmydata.interfaces import RIKeyGenerator from allmydata.interfaces import RIKeyGenerator
class KeyGenerator(service.MultiService, foolscap.Referenceable): class KeyGenerator(service.MultiService, Referenceable):
implements(RIKeyGenerator) implements(RIKeyGenerator)
pool_size = 16 # no. keys to keep on hand in the pool pool_size = 16 # no. keys to keep on hand in the pool
@ -79,7 +79,7 @@ class KeyGeneratorService(service.MultiService):
def __init__(self, basedir='.', display_furl=True, default_key_size=2048): def __init__(self, basedir='.', display_furl=True, default_key_size=2048):
service.MultiService.__init__(self) service.MultiService.__init__(self)
self.basedir = basedir 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.tub.setServiceParent(self)
self.key_generator = KeyGenerator(default_key_size=default_key_size) self.key_generator = KeyGenerator(default_key_size=default_key_size)
self.key_generator.setServiceParent(self) self.key_generator.setServiceParent(self)

View File

@ -3,7 +3,7 @@ import random
from zope.interface import implements from zope.interface import implements
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from foolscap.eventual import eventually from foolscap.api import eventually
from allmydata.interfaces import IMutableFileNode, IMutableFileURI, \ from allmydata.interfaces import IMutableFileNode, IMutableFileURI, \
ICheckable, ICheckResults, NotEnoughSharesError ICheckable, ICheckResults, NotEnoughSharesError
from allmydata.util import hashutil, log from allmydata.util import hashutil, log

View File

@ -10,7 +10,7 @@ from allmydata.util import base32, hashutil, mathutil, idlib, log
from allmydata import hashtree, codec from allmydata import hashtree, codec
from allmydata.storage.server import si_b2a from allmydata.storage.server import si_b2a
from pycryptopp.cipher.aes import AES from pycryptopp.cipher.aes import AES
from foolscap.eventual import eventually from foolscap.api import eventually
from common import MODE_WRITE, MODE_CHECK, DictOfSets, \ from common import MODE_WRITE, MODE_CHECK, DictOfSets, \
UncoordinatedWriteError, NotEnoughServersError UncoordinatedWriteError, NotEnoughServersError

View File

@ -4,8 +4,7 @@ from itertools import count
from zope.interface import implements from zope.interface import implements
from twisted.internet import defer from twisted.internet import defer
from twisted.python import failure from twisted.python import failure
from foolscap import DeadReferenceError from foolscap.api import DeadReferenceError, eventually, fireEventually
from foolscap.eventual import eventually, fireEventually
from allmydata.interfaces import IRetrieveStatus, NotEnoughSharesError from allmydata.interfaces import IRetrieveStatus, NotEnoughSharesError
from allmydata.util import hashutil, idlib, log from allmydata.util import hashutil, idlib, log
from allmydata import hashtree, codec from allmydata import hashtree, codec

View File

@ -4,8 +4,7 @@ from zope.interface import implements
from itertools import count from itertools import count
from twisted.internet import defer from twisted.internet import defer
from twisted.python import failure from twisted.python import failure
from foolscap import DeadReferenceError from foolscap.api import DeadReferenceError, eventually
from foolscap.eventual import eventually
from allmydata.util import base32, hashutil, idlib, log, rrefutil from allmydata.util import base32, hashutil, idlib, log, rrefutil
from allmydata.storage.server import si_b2a from allmydata.storage.server import si_b2a
from allmydata.interfaces import IServermapUpdaterStatus from allmydata.interfaces import IServermapUpdaterStatus

View File

@ -5,15 +5,13 @@ from base64 import b32decode, b32encode
from twisted.python import log as twlog from twisted.python import log as twlog
from twisted.application import service from twisted.application import service
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from foolscap import Tub, eventual from foolscap.api import Tub, eventually, app_versions
import foolscap.logging.log import foolscap.logging.log
from allmydata import get_package_versions, get_package_versions_string from allmydata import get_package_versions, get_package_versions_string
from allmydata.util import log from allmydata.util import log
from allmydata.util import fileutil, iputil, observer from allmydata.util import fileutil, iputil, observer
from allmydata.util.assertutil import precondition, _assert from allmydata.util.assertutil import precondition, _assert
from foolscap.logging import app_versions
# Add our application versions to the data that Foolscap's LogPublisher # Add our application versions to the data that Foolscap's LogPublisher
# reports. # reports.
for thing, things_version in get_package_versions().iteritems(): for thing, things_version in get_package_versions().iteritems():
@ -243,7 +241,7 @@ class Node(service.MultiService):
except EnvironmentError: except EnvironmentError:
pass pass
# Delay until the reactor is running. # Delay until the reactor is running.
eventual.eventually(self._startService) eventually(self._startService)
def _startService(self): def _startService(self):
precondition(reactor.running) precondition(reactor.running)

View File

@ -9,10 +9,8 @@ from twisted.internet import reactor
from twisted.application import service from twisted.application import service
from twisted.application.internet import TimerService from twisted.application.internet import TimerService
from zope.interface import implements from zope.interface import implements
import foolscap from foolscap.api import eventually, DeadReferenceError, Referenceable, Tub
from foolscap.eventual import eventually
from twisted.internet.error import ConnectionDone, ConnectionLost from twisted.internet.error import ConnectionDone, ConnectionLost
from foolscap import DeadReferenceError
from allmydata.util import log from allmydata.util import log
from allmydata.interfaces import RIStatsProvider, RIStatsGatherer, IStatsProducer from allmydata.interfaces import RIStatsProvider, RIStatsGatherer, IStatsProducer
@ -124,7 +122,7 @@ class CPUUsageMonitor(service.MultiService):
return s return s
class StatsProvider(foolscap.Referenceable, service.MultiService): class StatsProvider(Referenceable, service.MultiService):
implements(RIStatsProvider) implements(RIStatsProvider)
def __init__(self, node, gatherer_furl): def __init__(self, node, gatherer_furl):
@ -180,7 +178,7 @@ class StatsProvider(foolscap.Referenceable, service.MultiService):
gatherer.callRemoteOnly('provide', self, nickname or '') gatherer.callRemoteOnly('provide', self, nickname or '')
class StatsGatherer(foolscap.Referenceable, service.MultiService): class StatsGatherer(Referenceable, service.MultiService):
implements(RIStatsGatherer) implements(RIStatsGatherer)
poll_interval = 60 poll_interval = 60
@ -196,7 +194,7 @@ class StatsGatherer(foolscap.Referenceable, service.MultiService):
self.timer.setServiceParent(self) self.timer.setServiceParent(self)
def get_tubid(self, rref): def get_tubid(self, rref):
return foolscap.SturdyRef(rref.tracker.getURL()).getTubRef().getTubID() return rref.getRemoteTubID()
def remote_provide(self, provider, nickname): def remote_provide(self, provider, nickname):
tubid = self.get_tubid(provider) tubid = self.get_tubid(provider)
@ -282,8 +280,8 @@ class StatsGathererService(service.MultiService):
def __init__(self, basedir=".", verbose=False): def __init__(self, basedir=".", verbose=False):
service.MultiService.__init__(self) service.MultiService.__init__(self)
self.basedir = basedir self.basedir = basedir
self.tub = foolscap.Tub(certFile=os.path.join(self.basedir, self.tub = Tub(certFile=os.path.join(self.basedir,
"stats_gatherer.pem")) "stats_gatherer.pem"))
self.tub.setServiceParent(self) self.tub.setServiceParent(self)
self.tub.setOption("logLocalFailures", True) self.tub.setOption("logLocalFailures", True)
self.tub.setOption("logRemoteFailures", True) self.tub.setOption("logRemoteFailures", True)

View File

@ -1,6 +1,6 @@
import os, stat, struct, time import os, stat, struct, time
from foolscap import Referenceable from foolscap.api import Referenceable
from zope.interface import implements from zope.interface import implements
from allmydata.interfaces import RIBucketWriter, RIBucketReader from allmydata.interfaces import RIBucketWriter, RIBucketReader

View File

@ -1,6 +1,6 @@
import os, re, weakref, struct, time import os, re, weakref, struct, time
from foolscap import Referenceable from foolscap.api import Referenceable
from twisted.application import service from twisted.application import service
from zope.interface import implements from zope.interface import implements

View File

@ -9,8 +9,7 @@ from allmydata import client, introducer
from allmydata.immutable import upload from allmydata.immutable import upload
from allmydata.scripts import create_node from allmydata.scripts import create_node
from allmydata.util import fileutil, pollmixin from allmydata.util import fileutil, pollmixin
import foolscap from foolscap.api import Tub, fireEventually, flushEventualQueue
from foolscap import eventual
from twisted.python import log from twisted.python import log
class StallableHTTPGetterDiscarder(tw_client.HTTPPageGetter): class StallableHTTPGetterDiscarder(tw_client.HTTPPageGetter):
@ -74,7 +73,7 @@ class SystemFramework(pollmixin.PollMixin):
self.sparent = service.MultiService() self.sparent = service.MultiService()
self.sparent.startService() self.sparent.startService()
self.proc = None self.proc = None
self.tub = foolscap.Tub() self.tub = Tub()
self.tub.setServiceParent(self.sparent) self.tub.setServiceParent(self.sparent)
self.mode = mode self.mode = mode
self.failed = False self.failed = False
@ -87,7 +86,7 @@ class SystemFramework(pollmixin.PollMixin):
#logfile = open(os.path.join(self.testdir, "log"), "w") #logfile = open(os.path.join(self.testdir, "log"), "w")
#flo = log.FileLogObserver(logfile) #flo = log.FileLogObserver(logfile)
#log.startLoggingWithObserver(flo.emit, setStdout=False) #log.startLoggingWithObserver(flo.emit, setStdout=False)
d = eventual.fireEventually() d = fireEventually()
d.addCallback(lambda res: self.setUp()) d.addCallback(lambda res: self.setUp())
d.addCallback(lambda res: self.record_initial_memusage()) d.addCallback(lambda res: self.record_initial_memusage())
d.addCallback(lambda res: self.make_nodes()) d.addCallback(lambda res: self.make_nodes())
@ -154,7 +153,7 @@ class SystemFramework(pollmixin.PollMixin):
if self.proc: if self.proc:
d.addCallback(lambda res: self.kill_client()) d.addCallback(lambda res: self.kill_client())
d.addCallback(lambda res: self.sparent.stopService()) d.addCallback(lambda res: self.sparent.stopService())
d.addCallback(lambda res: eventual.flushEventualQueue()) d.addCallback(lambda res: flushEventualQueue())
def _close_statsfile(res): def _close_statsfile(res):
self.statsfile.close() self.statsfile.close()
d.addCallback(_close_statsfile) d.addCallback(_close_statsfile)

View File

@ -4,7 +4,7 @@ import os, sys
from twisted.internet import reactor, defer from twisted.internet import reactor, defer
from twisted.python import log from twisted.python import log
from twisted.application import service from twisted.application import service
from foolscap import Tub, eventual from foolscap.api import Tub, fireEventually
MB = 1000000 MB = 1000000
@ -26,7 +26,7 @@ class SpeedTest:
def run(self): def run(self):
print "STARTING" print "STARTING"
d = eventual.fireEventually() d = fireEventually()
d.addCallback(lambda res: self.setUp()) d.addCallback(lambda res: self.setUp())
d.addCallback(lambda res: self.do_test()) d.addCallback(lambda res: self.do_test())
d.addBoth(self.tearDown) d.addBoth(self.tearDown)

View File

@ -5,7 +5,7 @@ from twisted.internet.interfaces import IConsumer
from twisted.python import failure from twisted.python import failure
from twisted.application import service from twisted.application import service
from twisted.web.error import Error as WebError 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 import uri, dirnode, client
from allmydata.introducer.server import IntroducerNode from allmydata.introducer.server import IntroducerNode
from allmydata.interfaces import IURI, IMutableFileNode, IFileNode, \ from allmydata.interfaces import IURI, IMutableFileNode, IFileNode, \

View File

@ -17,8 +17,7 @@ import os.path
import sha import sha
from twisted.application import service from twisted.application import service
from twisted.internet import reactor from twisted.internet import reactor
from foolscap import Referenceable from foolscap.api import Referenceable, fireEventually
from foolscap.eventual import fireEventually
from base64 import b32encode from base64 import b32encode
from allmydata import uri as tahoe_uri from allmydata import uri as tahoe_uri
from allmydata.client import Client from allmydata.client import Client

View File

@ -8,7 +8,7 @@ import allmydata
from allmydata import client from allmydata import client
from allmydata.introducer.client import IntroducerClient from allmydata.introducer.client import IntroducerClient
from allmydata.util import base32 from allmydata.util import base32
from foolscap.eventual import flushEventualQueue from foolscap.api import flushEventualQueue
import common_util as testutil import common_util as testutil
class FakeIntroducerClient(IntroducerClient): class FakeIntroducerClient(IntroducerClient):

View File

@ -4,7 +4,7 @@ import os.path
from twisted.trial import unittest from twisted.trial import unittest
from twisted.application import service from twisted.application import service
from twisted.internet import defer from twisted.internet import defer
from foolscap import eventual from foolscap.api import eventually, fireEventually
from allmydata.util import fileutil, hashutil, pollmixin from allmydata.util import fileutil, hashutil, pollmixin
from allmydata.storage.server import StorageServer, si_b2a from allmydata.storage.server import StorageServer, si_b2a
@ -23,7 +23,7 @@ class BucketEnumeratingCrawler(ShareCrawler):
def process_bucket(self, cycle, prefix, prefixdir, storage_index_b32): def process_bucket(self, cycle, prefix, prefixdir, storage_index_b32):
self.all_buckets.append(storage_index_b32) self.all_buckets.append(storage_index_b32)
def finished_cycle(self, cycle): def finished_cycle(self, cycle):
eventual.eventually(self.finished_d.callback, None) eventually(self.finished_d.callback, None)
class PacedCrawler(ShareCrawler): class PacedCrawler(ShareCrawler):
cpu_slice = 500 # make sure it can complete in a single slice cpu_slice = 500 # make sure it can complete in a single slice
@ -45,7 +45,7 @@ class PacedCrawler(ShareCrawler):
if self.yield_cb: if self.yield_cb:
self.yield_cb() self.yield_cb()
def finished_cycle(self, cycle): def finished_cycle(self, cycle):
eventual.eventually(self.finished_d.callback, None) eventually(self.finished_d.callback, None)
class ConsumingCrawler(ShareCrawler): class ConsumingCrawler(ShareCrawler):
cpu_slice = 0.5 cpu_slice = 0.5
@ -420,7 +420,7 @@ class Basic(unittest.TestCase, StallMixin, pollmixin.PollMixin):
d = c.finished_d d = c.finished_d
def _finished_first_cycle(ignored): def _finished_first_cycle(ignored):
return eventual.fireEventually(c.counter) return fireEventually(c.counter)
d.addCallback(_finished_first_cycle) d.addCallback(_finished_first_cycle)
def _check(old_counter): def _check(old_counter):
# the crawler should do any work after it's been stopped # the crawler should do any work after it's been stopped

View File

@ -3,7 +3,7 @@ from twisted.trial import unittest
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from twisted.internet.interfaces import IConsumer from twisted.internet.interfaces import IConsumer
from twisted.python.failure import Failure from twisted.python.failure import Failure
from foolscap import eventual from foolscap.api import fireEventually
from allmydata import hashtree, uri from allmydata import hashtree, uri
from allmydata.immutable import encode, upload, download from allmydata.immutable import encode, upload, download
from allmydata.util import hashutil from allmydata.util import hashutil
@ -40,7 +40,7 @@ class FakeBucketReaderWriterProxy:
def _start(self): def _start(self):
if self.mode == "lost-early": if self.mode == "lost-early":
f = Failure(LostPeerError("I went away early")) f = Failure(LostPeerError("I went away early"))
return eventual.fireEventually(f) return fireEventually(f)
return defer.succeed(self) return defer.succeed(self)
def put_header(self): def put_header(self):
@ -49,7 +49,7 @@ class FakeBucketReaderWriterProxy:
def put_block(self, segmentnum, data): def put_block(self, segmentnum, data):
if self.mode == "lost-early": if self.mode == "lost-early":
f = Failure(LostPeerError("I went away early")) f = Failure(LostPeerError("I went away early"))
return eventual.fireEventually(f) return fireEventually(f)
def _try(): def _try():
assert not self.closed assert not self.closed
assert segmentnum not in self.blocks assert segmentnum not in self.blocks

View File

@ -2,7 +2,7 @@ import os
from twisted.trial import unittest from twisted.trial import unittest
from twisted.application import service from twisted.application import service
from foolscap import Tub, eventual from foolscap.api import Tub, fireEventually, flushEventualQueue
from foolscap.logging import log from foolscap.logging import log
from allmydata.storage.server import si_b2a from allmydata.storage.server import si_b2a
@ -70,19 +70,19 @@ class FakeClient(service.MultiService):
return [] return []
def flush_but_dont_ignore(res): def flush_but_dont_ignore(res):
d = eventual.flushEventualQueue() d = flushEventualQueue()
def _done(ignored): def _done(ignored):
return res return res
d.addCallback(_done) d.addCallback(_done)
return d return d
def wait_a_few_turns(ignored=None): def wait_a_few_turns(ignored=None):
d = eventual.fireEventually() d = fireEventually()
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
return d return d
def upload_data(uploader, data, convergence): def upload_data(uploader, data, convergence):
@ -110,7 +110,7 @@ class AssistedUpload(unittest.TestCase):
def tearDown(self): def tearDown(self):
d = self.s.stopService() d = self.s.stopService()
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
d.addBoth(flush_but_dont_ignore) d.addBoth(flush_but_dont_ignore)
return d return d

View File

@ -6,8 +6,7 @@ from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from twisted.python import log from twisted.python import log
from foolscap import Tub, Referenceable from foolscap.api import Tub, Referenceable, fireEventually, flushEventualQueue
from foolscap.eventual import fireEventually, flushEventualQueue
from twisted.application import service from twisted.application import service
from allmydata.interfaces import InsufficientVersionError from allmydata.interfaces import InsufficientVersionError
from allmydata.introducer.client import IntroducerClient from allmydata.introducer.client import IntroducerClient

View File

@ -3,14 +3,14 @@ import os
from twisted.trial import unittest from twisted.trial import unittest
from twisted.application import service from twisted.application import service
from foolscap import Tub, eventual from foolscap.api import Tub, fireEventually, flushEventualQueue
from allmydata import key_generator from allmydata import key_generator
from allmydata.util import pollmixin from allmydata.util import pollmixin
from pycryptopp.publickey import rsa from pycryptopp.publickey import rsa
def flush_but_dont_ignore(res): def flush_but_dont_ignore(res):
d = eventual.flushEventualQueue() d = flushEventualQueue()
def _done(ignored): def _done(ignored):
return res return res
d.addCallback(_done) d.addCallback(_done)
@ -25,11 +25,11 @@ class KeyGenService(unittest.TestCase, pollmixin.PollMixin):
t.setServiceParent(self.parent) t.setServiceParent(self.parent)
t.listenOn("tcp:0") t.listenOn("tcp:0")
t.setLocationAutomatically() t.setLocationAutomatically()
return eventual.fireEventually() return fireEventually()
def tearDown(self): def tearDown(self):
d = self.parent.stopService() d = self.parent.stopService()
d.addCallback(eventual.fireEventually) d.addCallback(fireEventually)
d.addBoth(flush_but_dont_ignore) d.addBoth(flush_but_dont_ignore)
return d return d
@ -50,7 +50,7 @@ class KeyGenService(unittest.TestCase, pollmixin.PollMixin):
return len(kgs.key_generator.keypool) == kgs.key_generator.pool_size return len(kgs.key_generator.keypool) == kgs.key_generator.pool_size
# first wait for key gen pool to fill up # 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(p, 'waiting for pool to fill up')
d.addCallback(lambda junk: self.poll(keypool_full)) d.addCallback(lambda junk: self.poll(keypool_full))

View File

@ -15,7 +15,7 @@ from allmydata.interfaces import IURI, IMutableFileURI, IUploadable, \
FileTooLargeError, NotEnoughSharesError, IRepairResults FileTooLargeError, NotEnoughSharesError, IRepairResults
from allmydata.monitor import Monitor from allmydata.monitor import Monitor
from allmydata.test.common import ShouldFailMixin from allmydata.test.common import ShouldFailMixin
from foolscap.eventual import eventually, fireEventually from foolscap.api import eventually, fireEventually
from foolscap.logging import log from foolscap.logging import log
import sha import sha

View File

@ -4,7 +4,7 @@ from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from twisted.python import log from twisted.python import log
from foolscap.eventual import flushEventualQueue from foolscap.api import flushEventualQueue
from twisted.application import service from twisted.application import service
from allmydata.node import Node, formatTimeTahoeStyle from allmydata.node import Node, formatTimeTahoeStyle
from allmydata.util import fileutil from allmydata.util import fileutil

View File

@ -5,7 +5,7 @@ from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from twisted.application import service from twisted.application import service
from foolscap import eventual from foolscap.api import fireEventually
import itertools import itertools
from allmydata import interfaces from allmydata import interfaces
from allmydata.util import fileutil, hashutil, base32, pollmixin, time_format from allmydata.util import fileutil, hashutil, base32, pollmixin, time_format
@ -1391,7 +1391,7 @@ class BucketCounter(unittest.TestCase, pollmixin.PollMixin):
# cpu_slice=0 will force it to yield right after it processes the # cpu_slice=0 will force it to yield right after it processes the
# first prefix # first prefix
d = eventual.fireEventually() d = fireEventually()
def _check(ignored): def _check(ignored):
# are we really right after the first prefix? # are we really right after the first prefix?
state = ss.bucket_counter.get_state() state = ss.bucket_counter.get_state()
@ -1428,7 +1428,7 @@ class BucketCounter(unittest.TestCase, pollmixin.PollMixin):
ss.bucket_counter.cpu_slice = 0 ss.bucket_counter.cpu_slice = 0
ss.setServiceParent(self.s) ss.setServiceParent(self.s)
d = eventual.fireEventually() d = fireEventually()
def _after_first_prefix(ignored): def _after_first_prefix(ignored):
ss.bucket_counter.cpu_slice = 100.0 # finish as fast as possible ss.bucket_counter.cpu_slice = 100.0 # finish as fast as possible
@ -1613,7 +1613,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
DAY = 24*60*60 DAY = 24*60*60
d = eventual.fireEventually() d = fireEventually()
# now examine the state right after the first bucket has been # now examine the state right after the first bucket has been
# processed. # processed.
@ -1813,7 +1813,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
ss.setServiceParent(self.s) ss.setServiceParent(self.s)
d = eventual.fireEventually() d = fireEventually()
# examine the state right after the first bucket has been processed # examine the state right after the first bucket has been processed
def _after_first_bucket(ignored): def _after_first_bucket(ignored):
p = lc.get_progress() p = lc.get_progress()
@ -1954,7 +1954,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
ss.setServiceParent(self.s) ss.setServiceParent(self.s)
d = eventual.fireEventually() d = fireEventually()
# examine the state right after the first bucket has been processed # examine the state right after the first bucket has been processed
def _after_first_bucket(ignored): def _after_first_bucket(ignored):
p = lc.get_progress() p = lc.get_progress()
@ -2220,7 +2220,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
ss.setServiceParent(self.s) ss.setServiceParent(self.s)
d = eventual.fireEventually() d = fireEventually()
def _check(ignored): def _check(ignored):
# this should fire after the first bucket is complete, but before # this should fire after the first bucket is complete, but before
# the first prefix is complete, so the progress-measurer won't # the first prefix is complete, so the progress-measurer won't
@ -2338,7 +2338,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin):
ss.setServiceParent(self.s) ss.setServiceParent(self.s)
d = eventual.fireEventually() d = fireEventually()
# now examine the state right after the first bucket has been # now examine the state right after the first bucket has been
# processed. # processed.

View File

@ -20,7 +20,7 @@ from allmydata.interfaces import IDirectoryNode, IFileNode, IFileURI, \
from allmydata.monitor import Monitor from allmydata.monitor import Monitor
from allmydata.mutable.common import NotMutableError from allmydata.mutable.common import NotMutableError
from allmydata.mutable import layout as mutable_layout 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.python.failure import Failure
from twisted.web.client import getPage from twisted.web.client import getPage
from twisted.web.error import Error from twisted.web.error import Error

View File

@ -5,7 +5,7 @@ from twisted.trial import unittest
from twisted.python.failure import Failure from twisted.python.failure import Failure
from twisted.python import log from twisted.python import log
from twisted.internet import defer from twisted.internet import defer
from foolscap import eventual from foolscap.api import fireEventually
import allmydata # for __full_version__ import allmydata # for __full_version__
from allmydata import uri, monitor from allmydata import uri, monitor
@ -97,7 +97,7 @@ class FakeStorageServer:
def _call(): def _call():
meth = getattr(self, methname) meth = getattr(self, methname)
return meth(*args, **kwargs) return meth(*args, **kwargs)
d = eventual.fireEventually() d = fireEventually()
d.addCallback(lambda res: _call()) d.addCallback(lambda res: _call())
return d return d
@ -128,7 +128,7 @@ class FakeBucketWriter:
def _call(): def _call():
meth = getattr(self, "remote_" + methname) meth = getattr(self, "remote_" + methname)
return meth(*args, **kwargs) return meth(*args, **kwargs)
d = eventual.fireEventually() d = fireEventually()
d.addCallback(lambda res: _call()) d.addCallback(lambda res: _call())
return d return d

View File

@ -1,6 +1,6 @@
from twisted.internet import defer from twisted.internet import defer
from foolscap.eventual import eventually from foolscap.api import eventually
class ConcurrencyLimiter: class ConcurrencyLimiter:
"""I implement a basic concurrency limiter. Add work to it in the form of """I implement a basic concurrency limiter. Add work to it in the form of

View File

@ -1,7 +1,7 @@
# -*- test-case-name: allmydata.test.test_observer -*- # -*- test-case-name: allmydata.test.test_observer -*-
from twisted.internet import defer 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 """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 'when_something', which returns a deferred. That deferred will be fired when

View File

@ -1,6 +1,6 @@
import exceptions import exceptions
from foolscap.tokens import Violation from foolscap.api import Violation
class ServerFailure(exceptions.Exception): class ServerFailure(exceptions.Exception):
# If the server returns a Failure instead of the normal response to a # If the server returns a Failure instead of the normal response to a

View File

@ -10,7 +10,7 @@ from twisted.web import http, html
from nevow import url, rend, inevow, tags as T from nevow import url, rend, inevow, tags as T
from nevow.inevow import IRequest from nevow.inevow import IRequest
from foolscap.eventual import fireEventually from foolscap.api import fireEventually
from allmydata.util import base32, time_format from allmydata.util import base32, time_format
from allmydata.uri import from_string_dirnode from allmydata.uri import from_string_dirnode

View File

@ -1,7 +1,7 @@
import time import time
from nevow import rend, inevow from nevow import rend, inevow
from foolscap.referenceable import SturdyRef from foolscap.api import SturdyRef
from twisted.internet import address from twisted.internet import address
import allmydata import allmydata
import simplejson import simplejson