From: Brian Warner Date: Fri, 22 May 2009 00:38:23 +0000 (-0700) Subject: switch all foolscap imports to use foolscap.api or foolscap.logging X-Git-Url: https://git.rkrishnan.org/uri?a=commitdiff_plain;h=c9803d521747d7da939a34e19520edc8f070d213;p=tahoe-lafs%2Ftahoe-lafs.git switch all foolscap imports to use foolscap.api or foolscap.logging --- diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index f86e2703..2e2d8b1d 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -136,12 +136,12 @@ def get_package_versions_and_locations(): # 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__)), diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 04401a3b..99dfa09b 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -5,7 +5,7 @@ from allmydata import node 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 diff --git a/src/allmydata/control.py b/src/allmydata/control.py index 73756605..01eb7c37 100644 --- a/src/allmydata/control.py +++ b/src/allmydata/control.py @@ -3,7 +3,7 @@ import os, time 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 diff --git a/src/allmydata/dirnode.py b/src/allmydata/dirnode.py index 4bfaeb70..cba72b23 100644 --- a/src/allmydata/dirnode.py +++ b/src/allmydata/dirnode.py @@ -3,7 +3,7 @@ import os, time, math 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 diff --git a/src/allmydata/gui/confwiz.py b/src/allmydata/gui/confwiz.py index ae48af11..3f47fb05 100644 --- a/src/allmydata/gui/confwiz.py +++ b/src/allmydata/gui/confwiz.py @@ -28,7 +28,7 @@ import allmydata #import amdicon import amdlogo -import foolscap +from foolscap.api import Tub from twisted.python import usage class AuthError(Exception): @@ -124,7 +124,7 @@ def write_root_cap(root_cap): 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(): diff --git a/src/allmydata/immutable/checker.py b/src/allmydata/immutable/checker.py index bbcd2ee9..88d7b171 100644 --- a/src/allmydata/immutable/checker.py +++ b/src/allmydata/immutable/checker.py @@ -1,4 +1,4 @@ -from foolscap import DeadReferenceError +from foolscap.api import DeadReferenceError from twisted.internet import defer from allmydata import hashtree from allmydata.check_results import CheckResults diff --git a/src/allmydata/immutable/download.py b/src/allmydata/immutable/download.py index 70907bc5..2d544ad6 100644 --- a/src/allmydata/immutable/download.py +++ b/src/allmydata/immutable/download.py @@ -3,8 +3,7 @@ from zope.interface import implements 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 diff --git a/src/allmydata/immutable/encode.py b/src/allmydata/immutable/encode.py index 310e446e..785e42d1 100644 --- a/src/allmydata/immutable/encode.py +++ b/src/allmydata/immutable/encode.py @@ -3,7 +3,7 @@ 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 @@ -220,7 +220,7 @@ class Encoder(object): } self._start_total_timestamp = time.time() - d = eventual.fireEventually() + d = fireEventually() 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 # normally expect. - return eventual.fireEventually(res) + return fireEventually(res) def start_all_shareholders(self): diff --git a/src/allmydata/immutable/filenode.py b/src/allmydata/immutable/filenode.py index 20260980..bace4357 100644 --- a/src/allmydata/immutable/filenode.py +++ b/src/allmydata/immutable/filenode.py @@ -4,7 +4,7 @@ from zope.interface import implements 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 diff --git a/src/allmydata/immutable/offloaded.py b/src/allmydata/immutable/offloaded.py index bbbc5c85..c8da456d 100644 --- a/src/allmydata/immutable/offloaded.py +++ b/src/allmydata/immutable/offloaded.py @@ -3,8 +3,7 @@ import os, stat, time, weakref 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 diff --git a/src/allmydata/immutable/upload.py b/src/allmydata/immutable/upload.py index ec3619f6..d7a4d7ad 100644 --- a/src/allmydata/immutable/upload.py +++ b/src/allmydata/immutable/upload.py @@ -3,8 +3,7 @@ from zope.interface import implements 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, \ @@ -529,7 +528,7 @@ class EncryptAnUploadable: # 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/' diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index abfeb1cc..a123afed 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -1,8 +1,7 @@ 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 diff --git a/src/allmydata/introducer/client.py b/src/allmydata/introducer/client.py index 5781abce..bd45f6e8 100644 --- a/src/allmydata/introducer/client.py +++ b/src/allmydata/introducer/client.py @@ -3,7 +3,7 @@ import re, time, sha 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 diff --git a/src/allmydata/introducer/interfaces.py b/src/allmydata/introducer/interfaces.py index 56b87b16..b02bb355 100644 --- a/src/allmydata/introducer/interfaces.py +++ b/src/allmydata/introducer/interfaces.py @@ -1,7 +1,7 @@ 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, diff --git a/src/allmydata/introducer/old.py b/src/allmydata/introducer/old.py index d3440dac..2f6fa18a 100644 --- a/src/allmydata/introducer/old.py +++ b/src/allmydata/introducer/old.py @@ -7,7 +7,7 @@ import re, time, sha 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 diff --git a/src/allmydata/introducer/server.py b/src/allmydata/introducer/server.py index d0ed6412..de511e74 100644 --- a/src/allmydata/introducer/server.py +++ b/src/allmydata/introducer/server.py @@ -2,7 +2,7 @@ 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 diff --git a/src/allmydata/key_generator.py b/src/allmydata/key_generator.py index 57a3fd1c..7d0ecdb7 100644 --- a/src/allmydata/key_generator.py +++ b/src/allmydata/key_generator.py @@ -2,7 +2,7 @@ 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 @@ -11,7 +11,7 @@ from allmydata.util import log 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 @@ -79,7 +79,7 @@ class KeyGeneratorService(service.MultiService): 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) diff --git a/src/allmydata/mutable/filenode.py b/src/allmydata/mutable/filenode.py index d7b5365c..e3f5a675 100644 --- a/src/allmydata/mutable/filenode.py +++ b/src/allmydata/mutable/filenode.py @@ -3,7 +3,7 @@ import random 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 diff --git a/src/allmydata/mutable/publish.py b/src/allmydata/mutable/publish.py index 819f8bd7..34fad3b8 100644 --- a/src/allmydata/mutable/publish.py +++ b/src/allmydata/mutable/publish.py @@ -10,7 +10,7 @@ from allmydata.util import base32, hashutil, mathutil, idlib, 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 diff --git a/src/allmydata/mutable/retrieve.py b/src/allmydata/mutable/retrieve.py index 0a6c0ea6..935ec50f 100644 --- a/src/allmydata/mutable/retrieve.py +++ b/src/allmydata/mutable/retrieve.py @@ -4,8 +4,7 @@ from itertools import count 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 diff --git a/src/allmydata/mutable/servermap.py b/src/allmydata/mutable/servermap.py index e56be746..12cf4ff0 100644 --- a/src/allmydata/mutable/servermap.py +++ b/src/allmydata/mutable/servermap.py @@ -4,8 +4,7 @@ from zope.interface import implements 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 diff --git a/src/allmydata/node.py b/src/allmydata/node.py index e9dd3b7e..b582d923 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -5,15 +5,13 @@ from base64 import b32decode, b32encode 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(): @@ -243,7 +241,7 @@ class Node(service.MultiService): except EnvironmentError: pass # Delay until the reactor is running. - eventual.eventually(self._startService) + eventually(self._startService) def _startService(self): precondition(reactor.running) diff --git a/src/allmydata/stats.py b/src/allmydata/stats.py index fc9ca9e7..685aa3d0 100644 --- a/src/allmydata/stats.py +++ b/src/allmydata/stats.py @@ -9,10 +9,8 @@ from twisted.internet import reactor 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 @@ -124,7 +122,7 @@ class CPUUsageMonitor(service.MultiService): return s -class StatsProvider(foolscap.Referenceable, service.MultiService): +class StatsProvider(Referenceable, service.MultiService): implements(RIStatsProvider) def __init__(self, node, gatherer_furl): @@ -180,7 +178,7 @@ class StatsProvider(foolscap.Referenceable, service.MultiService): gatherer.callRemoteOnly('provide', self, nickname or '') -class StatsGatherer(foolscap.Referenceable, service.MultiService): +class StatsGatherer(Referenceable, service.MultiService): implements(RIStatsGatherer) poll_interval = 60 @@ -196,7 +194,7 @@ class StatsGatherer(foolscap.Referenceable, service.MultiService): 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) @@ -282,8 +280,8 @@ class StatsGathererService(service.MultiService): 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) diff --git a/src/allmydata/storage/immutable.py b/src/allmydata/storage/immutable.py index cc58d44f..0b43b598 100644 --- a/src/allmydata/storage/immutable.py +++ b/src/allmydata/storage/immutable.py @@ -1,6 +1,6 @@ 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 diff --git a/src/allmydata/storage/server.py b/src/allmydata/storage/server.py index 1ea8e1ed..2b0f8af6 100644 --- a/src/allmydata/storage/server.py +++ b/src/allmydata/storage/server.py @@ -1,6 +1,6 @@ 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 diff --git a/src/allmydata/test/check_memory.py b/src/allmydata/test/check_memory.py index 8994cb66..bfc6b91a 100644 --- a/src/allmydata/test/check_memory.py +++ b/src/allmydata/test/check_memory.py @@ -9,8 +9,7 @@ from allmydata import client, introducer 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): @@ -74,7 +73,7 @@ class SystemFramework(pollmixin.PollMixin): 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 @@ -87,7 +86,7 @@ class SystemFramework(pollmixin.PollMixin): #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()) @@ -154,7 +153,7 @@ class SystemFramework(pollmixin.PollMixin): 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) diff --git a/src/allmydata/test/check_speed.py b/src/allmydata/test/check_speed.py index 42cfe07a..f8d0fc1d 100644 --- a/src/allmydata/test/check_speed.py +++ b/src/allmydata/test/check_speed.py @@ -4,7 +4,7 @@ import os, sys 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 @@ -26,7 +26,7 @@ class SpeedTest: 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) diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 03d5a2dd..ee5c2650 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -5,7 +5,7 @@ from twisted.internet.interfaces import IConsumer 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, \ diff --git a/src/allmydata/test/no_network.py b/src/allmydata/test/no_network.py index 421bd2a0..d417f60a 100644 --- a/src/allmydata/test/no_network.py +++ b/src/allmydata/test/no_network.py @@ -17,8 +17,7 @@ import os.path 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 diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index f878101a..5865edc5 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -8,7 +8,7 @@ import allmydata 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): diff --git a/src/allmydata/test/test_crawler.py b/src/allmydata/test/test_crawler.py index b4cf56e7..4caa2906 100644 --- a/src/allmydata/test/test_crawler.py +++ b/src/allmydata/test/test_crawler.py @@ -4,7 +4,7 @@ import os.path 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 @@ -23,7 +23,7 @@ class BucketEnumeratingCrawler(ShareCrawler): 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 @@ -45,7 +45,7 @@ class PacedCrawler(ShareCrawler): 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 @@ -420,7 +420,7 @@ class Basic(unittest.TestCase, StallMixin, pollmixin.PollMixin): 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 diff --git a/src/allmydata/test/test_encode.py b/src/allmydata/test/test_encode.py index 0e2e2a8f..b3461f35 100644 --- a/src/allmydata/test/test_encode.py +++ b/src/allmydata/test/test_encode.py @@ -3,7 +3,7 @@ from twisted.trial import unittest 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 @@ -40,7 +40,7 @@ class FakeBucketReaderWriterProxy: 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): @@ -49,7 +49,7 @@ class FakeBucketReaderWriterProxy: 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 diff --git a/src/allmydata/test/test_helper.py b/src/allmydata/test/test_helper.py index 33cfe351..e9cd0c37 100644 --- a/src/allmydata/test/test_helper.py +++ b/src/allmydata/test/test_helper.py @@ -2,7 +2,7 @@ import os 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 @@ -70,19 +70,19 @@ class FakeClient(service.MultiService): 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): @@ -110,7 +110,7 @@ class AssistedUpload(unittest.TestCase): def tearDown(self): d = self.s.stopService() - d.addCallback(eventual.fireEventually) + d.addCallback(fireEventually) d.addBoth(flush_but_dont_ignore) return d diff --git a/src/allmydata/test/test_introducer.py b/src/allmydata/test/test_introducer.py index b0e54afe..6650bf27 100644 --- a/src/allmydata/test/test_introducer.py +++ b/src/allmydata/test/test_introducer.py @@ -6,8 +6,7 @@ from twisted.trial import unittest 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 diff --git a/src/allmydata/test/test_keygen.py b/src/allmydata/test/test_keygen.py index 11b8f7de..34282b58 100644 --- a/src/allmydata/test/test_keygen.py +++ b/src/allmydata/test/test_keygen.py @@ -3,14 +3,14 @@ import os 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) @@ -25,11 +25,11 @@ class KeyGenService(unittest.TestCase, pollmixin.PollMixin): 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 @@ -50,7 +50,7 @@ class KeyGenService(unittest.TestCase, pollmixin.PollMixin): 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)) diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 16b63279..4810ee94 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -15,7 +15,7 @@ from allmydata.interfaces import IURI, IMutableFileURI, IUploadable, \ 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 diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py index ef9b4510..fb6be27a 100644 --- a/src/allmydata/test/test_node.py +++ b/src/allmydata/test/test_node.py @@ -4,7 +4,7 @@ from twisted.trial import unittest 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 diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index d062426b..1caca267 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -5,7 +5,7 @@ from twisted.trial import unittest 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 @@ -1391,7 +1391,7 @@ class BucketCounter(unittest.TestCase, pollmixin.PollMixin): # 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() @@ -1428,7 +1428,7 @@ class BucketCounter(unittest.TestCase, pollmixin.PollMixin): 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 @@ -1613,7 +1613,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin): DAY = 24*60*60 - d = eventual.fireEventually() + d = fireEventually() # now examine the state right after the first bucket has been # processed. @@ -1813,7 +1813,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin): 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() @@ -1954,7 +1954,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin): 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() @@ -2220,7 +2220,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin): 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 @@ -2338,7 +2338,7 @@ class LeaseCrawler(unittest.TestCase, pollmixin.PollMixin, WebRenderingMixin): ss.setServiceParent(self.s) - d = eventual.fireEventually() + d = fireEventually() # now examine the state right after the first bucket has been # processed. diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index f66c4e4c..c1c9b08a 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -20,7 +20,7 @@ from allmydata.interfaces import IDirectoryNode, IFileNode, IFileURI, \ 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 diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index a0bc7984..845f412d 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -5,7 +5,7 @@ from twisted.trial import unittest 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 @@ -97,7 +97,7 @@ class FakeStorageServer: def _call(): meth = getattr(self, methname) return meth(*args, **kwargs) - d = eventual.fireEventually() + d = fireEventually() d.addCallback(lambda res: _call()) return d @@ -128,7 +128,7 @@ class FakeBucketWriter: def _call(): meth = getattr(self, "remote_" + methname) return meth(*args, **kwargs) - d = eventual.fireEventually() + d = fireEventually() d.addCallback(lambda res: _call()) return d diff --git a/src/allmydata/util/limiter.py b/src/allmydata/util/limiter.py index 241c1eb8..7ba27742 100644 --- a/src/allmydata/util/limiter.py +++ b/src/allmydata/util/limiter.py @@ -1,6 +1,6 @@ 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 diff --git a/src/allmydata/util/observer.py b/src/allmydata/util/observer.py index ca29f8f3..13e4b511 100644 --- a/src/allmydata/util/observer.py +++ b/src/allmydata/util/observer.py @@ -1,7 +1,7 @@ # -*- 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 diff --git a/src/allmydata/util/rrefutil.py b/src/allmydata/util/rrefutil.py index 1c037cc4..99e10774 100644 --- a/src/allmydata/util/rrefutil.py +++ b/src/allmydata/util/rrefutil.py @@ -1,6 +1,6 @@ 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 diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index 8da7a33f..42dd271a 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -10,7 +10,7 @@ from twisted.web import http, html 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 diff --git a/src/allmydata/web/introweb.py b/src/allmydata/web/introweb.py index 3210fda1..14b01266 100644 --- a/src/allmydata/web/introweb.py +++ b/src/allmydata/web/introweb.py @@ -1,7 +1,7 @@ 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