use @implementer instead of implements

Also, derive some more things from 'object'
This commit is contained in:
meejah 2017-02-27 10:56:49 -07:00
parent bb782b0331
commit 49ae2c5eb7
44 changed files with 195 additions and 195 deletions

View File

@ -1,7 +1,7 @@
import os import os
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.python import log as twisted_log from twisted.python import log as twisted_log
@ -56,8 +56,8 @@ class Blacklist:
return reason return reason
class ProhibitedNode: @implementer(IFileNode)
implements(IFileNode) class ProhibitedNode(object):
def __init__(self, wrapped_node, reason): def __init__(self, wrapped_node, reason):
assert IFilesystemNode.providedBy(wrapped_node), wrapped_node assert IFilesystemNode.providedBy(wrapped_node), wrapped_node

View File

@ -1,11 +1,11 @@
from zope.interface import implements from zope.interface import implementer
from allmydata.interfaces import ICheckResults, ICheckAndRepairResults, \ from allmydata.interfaces import ICheckResults, ICheckAndRepairResults, \
IDeepCheckResults, IDeepCheckAndRepairResults, IURI, IDisplayableServer IDeepCheckResults, IDeepCheckAndRepairResults, IURI, IDisplayableServer
from allmydata.util import base32 from allmydata.util import base32
class CheckResults: @implementer(ICheckResults)
implements(ICheckResults) class CheckResults(object):
def __init__(self, uri, storage_index, def __init__(self, uri, storage_index,
healthy, recoverable, count_happiness, healthy, recoverable, count_happiness,
@ -146,8 +146,8 @@ class CheckResults:
def get_servermap(self): def get_servermap(self):
return self._servermap return self._servermap
class CheckAndRepairResults: @implementer(ICheckAndRepairResults)
implements(ICheckAndRepairResults) class CheckAndRepairResults(object):
def __init__(self, storage_index): def __init__(self, storage_index):
self.storage_index = storage_index self.storage_index = storage_index
@ -206,8 +206,8 @@ class DeepResultsBase:
return self.stats return self.stats
@implementer(IDeepCheckResults)
class DeepCheckResults(DeepResultsBase): class DeepCheckResults(DeepResultsBase):
implements(IDeepCheckResults)
def add_check(self, r, path): def add_check(self, r, path):
if not r: if not r:
@ -234,8 +234,8 @@ class DeepCheckResults(DeepResultsBase):
} }
@implementer(IDeepCheckAndRepairResults)
class DeepCheckAndRepairResults(DeepResultsBase): class DeepCheckAndRepairResults(DeepResultsBase):
implements(IDeepCheckAndRepairResults)
def __init__(self, root_storage_index): def __init__(self, root_storage_index):
DeepResultsBase.__init__(self, root_storage_index) DeepResultsBase.__init__(self, root_storage_index)

View File

@ -2,7 +2,7 @@ import os, stat, time, weakref
from allmydata import node from allmydata import node
from base64 import urlsafe_b64encode from base64 import urlsafe_b64encode
from zope.interface import implements from zope.interface import implementer
from twisted.internet import reactor, defer from twisted.internet import reactor, defer
from twisted.application import service from twisted.application import service
from twisted.application.internet import TimerService from twisted.application.internet import TimerService
@ -153,8 +153,8 @@ class Terminator(service.Service):
return service.Service.stopService(self) return service.Service.stopService(self)
@implementer(IStatsProducer)
class Client(node.Node, pollmixin.PollMixin): class Client(node.Node, pollmixin.PollMixin):
implements(IStatsProducer)
PORTNUMFILE = "client.port" PORTNUMFILE = "client.port"
STOREDIR = 'storage' STOREDIR = 'storage'

View File

@ -1,14 +1,14 @@
# -*- test-case-name: allmydata.test.test_encode_share -*- # -*- test-case-name: allmydata.test.test_encode_share -*-
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata.util import mathutil from allmydata.util import mathutil
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition
from allmydata.interfaces import ICodecEncoder, ICodecDecoder from allmydata.interfaces import ICodecEncoder, ICodecDecoder
import zfec import zfec
@implementer(ICodecEncoder)
class CRSEncoder(object): class CRSEncoder(object):
implements(ICodecEncoder)
ENCODER_TYPE = "crs" ENCODER_TYPE = "crs"
def set_params(self, data_size, required_shares, max_shares): def set_params(self, data_size, required_shares, max_shares):
@ -45,8 +45,8 @@ class CRSEncoder(object):
return defer.succeed((shares, desired_share_ids)) return defer.succeed((shares, desired_share_ids))
@implementer(ICodecDecoder)
class CRSDecoder(object): class CRSDecoder(object):
implements(ICodecDecoder)
def set_params(self, data_size, required_shares, max_shares): def set_params(self, data_size, required_shares, max_shares):
self.data_size = data_size self.data_size = data_size

View File

@ -1,6 +1,6 @@
import os, time, tempfile import os, time, tempfile
from zope.interface import implements from zope.interface import implementer
from twisted.application import service from twisted.application import service
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IConsumer from twisted.internet.interfaces import IConsumer
@ -37,8 +37,8 @@ def log_memory_usage(where=""):
stats["VmPeak"], stats["VmPeak"],
where)) where))
@implementer(IConsumer)
class FileWritingConsumer: class FileWritingConsumer:
implements(IConsumer)
def __init__(self, filename): def __init__(self, filename):
self.done = False self.done = False
self.f = open(filename, "wb") self.f = open(filename, "wb")
@ -54,8 +54,8 @@ class FileWritingConsumer:
self.done = True self.done = True
self.f.close() self.f.close()
@implementer(RIControlClient)
class ControlServer(Referenceable, service.Service): class ControlServer(Referenceable, service.Service):
implements(RIControlClient)
def remote_wait_for_client_connections(self, num_clients): def remote_wait_for_client_connections(self, num_clients):
return self.parent.debug_wait_for_client_connections(num_clients) return self.parent.debug_wait_for_client_connections(num_clients)
@ -245,8 +245,8 @@ class SpeedTest:
os.unlink(fn) os.unlink(fn)
return res return res
class DiscardingConsumer: @implementer(IConsumer)
implements(IConsumer) class DiscardingConsumer(object):
def __init__(self): def __init__(self):
self.done = False self.done = False
def registerProducer(self, p, streaming): def registerProducer(self, p, streaming):

View File

@ -1,7 +1,7 @@
"""Directory Node implementation.""" """Directory Node implementation."""
import time, unicodedata import time, unicodedata
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from foolscap.api import fireEventually from foolscap.api import fireEventually
import simplejson import simplejson
@ -256,8 +256,8 @@ def _pack_normalized_children(children, writekey, deep_immutable=False):
entries.append(netstring(entry)) entries.append(netstring(entry))
return "".join(entries) return "".join(entries)
class DirectoryNode: @implementer(IDirectoryNode, ICheckable, IDeepCheckable)
implements(IDirectoryNode, ICheckable, IDeepCheckable) class DirectoryNode(object):
filenode_class = MutableFileNode filenode_class = MutableFileNode
def __init__(self, filenode, nodemaker, uploader): def __init__(self, filenode, nodemaker, uploader):

View File

@ -1,6 +1,6 @@
import os import os
from zope.interface import implements from zope.interface import implementer
from twisted.web.client import getPage from twisted.web.client import getPage
from twisted.internet import defer from twisted.internet import defer
from twisted.cred import error, checkers, credentials from twisted.cred import error, checkers, credentials
@ -21,8 +21,8 @@ class FTPAvatarID:
self.username = username self.username = username
self.rootcap = rootcap self.rootcap = rootcap
class AccountFileChecker: @implementer(checkers.ICredentialsChecker)
implements(checkers.ICredentialsChecker) class AccountFileChecker(object):
credentialInterfaces = (credentials.IUsernamePassword, credentialInterfaces = (credentials.IUsernamePassword,
credentials.IUsernameHashedPassword, credentials.IUsernameHashedPassword,
credentials.ISSHPrivateKey) credentials.ISSHPrivateKey)
@ -108,8 +108,8 @@ class AccountFileChecker:
return defer.fail(error.UnauthorizedLogin()) return defer.fail(error.UnauthorizedLogin())
class AccountURLChecker: @implementer(checkers.ICredentialsChecker)
implements(checkers.ICredentialsChecker) class AccountURLChecker(object):
credentialInterfaces = (credentials.IUsernamePassword,) credentialInterfaces = (credentials.IUsernamePassword,)
def __init__(self, client, auth_url): def __init__(self, client, auth_url):

View File

@ -1,7 +1,7 @@
from types import NoneType from types import NoneType
from zope.interface import implements from zope.interface import implementer
from twisted.application import service, strports from twisted.application import service, strports
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IConsumer from twisted.internet.interfaces import IConsumer
@ -15,16 +15,16 @@ from allmydata.immutable.upload import FileHandle
from allmydata.util.fileutil import EncryptedTemporaryFile from allmydata.util.fileutil import EncryptedTemporaryFile
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition
class ReadFile: @implementer(ftp.IReadFile)
implements(ftp.IReadFile) class ReadFile(object):
def __init__(self, node): def __init__(self, node):
self.node = node self.node = node
def send(self, consumer): def send(self, consumer):
d = self.node.read(consumer) d = self.node.read(consumer)
return d # when consumed return d # when consumed
class FileWriter: @implementer(IConsumer)
implements(IConsumer) class FileWriter(object):
def registerProducer(self, producer, streaming): def registerProducer(self, producer, streaming):
if not streaming: if not streaming:
@ -41,8 +41,8 @@ class FileWriter:
def write(self, data): def write(self, data):
self.f.write(data) self.f.write(data)
class WriteFile: @implementer(ftp.IWriteFile)
implements(ftp.IWriteFile) class WriteFile(object):
def __init__(self, parent, childname, convergence): def __init__(self, parent, childname, convergence):
self.parent = parent self.parent = parent
@ -73,8 +73,8 @@ class IntishPermissions(filepath.Permissions):
def __and__(self, other): def __and__(self, other):
return self._tahoe_statModeInt & other return self._tahoe_statModeInt & other
class Handler: @implementer(ftp.IFTPShell)
implements(ftp.IFTPShell) class Handler(object):
def __init__(self, client, rootnode, username, convergence): def __init__(self, client, rootnode, username, convergence):
self.client = client self.client = client
self.root = rootnode self.root = rootnode
@ -292,8 +292,8 @@ class Handler:
from allmydata.frontends.auth import AccountURLChecker, AccountFileChecker, NeedRootcapLookupScheme from allmydata.frontends.auth import AccountURLChecker, AccountFileChecker, NeedRootcapLookupScheme
class Dispatcher: @implementer(portal.IRealm)
implements(portal.IRealm) class Dispatcher(object):
def __init__(self, client): def __init__(self, client):
self.client = client self.client = client

View File

@ -4,7 +4,7 @@ from types import NoneType
from stat import S_IFREG, S_IFDIR from stat import S_IFREG, S_IFDIR
from time import time, strftime, localtime from time import time, strftime, localtime
from zope.interface import implements from zope.interface import implementer
from twisted.python import components from twisted.python import components
from twisted.application import service, strports from twisted.application import service, strports
from twisted.conch.ssh import factory, keys, session from twisted.conch.ssh import factory, keys, session
@ -294,8 +294,8 @@ def _direntry_for(filenode_or_parent, childname, filenode=None):
return None return None
@implementer(IConsumer)
class OverwriteableFileConsumer(PrefixingLogMixin): class OverwriteableFileConsumer(PrefixingLogMixin):
implements(IConsumer)
"""I act both as a consumer for the download of the original file contents, and as a """I act both as a consumer for the download of the original file contents, and as a
wrapper for a temporary file that records the downloaded data and any overwrites. wrapper for a temporary file that records the downloaded data and any overwrites.
I use a priority queue to keep track of which regions of the file have been overwritten I use a priority queue to keep track of which regions of the file have been overwritten
@ -566,8 +566,8 @@ class OverwriteableFileConsumer(PrefixingLogMixin):
SIZE_THRESHOLD = 1000 SIZE_THRESHOLD = 1000
@implementer(ISFTPFile)
class ShortReadOnlySFTPFile(PrefixingLogMixin): class ShortReadOnlySFTPFile(PrefixingLogMixin):
implements(ISFTPFile)
"""I represent a file handle to a particular file on an SFTP connection. """I represent a file handle to a particular file on an SFTP connection.
I am used only for short immutable files opened in read-only mode. I am used only for short immutable files opened in read-only mode.
When I am created, the file contents start to be downloaded to memory. When I am created, the file contents start to be downloaded to memory.
@ -644,8 +644,8 @@ class ShortReadOnlySFTPFile(PrefixingLogMixin):
return defer.execute(_denied) return defer.execute(_denied)
@implementer(ISFTPFile)
class GeneralSFTPFile(PrefixingLogMixin): class GeneralSFTPFile(PrefixingLogMixin):
implements(ISFTPFile)
"""I represent a file handle to a particular file on an SFTP connection. """I represent a file handle to a particular file on an SFTP connection.
I wrap an instance of OverwriteableFileConsumer, which is responsible for I wrap an instance of OverwriteableFileConsumer, which is responsible for
storing the file contents. In order to allow write requests to be satisfied storing the file contents. In order to allow write requests to be satisfied
@ -993,8 +993,8 @@ def _reload():
global all_heisenfiles global all_heisenfiles
all_heisenfiles = {} all_heisenfiles = {}
@implementer(ISFTPServer)
class SFTPUserHandler(ConchUser, PrefixingLogMixin): class SFTPUserHandler(ConchUser, PrefixingLogMixin):
implements(ISFTPServer)
def __init__(self, client, rootnode, username): def __init__(self, client, rootnode, username):
ConchUser.__init__(self) ConchUser.__init__(self)
PrefixingLogMixin.__init__(self, facility="tahoe.sftp", prefix=username) PrefixingLogMixin.__init__(self, facility="tahoe.sftp", prefix=username)
@ -1894,8 +1894,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
return d return d
class FakeTransport: @implementer(ITransport)
implements(ITransport) class FakeTransport(object):
def write(self, data): def write(self, data):
logmsg("FakeTransport.write(<data of length %r>)" % (len(data),), level=NOISY) logmsg("FakeTransport.write(<data of length %r>)" % (len(data),), level=NOISY)
@ -1908,8 +1908,8 @@ class FakeTransport:
# getPeer and getHost can just raise errors, since we don't know what to return # getPeer and getHost can just raise errors, since we don't know what to return
@implementer(ISession)
class ShellSession(PrefixingLogMixin): class ShellSession(PrefixingLogMixin):
implements(ISession)
def __init__(self, userHandler): def __init__(self, userHandler):
PrefixingLogMixin.__init__(self, facility="tahoe.sftp") PrefixingLogMixin.__init__(self, facility="tahoe.sftp")
if noisy: self.log(".__init__(%r)" % (userHandler), level=NOISY) if noisy: self.log(".__init__(%r)" % (userHandler), level=NOISY)
@ -1965,8 +1965,8 @@ components.registerAdapter(ShellSession, SFTPUserHandler, ISession)
from allmydata.frontends.auth import AccountURLChecker, AccountFileChecker, NeedRootcapLookupScheme from allmydata.frontends.auth import AccountURLChecker, AccountFileChecker, NeedRootcapLookupScheme
class Dispatcher: @implementer(portal.IRealm)
implements(portal.IRealm) class Dispatcher(object):
def __init__(self, client): def __init__(self, client):
self._client = client self._client = client

View File

@ -1,4 +1,4 @@
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from foolscap.api import DeadReferenceError, RemoteException from foolscap.api import DeadReferenceError, RemoteException
from allmydata import hashtree, codec, uri from allmydata import hashtree, codec, uri
@ -27,8 +27,8 @@ class BadOrMissingHash(IntegrityCheckReject):
class UnsupportedErasureCodec(BadURIExtension): class UnsupportedErasureCodec(BadURIExtension):
pass pass
class ValidatedExtendedURIProxy: @implementer(IValidatedThingProxy)
implements(IValidatedThingProxy) class ValidatedExtendedURIProxy(object):
""" I am a front-end for a remote UEB (using a local ReadBucketProxy), """ I am a front-end for a remote UEB (using a local ReadBucketProxy),
responsible for retrieving and validating the elements from the UEB.""" responsible for retrieving and validating the elements from the UEB."""

View File

@ -1,7 +1,7 @@
import time import time
now = time.time now = time.time
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IPushProducer from twisted.internet.interfaces import IPushProducer
from foolscap.api import eventually from foolscap.api import eventually
@ -11,14 +11,14 @@ from allmydata.interfaces import DownloadStopped
from common import BadSegmentNumberError, WrongSegmentError from common import BadSegmentNumberError, WrongSegmentError
class Segmentation: @implementer(IPushProducer)
class Segmentation(object):
"""I am responsible for a single offset+size read of the file. I handle """I am responsible for a single offset+size read of the file. I handle
segmentation: I figure out which segments are necessary, request them segmentation: I figure out which segments are necessary, request them
(from my CiphertextDownloader) in order, and trim the segments down to (from my CiphertextDownloader) in order, and trim the segments down to
match the offset+size span. I use the Producer/Consumer interface to only match the offset+size span. I use the Producer/Consumer interface to only
request one segment at a time. request one segment at a time.
""" """
implements(IPushProducer)
def __init__(self, node, offset, size, consumer, read_ev, logparent=None): def __init__(self, node, offset, size, consumer, read_ev, logparent=None):
self._node = node self._node = node
self._hungry = True self._hungry = True

View File

@ -1,6 +1,6 @@
import itertools import itertools
from zope.interface import implements from zope.interface import implementer
from allmydata.interfaces import IDownloadStatus from allmydata.interfaces import IDownloadStatus
class ReadEvent: class ReadEvent:
@ -64,10 +64,10 @@ class BlockRequestEvent:
self._ds.update_last_timestamp(when) self._ds.update_last_timestamp(when)
class DownloadStatus: @implementer(IDownloadStatus)
class DownloadStatus(object):
# There is one DownloadStatus for each CiphertextFileNode. The status # There is one DownloadStatus for each CiphertextFileNode. The status
# object will keep track of all activity for that node. # object will keep track of all activity for that node.
implements(IDownloadStatus)
statusid_counter = itertools.count(0) statusid_counter = itertools.count(0)
def __init__(self, storage_index, size): def __init__(self, storage_index, size):

View File

@ -1,7 +1,7 @@
# -*- test-case-name: allmydata.test.test_encode -*- # -*- test-case-name: allmydata.test.test_encode -*-
import time import time
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from foolscap.api import fireEventually from foolscap.api import fireEventually
from allmydata import uri from allmydata import uri
@ -71,8 +71,8 @@ GiB=1024*MiB
TiB=1024*GiB TiB=1024*GiB
PiB=1024*TiB PiB=1024*TiB
@implementer(IEncoder)
class Encoder(object): class Encoder(object):
implements(IEncoder)
def __init__(self, log_parent=None, upload_status=None, progress=None): def __init__(self, log_parent=None, upload_status=None, progress=None):
object.__init__(self) object.__init__(self)

View File

@ -2,7 +2,7 @@
import binascii import binascii
from time import time as now from time import time as now
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata import uri from allmydata import uri
@ -182,12 +182,12 @@ class CiphertextFileNode:
monitor=monitor) monitor=monitor)
return v.start() return v.start()
class DecryptingConsumer: @implementer(IConsumer, IDownloadStatusHandlingConsumer)
class DecryptingConsumer(object):
"""I sit between a CiphertextDownloader (which acts as a Producer) and """I sit between a CiphertextDownloader (which acts as a Producer) and
the real Consumer, decrypting everything that passes by. The real the real Consumer, decrypting everything that passes by. The real
Consumer sees the real Producer, but the Producer sees us instead of the Consumer sees the real Producer, but the Producer sees us instead of the
real consumer.""" real consumer."""
implements(IConsumer, IDownloadStatusHandlingConsumer)
def __init__(self, consumer, readkey, offset): def __init__(self, consumer, readkey, offset):
self._consumer = consumer self._consumer = consumer
@ -227,8 +227,8 @@ class DecryptingConsumer:
self._download_status.add_misc_event("AES", started, now()) self._download_status.add_misc_event("AES", started, now())
self._consumer.write(plaintext) self._consumer.write(plaintext)
class ImmutableFileNode: @implementer(IImmutableFileNode)
implements(IImmutableFileNode) class ImmutableFileNode(object):
# I wrap a CiphertextFileNode with a decryption key # I wrap a CiphertextFileNode with a decryption key
def __init__(self, filecap, storage_broker, secret_holder, terminator, def __init__(self, filecap, storage_broker, secret_holder, terminator,

View File

@ -1,5 +1,5 @@
import struct import struct
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata.interfaces import IStorageBucketWriter, IStorageBucketReader, \ from allmydata.interfaces import IStorageBucketWriter, IStorageBucketReader, \
FileTooLargeError, HASH_SIZE FileTooLargeError, HASH_SIZE
@ -94,8 +94,8 @@ def make_write_bucket_proxy(rref, server,
num_share_hashes, uri_extension_size_max) num_share_hashes, uri_extension_size_max)
return wbp return wbp
class WriteBucketProxy: @implementer(IStorageBucketWriter)
implements(IStorageBucketWriter) class WriteBucketProxy(object):
fieldsize = 4 fieldsize = 4
fieldstruct = ">L" fieldstruct = ">L"
@ -289,8 +289,8 @@ class WriteBucketProxy_v2(WriteBucketProxy):
assert len(offset_data) == 0x44, len(offset_data) assert len(offset_data) == 0x44, len(offset_data)
self._offset_data = offset_data self._offset_data = offset_data
class ReadBucketProxy: @implementer(IStorageBucketReader)
implements(IStorageBucketReader) class ReadBucketProxy(object):
MAX_UEB_SIZE = 2000 # actual size is closer to 419, but varies by a few bytes MAX_UEB_SIZE = 2000 # actual size is closer to 419, but varies by a few bytes

View File

@ -1,13 +1,13 @@
from cStringIO import StringIO from cStringIO import StringIO
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IPushProducer from twisted.internet.interfaces import IPushProducer
from twisted.protocols import basic from twisted.protocols import basic
from allmydata.interfaces import IImmutableFileNode, ICheckable from allmydata.interfaces import IImmutableFileNode, ICheckable
from allmydata.uri import LiteralFileURI from allmydata.uri import LiteralFileURI
@implementer(IImmutableFileNode, ICheckable)
class _ImmutableFileNodeBase(object): class _ImmutableFileNodeBase(object):
implements(IImmutableFileNode, ICheckable)
def get_write_uri(self): def get_write_uri(self):
return None return None
@ -44,8 +44,8 @@ class _ImmutableFileNodeBase(object):
return True return True
class LiteralProducer: @implementer(IPushProducer)
implements(IPushProducer) class LiteralProducer(object):
def pauseProducing(self): def pauseProducing(self):
pass pass

View File

@ -1,6 +1,6 @@
import os, stat, time, weakref import os, stat, time, weakref
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from foolscap.api import Referenceable, DeadReferenceError, eventually from foolscap.api import Referenceable, DeadReferenceError, eventually
import allmydata # for __full_version__ import allmydata # for __full_version__
@ -123,12 +123,12 @@ class CHKCheckerAndUEBFetcher:
return False return False
@implementer(interfaces.RICHKUploadHelper)
class CHKUploadHelper(Referenceable, upload.CHKUploader): class CHKUploadHelper(Referenceable, upload.CHKUploader):
"""I am the helper-server -side counterpart to AssistedUploader. I handle """I am the helper-server -side counterpart to AssistedUploader. I handle
peer selection, encoding, and share pushing. I read ciphertext from the peer selection, encoding, and share pushing. I read ciphertext from the
remote AssistedUploader. remote AssistedUploader.
""" """
implements(interfaces.RICHKUploadHelper)
VERSION = { "http://allmydata.org/tahoe/protocols/helper/chk-upload/v1" : VERSION = { "http://allmydata.org/tahoe/protocols/helper/chk-upload/v1" :
{ }, { },
"application-version": str(allmydata.__full_version__), "application-version": str(allmydata.__full_version__),
@ -447,8 +447,8 @@ class CHKCiphertextFetcher(AskUntilSuccessMixin):
return self._ciphertext_fetched return self._ciphertext_fetched
@implementer(interfaces.IEncryptedUploadable)
class LocalCiphertextReader(AskUntilSuccessMixin): class LocalCiphertextReader(AskUntilSuccessMixin):
implements(interfaces.IEncryptedUploadable)
def __init__(self, upload_helper, storage_index, encoding_file): def __init__(self, upload_helper, storage_index, encoding_file):
self._readers = [] self._readers = []
@ -484,8 +484,8 @@ class LocalCiphertextReader(AskUntilSuccessMixin):
@implementer(interfaces.RIHelper, interfaces.IStatsProducer)
class Helper(Referenceable): class Helper(Referenceable):
implements(interfaces.RIHelper, interfaces.IStatsProducer)
# this is the non-distributed version. When we need to have multiple # this is the non-distributed version. When we need to have multiple
# helpers, this object will become the HelperCoordinator, and will query # helpers, this object will become the HelperCoordinator, and will query
# the farm of Helpers to see if anyone has the storage_index of interest, # the farm of Helpers to see if anyone has the storage_index of interest,

View File

@ -1,4 +1,4 @@
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata.storage.server import si_b2a from allmydata.storage.server import si_b2a
from allmydata.util import log, consumer from allmydata.util import log, consumer
@ -7,8 +7,8 @@ from allmydata.interfaces import IEncryptedUploadable
from allmydata.immutable import upload from allmydata.immutable import upload
@implementer(IEncryptedUploadable)
class Repairer(log.PrefixingLogMixin): class Repairer(log.PrefixingLogMixin):
implements(IEncryptedUploadable)
"""I generate any shares which were not available and upload them to """I generate any shares which were not available and upload them to
servers. servers.

View File

@ -1,5 +1,5 @@
import os, time, weakref, itertools import os, time, weakref, itertools
from zope.interface import implements from zope.interface import implementer
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
@ -57,8 +57,8 @@ class HelperUploadResults(Copyable, RemoteCopy):
self.preexisting_shares = None # count of shares already present self.preexisting_shares = None # count of shares already present
self.pushed_shares = None # count of shares we pushed self.pushed_shares = None # count of shares we pushed
class UploadResults: @implementer(IUploadResults)
implements(IUploadResults) class UploadResults(object):
def __init__(self, file_size, def __init__(self, file_size,
ciphertext_fetched, # how much the helper fetched ciphertext_fetched, # how much the helper fetched
@ -617,10 +617,10 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin):
raise UploadUnhappinessError(msg) raise UploadUnhappinessError(msg)
class EncryptAnUploadable: @implementer(IEncryptedUploadable)
class EncryptAnUploadable(object):
"""This is a wrapper that takes an IUploadable and provides """This is a wrapper that takes an IUploadable and provides
IEncryptedUploadable.""" IEncryptedUploadable."""
implements(IEncryptedUploadable)
CHUNKSIZE = 50*1024 CHUNKSIZE = 50*1024
def __init__(self, original, log_parent=None, progress=None): def __init__(self, original, log_parent=None, progress=None):
@ -844,8 +844,8 @@ class EncryptAnUploadable:
def close(self): def close(self):
return self.original.close() return self.original.close()
class UploadStatus: @implementer(IUploadStatus)
implements(IUploadStatus) class UploadStatus(object):
statusid_counter = itertools.count(0) statusid_counter = itertools.count(0)
def __init__(self): def __init__(self):
@ -1129,8 +1129,8 @@ class LiteralUploader:
def get_upload_status(self): def get_upload_status(self):
return self._status return self._status
@implementer(RIEncryptedUploadable)
class RemoteEncryptedUploadable(Referenceable): class RemoteEncryptedUploadable(Referenceable):
implements(RIEncryptedUploadable)
def __init__(self, encrypted_uploadable, upload_status): def __init__(self, encrypted_uploadable, upload_status):
self._eu = IEncryptedUploadable(encrypted_uploadable) self._eu = IEncryptedUploadable(encrypted_uploadable)
@ -1407,8 +1407,8 @@ class BaseUploadable:
d.addCallback(_got_size) d.addCallback(_got_size)
return d return d
@implementer(IUploadable)
class FileHandle(BaseUploadable): class FileHandle(BaseUploadable):
implements(IUploadable)
def __init__(self, filehandle, convergence): def __init__(self, filehandle, convergence):
""" """
@ -1510,11 +1510,11 @@ class Data(FileHandle):
assert convergence is None or isinstance(convergence, str), (convergence, type(convergence)) assert convergence is None or isinstance(convergence, str), (convergence, type(convergence))
FileHandle.__init__(self, StringIO(data), convergence=convergence) FileHandle.__init__(self, StringIO(data), convergence=convergence)
@implementer(IUploader)
class Uploader(service.MultiService, log.PrefixingLogMixin): class Uploader(service.MultiService, log.PrefixingLogMixin):
"""I am a service that allows file uploading. I am a service-child of the """I am a service that allows file uploading. I am a service-child of the
Client. Client.
""" """
implements(IUploader)
name = "uploader" name = "uploader"
URI_LIT_SIZE_THRESHOLD = 55 URI_LIT_SIZE_THRESHOLD = 55

View File

@ -1,6 +1,6 @@
import time import time
from zope.interface import implements from zope.interface import implementer
from twisted.application import service from twisted.application import service
from foolscap.api import Referenceable, eventually from foolscap.api import Referenceable, eventually
from allmydata.interfaces import InsufficientVersionError from allmydata.interfaces import InsufficientVersionError
@ -18,8 +18,8 @@ class InvalidCacheError(Exception):
V2 = "http://allmydata.org/tahoe/protocols/introducer/v2" V2 = "http://allmydata.org/tahoe/protocols/introducer/v2"
@implementer(RIIntroducerSubscriberClient_v2, IIntroducerClient)
class IntroducerClient(service.Service, Referenceable): class IntroducerClient(service.Service, Referenceable):
implements(RIIntroducerSubscriberClient_v2, IIntroducerClient)
def __init__(self, tub, introducer_furl, def __init__(self, tub, introducer_furl,
nickname, my_version, oldest_supported, nickname, my_version, oldest_supported,

View File

@ -1,6 +1,6 @@
import time, os.path, textwrap import time, os.path, textwrap
from zope.interface import implements from zope.interface import implementer
from twisted.application import service from twisted.application import service
from foolscap.api import Referenceable from foolscap.api import Referenceable
import allmydata import allmydata
@ -69,8 +69,8 @@ class IntroducerNode(node.Node):
ws = IntroducerWebishServer(self, webport, nodeurl_path, staticdir) ws = IntroducerWebishServer(self, webport, nodeurl_path, staticdir)
self.add_service(ws) self.add_service(ws)
@implementer(RIIntroducerPublisherAndSubscriberService_v2)
class IntroducerService(service.MultiService, Referenceable): class IntroducerService(service.MultiService, Referenceable):
implements(RIIntroducerPublisherAndSubscriberService_v2)
name = "introducer" name = "introducer"
# v1 is the original protocol, added in 1.0 (but only advertised starting # v1 is the original protocol, added in 1.0 (but only advertised starting
# in 1.3), removed in 1.12. v2 is the new signed protocol, added in 1.10 # in 1.3), removed in 1.12. v2 is the new signed protocol, added in 1.10

View File

@ -1,5 +1,5 @@
from zope.interface import Interface, implements from zope.interface import Interface, implementer
from allmydata.util import observer from allmydata.util import observer
class IMonitor(Interface): class IMonitor(Interface):
@ -80,8 +80,8 @@ class OperationCancelledError(Exception):
pass pass
class Monitor: @implementer(IMonitor)
implements(IMonitor) class Monitor(object):
def __init__(self): def __init__(self):
self.cancelled = False self.cancelled = False

View File

@ -1,7 +1,7 @@
import random import random
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from foolscap.api import eventually from foolscap.api import eventually
from allmydata.interfaces import IMutableFileNode, ICheckable, ICheckResults, \ from allmydata.interfaces import IMutableFileNode, ICheckable, ICheckResults, \
@ -48,8 +48,8 @@ class BackoffAgent:
# use nodemaker.create_mutable_file() to make one of these # use nodemaker.create_mutable_file() to make one of these
class MutableFileNode: @implementer(IMutableFileNode, ICheckable)
implements(IMutableFileNode, ICheckable) class MutableFileNode(object):
def __init__(self, storage_broker, secret_holder, def __init__(self, storage_broker, secret_holder,
default_encoding_parameters, history): default_encoding_parameters, history):
@ -695,7 +695,8 @@ class MutableFileNode:
return res return res
class MutableFileVersion: @implementer(IMutableFileVersion, IWriteable)
class MutableFileVersion(object):
""" """
I represent a specific version (most likely the best version) of a I represent a specific version (most likely the best version) of a
mutable file. mutable file.
@ -708,7 +709,6 @@ class MutableFileVersion:
overwrite or modify the contents of the mutable file that I overwrite or modify the contents of the mutable file that I
reference. reference.
""" """
implements(IMutableFileVersion, IWriteable)
def __init__(self, def __init__(self,
node, node,

View File

@ -7,7 +7,7 @@ from allmydata.interfaces import HASH_SIZE, SALT_SIZE, SDMF_VERSION, \
from allmydata.util import mathutil from allmydata.util import mathutil
from twisted.python import failure from twisted.python import failure
from twisted.internet import defer from twisted.internet import defer
from zope.interface import implements from zope.interface import implementer
# These strings describe the format of the packed structs they help process. # These strings describe the format of the packed structs they help process.
@ -218,8 +218,8 @@ def pack_prefix(seqnum, root_hash, IV,
return prefix return prefix
class SDMFSlotWriteProxy: @implementer(IMutableSlotWriter)
implements(IMutableSlotWriter) class SDMFSlotWriteProxy(object):
""" """
I represent a remote write slot for an SDMF mutable file. I build a I represent a remote write slot for an SDMF mutable file. I build a
share in memory, and then write it in one piece to the remote share in memory, and then write it in one piece to the remote
@ -566,8 +566,8 @@ VERIFICATION_KEY_SIZE = 292
# bound. Each node requires 2 bytes of node-number plus 32 bytes of hash. # bound. Each node requires 2 bytes of node-number plus 32 bytes of hash.
SHARE_HASH_CHAIN_SIZE = (2+HASH_SIZE)*mathutil.log_ceil(256, 2) SHARE_HASH_CHAIN_SIZE = (2+HASH_SIZE)*mathutil.log_ceil(256, 2)
class MDMFSlotWriteProxy: @implementer(IMutableSlotWriter)
implements(IMutableSlotWriter) class MDMFSlotWriteProxy(object):
""" """
I represent a remote write slot for an MDMF mutable file. I represent a remote write slot for an MDMF mutable file.

View File

@ -3,7 +3,7 @@
import os, time import os, time
from StringIO import StringIO from StringIO import StringIO
from itertools import count from itertools import count
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.python import failure from twisted.python import failure
from allmydata.interfaces import IPublishStatus, SDMF_VERSION, MDMF_VERSION, \ from allmydata.interfaces import IPublishStatus, SDMF_VERSION, MDMF_VERSION, \
@ -30,8 +30,8 @@ PUSHING_BLOCKS_STATE = 0
PUSHING_EVERYTHING_ELSE_STATE = 1 PUSHING_EVERYTHING_ELSE_STATE = 1
DONE_STATE = 2 DONE_STATE = 2
class PublishStatus: @implementer(IPublishStatus)
implements(IPublishStatus) class PublishStatus(object):
statusid_counter = count(0) statusid_counter = count(0)
def __init__(self): def __init__(self):
self.timings = {} self.timings = {}
@ -1199,12 +1199,12 @@ class Publish:
eventually(self.done_deferred.callback, f) eventually(self.done_deferred.callback, f)
class MutableFileHandle: @implementer(IMutableUploadable)
class MutableFileHandle(object):
""" """
I am a mutable uploadable built around a filehandle-like object, I am a mutable uploadable built around a filehandle-like object,
usually either a StringIO instance or a handle to an actual file. usually either a StringIO instance or a handle to an actual file.
""" """
implements(IMutableUploadable)
def __init__(self, filehandle): def __init__(self, filehandle):
# The filehandle is defined as a generally file-like object that # The filehandle is defined as a generally file-like object that
@ -1283,13 +1283,13 @@ class MutableData(MutableFileHandle):
MutableFileHandle.__init__(self, StringIO(s)) MutableFileHandle.__init__(self, StringIO(s))
class TransformingUploadable: @implementer(IMutableUploadable)
class TransformingUploadable(object):
""" """
I am an IMutableUploadable that wraps another IMutableUploadable, I am an IMutableUploadable that wraps another IMutableUploadable,
and some segments that are already on the grid. When I am called to and some segments that are already on the grid. When I am called to
read, I handle merging of boundary segments. read, I handle merging of boundary segments.
""" """
implements(IMutableUploadable)
def __init__(self, data, offset, segment_size, start, end): def __init__(self, data, offset, segment_size, start, end):

View File

@ -1,13 +1,13 @@
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata.interfaces import IRepairResults, ICheckResults from allmydata.interfaces import IRepairResults, ICheckResults
from allmydata.mutable.publish import MutableData from allmydata.mutable.publish import MutableData
from allmydata.mutable.common import MODE_REPAIR from allmydata.mutable.common import MODE_REPAIR
from allmydata.mutable.servermap import ServerMap, ServermapUpdater from allmydata.mutable.servermap import ServerMap, ServermapUpdater
class RepairResults: @implementer(IRepairResults)
implements(IRepairResults) class RepairResults(object):
def __init__(self, smap): def __init__(self, smap):
self.servermap = smap self.servermap = smap

View File

@ -1,7 +1,7 @@
import time import time
from itertools import count from itertools import count
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.python import failure from twisted.python import failure
from twisted.internet.interfaces import IPushProducer, IConsumer from twisted.internet.interfaces import IPushProducer, IConsumer
@ -22,8 +22,8 @@ from allmydata.mutable.common import CorruptShareError, BadShareError, \
UncoordinatedWriteError UncoordinatedWriteError
from allmydata.mutable.layout import MDMFSlotReadProxy from allmydata.mutable.layout import MDMFSlotReadProxy
class RetrieveStatus: @implementer(IRetrieveStatus)
implements(IRetrieveStatus) class RetrieveStatus(object):
statusid_counter = count(0) statusid_counter = count(0)
def __init__(self): def __init__(self):
self.timings = {} self.timings = {}
@ -92,13 +92,13 @@ class RetrieveStatus:
class Marker: class Marker:
pass pass
class Retrieve: @implementer(IPushProducer)
class Retrieve(object):
# this class is currently single-use. Eventually (in MDMF) we will make # this class is currently single-use. Eventually (in MDMF) we will make
# it multi-use, in which case you can call download(range) multiple # it multi-use, in which case you can call download(range) multiple
# times, and each will have a separate response chain. However the # times, and each will have a separate response chain. However the
# Retrieve object will remain tied to a specific version of the file, and # Retrieve object will remain tied to a specific version of the file, and
# will use a single ServerMap instance. # will use a single ServerMap instance.
implements(IPushProducer)
def __init__(self, filenode, storage_broker, servermap, verinfo, def __init__(self, filenode, storage_broker, servermap, verinfo,
fetch_privkey=False, verify=False): fetch_privkey=False, verify=False):

View File

@ -1,6 +1,6 @@
import sys, time, copy import sys, time, copy
from zope.interface import implements from zope.interface import implementer
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
@ -16,8 +16,8 @@ from allmydata.mutable.common import MODE_CHECK, MODE_ANYTHING, MODE_WRITE, \
MODE_READ, MODE_REPAIR, CorruptShareError MODE_READ, MODE_REPAIR, CorruptShareError
from allmydata.mutable.layout import SIGNED_PREFIX_LENGTH, MDMFSlotReadProxy from allmydata.mutable.layout import SIGNED_PREFIX_LENGTH, MDMFSlotReadProxy
class UpdateStatus: @implementer(IServermapUpdaterStatus)
implements(IServermapUpdaterStatus) class UpdateStatus(object):
statusid_counter = count(0) statusid_counter = count(0)
def __init__(self): def __init__(self):
self.timings = {} self.timings = {}

View File

@ -1,5 +1,5 @@
import weakref import weakref
from zope.interface import implements from zope.interface import implementer
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition
from allmydata.interfaces import INodeMaker from allmydata.interfaces import INodeMaker
from allmydata.immutable.literal import LiteralFileNode from allmydata.immutable.literal import LiteralFileNode
@ -13,8 +13,8 @@ from allmydata.blacklist import ProhibitedNode
from allmydata import uri from allmydata import uri
class NodeMaker: @implementer(INodeMaker)
implements(INodeMaker) class NodeMaker(object):
def __init__(self, storage_broker, secret_holder, history, def __init__(self, storage_broker, secret_holder, history,
uploader, terminator, uploader, terminator,

View File

@ -8,15 +8,15 @@ from collections import deque
from twisted.internet import reactor 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 implementer
from foolscap.api import eventually, DeadReferenceError, Referenceable, Tub from foolscap.api import eventually, DeadReferenceError, Referenceable, Tub
from allmydata.util import log from allmydata.util import log
from allmydata.util.encodingutil import quote_local_unicode_path from allmydata.util.encodingutil import quote_local_unicode_path
from allmydata.interfaces import RIStatsProvider, RIStatsGatherer, IStatsProducer from allmydata.interfaces import RIStatsProvider, RIStatsGatherer, IStatsProducer
@implementer(IStatsProducer)
class LoadMonitor(service.MultiService): class LoadMonitor(service.MultiService):
implements(IStatsProducer)
loop_interval = 1 loop_interval = 1
num_samples = 60 num_samples = 60
@ -69,8 +69,8 @@ class LoadMonitor(service.MultiService):
return { 'load_monitor.avg_load': avg, return { 'load_monitor.avg_load': avg,
'load_monitor.max_load': m_x, } 'load_monitor.max_load': m_x, }
@implementer(IStatsProducer)
class CPUUsageMonitor(service.MultiService): class CPUUsageMonitor(service.MultiService):
implements(IStatsProducer)
HISTORY_LENGTH = 15 HISTORY_LENGTH = 15
POLL_INTERVAL = 60 POLL_INTERVAL = 60
@ -122,8 +122,8 @@ class CPUUsageMonitor(service.MultiService):
return s return s
@implementer(RIStatsProvider)
class StatsProvider(Referenceable, service.MultiService): class StatsProvider(Referenceable, service.MultiService):
implements(RIStatsProvider)
def __init__(self, node, gatherer_furl): def __init__(self, node, gatherer_furl):
service.MultiService.__init__(self) service.MultiService.__init__(self)
@ -175,8 +175,8 @@ class StatsProvider(Referenceable, service.MultiService):
gatherer.callRemoteOnly('provide', self, nickname or '') gatherer.callRemoteOnly('provide', self, nickname or '')
@implementer(RIStatsGatherer)
class StatsGatherer(Referenceable, service.MultiService): class StatsGatherer(Referenceable, service.MultiService):
implements(RIStatsGatherer)
poll_interval = 60 poll_interval = 60

View File

@ -2,7 +2,7 @@ import os, stat, struct, time
from foolscap.api import Referenceable from foolscap.api import Referenceable
from zope.interface import implements from zope.interface import implementer
from allmydata.interfaces import RIBucketWriter, RIBucketReader from allmydata.interfaces import RIBucketWriter, RIBucketReader
from allmydata.util import base32, fileutil, log from allmydata.util import base32, fileutil, log
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition
@ -194,8 +194,8 @@ class ShareFile:
return space_freed return space_freed
@implementer(RIBucketWriter)
class BucketWriter(Referenceable): class BucketWriter(Referenceable):
implements(RIBucketWriter)
def __init__(self, ss, incominghome, finalhome, max_size, lease_info, canary): def __init__(self, ss, incominghome, finalhome, max_size, lease_info, canary):
self.ss = ss self.ss = ss
@ -293,8 +293,8 @@ class BucketWriter(Referenceable):
self.ss.bucket_writer_closed(self, 0) self.ss.bucket_writer_closed(self, 0)
@implementer(RIBucketReader)
class BucketReader(Referenceable): class BucketReader(Referenceable):
implements(RIBucketReader)
def __init__(self, ss, sharefname, storage_index=None, shnum=None): def __init__(self, ss, sharefname, storage_index=None, shnum=None):
self.ss = ss self.ss = ss

View File

@ -3,7 +3,7 @@ import os, re, weakref, struct, time
from foolscap.api 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 implementer
from allmydata.interfaces import RIStorageServer, IStatsProducer from allmydata.interfaces import RIStorageServer, IStatsProducer
from allmydata.util import fileutil, idlib, log, time_format from allmydata.util import fileutil, idlib, log, time_format
import allmydata # for __full_version__ import allmydata # for __full_version__
@ -33,8 +33,8 @@ NUM_RE=re.compile("^[0-9]+$")
@implementer(RIStorageServer, IStatsProducer)
class StorageServer(service.MultiService, Referenceable): class StorageServer(service.MultiService, Referenceable):
implements(RIStorageServer, IStatsProducer)
name = 'storage' name = 'storage'
LeaseCheckerClass = LeaseCheckingCrawler LeaseCheckerClass = LeaseCheckingCrawler

View File

@ -30,7 +30,7 @@ the foolscap-based server implemented in src/allmydata/storage/*.py .
import re, time, hashlib import re, time, hashlib
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.application import service from twisted.application import service
@ -59,8 +59,8 @@ from allmydata.util.hashutil import permute_server_hash
# don't pass signatures: only pass validated blessed-objects # don't pass signatures: only pass validated blessed-objects
@implementer(IStorageBroker)
class StorageFarmBroker(service.MultiService): class StorageFarmBroker(service.MultiService):
implements(IStorageBroker)
"""I live on the client, and know about storage servers. For each server """I live on the client, and know about storage servers. For each server
that is participating in a grid, I either maintain a connection to it or that is participating in a grid, I either maintain a connection to it or
remember enough information to establish a connection to it on demand. remember enough information to establish a connection to it on demand.
@ -235,8 +235,8 @@ class StorageFarmBroker(service.MultiService):
return s return s
return StubServer(serverid) return StubServer(serverid)
class StubServer: @implementer(IDisplayableServer)
implements(IDisplayableServer) class StubServer(object):
def __init__(self, serverid): def __init__(self, serverid):
self.serverid = serverid # binary tubid self.serverid = serverid # binary tubid
def get_serverid(self): def get_serverid(self):
@ -248,6 +248,7 @@ class StubServer:
def get_nickname(self): def get_nickname(self):
return "?" return "?"
@implementer(IServer)
class NativeStorageServer(service.MultiService): class NativeStorageServer(service.MultiService):
"""I hold information about a storage server that we want to connect to. """I hold information about a storage server that we want to connect to.
If we are connected, I hold the RemoteReference, their host address, and If we are connected, I hold the RemoteReference, their host address, and
@ -263,7 +264,6 @@ class NativeStorageServer(service.MultiService):
@ivar rref: the RemoteReference, if connected, otherwise None @ivar rref: the RemoteReference, if connected, otherwise None
@ivar remote_host: the IAddress, if connected, otherwise None @ivar remote_host: the IAddress, if connected, otherwise None
""" """
implements(IServer)
VERSION_DEFAULTS = { VERSION_DEFAULTS = {
"http://allmydata.org/tahoe/protocols/storage/v1" : "http://allmydata.org/tahoe/protocols/storage/v1" :

View File

@ -2,14 +2,14 @@ import hotshot.stats, os, random, sys
from pyutil import benchutil, randutil # http://tahoe-lafs.org/trac/pyutil from pyutil import benchutil, randutil # http://tahoe-lafs.org/trac/pyutil
from zope.interface import implements from zope.interface import implementer
from allmydata import dirnode, uri from allmydata import dirnode, uri
from allmydata.interfaces import IFileNode from allmydata.interfaces import IFileNode
from allmydata.mutable.filenode import MutableFileNode from allmydata.mutable.filenode import MutableFileNode
from allmydata.immutable.filenode import ImmutableFileNode from allmydata.immutable.filenode import ImmutableFileNode
class ContainerNode: @implementer(IFileNode)
implements(IFileNode) class ContainerNode(object):
# dirnodes sit on top of a "container" filenode, from which it extracts a # dirnodes sit on top of a "container" filenode, from which it extracts a
# writekey # writekey
def __init__(self): def __init__(self):

View File

@ -1,5 +1,5 @@
import os, random, struct import os, random, struct
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IPullProducer from twisted.internet.interfaces import IPullProducer
from twisted.python import failure from twisted.python import failure
@ -24,15 +24,15 @@ from allmydata.immutable.upload import Uploader
TEST_RSA_KEY_SIZE = 522 TEST_RSA_KEY_SIZE = 522
class DummyProducer: @implementer(IPullProducer)
implements(IPullProducer) class DummyProducer(object):
def resumeProducing(self): def resumeProducing(self):
pass pass
@implementer(IImmutableFileNode)
class FakeCHKFileNode: class FakeCHKFileNode:
"""I provide IImmutableFileNode, but all of my data is stored in a """I provide IImmutableFileNode, but all of my data is stored in a
class-level dictionary.""" class-level dictionary."""
implements(IImmutableFileNode)
def __init__(self, filecap, all_contents): def __init__(self, filecap, all_contents):
precondition(isinstance(filecap, (uri.CHKFileURI, uri.LiteralFileURI)), filecap) precondition(isinstance(filecap, (uri.CHKFileURI, uri.LiteralFileURI)), filecap)
@ -167,11 +167,11 @@ def create_chk_filenode(contents, all_contents):
return n return n
@implementer(IMutableFileNode, ICheckable)
class FakeMutableFileNode: class FakeMutableFileNode:
"""I provide IMutableFileNode, but all of my data is stored in a """I provide IMutableFileNode, but all of my data is stored in a
class-level dictionary.""" class-level dictionary."""
implements(IMutableFileNode, ICheckable)
MUTABLE_SIZELIMIT = 10000 MUTABLE_SIZELIMIT = 10000
def __init__(self, storage_broker, secret_holder, def __init__(self, storage_broker, secret_holder,

View File

@ -14,7 +14,7 @@
# control.furl . # control.furl .
import os import os
from zope.interface import implements from zope.interface import implementer
from twisted.application import service from twisted.application import service
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from twisted.python.failure import Failure from twisted.python.failure import Failure
@ -130,8 +130,8 @@ def wrap_storage_server(original):
wrapper.version = original.remote_get_version() wrapper.version = original.remote_get_version()
return wrapper return wrapper
class NoNetworkServer: @implementer(IServer)
implements(IServer) class NoNetworkServer(object):
def __init__(self, serverid, rref): def __init__(self, serverid, rref):
self.serverid = serverid self.serverid = serverid
self.rref = rref self.rref = rref
@ -164,8 +164,8 @@ class NoNetworkServer:
def get_version(self): def get_version(self):
return self.rref.version return self.rref.version
class NoNetworkStorageBroker: @implementer(IStorageBroker)
implements(IStorageBroker) class NoNetworkStorageBroker(object):
def get_servers_for_psi(self, peer_selection_index): def get_servers_for_psi(self, peer_selection_index):
def _permuted(server): def _permuted(server):
seed = server.get_permutation_seed() seed = server.get_permutation_seed()

View File

@ -2,7 +2,7 @@
import time import time
import unicodedata import unicodedata
from zope.interface import implements from zope.interface import implementer
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IConsumer from twisted.internet.interfaces import IConsumer
@ -27,8 +27,8 @@ from allmydata.nodemaker import NodeMaker
from base64 import b32decode from base64 import b32decode
import allmydata.test.common_util as testutil import allmydata.test.common_util as testutil
class MemAccum: @implementer(IConsumer)
implements(IConsumer) class MemAccum(object):
def registerProducer(self, producer, streaming): def registerProducer(self, producer, streaming):
self.producer = producer self.producer = producer
self.producer.resumeProducing() self.producer.resumeProducing()
@ -1489,8 +1489,8 @@ class Packing(testutil.ReallyEqualMixin, unittest.TestCase):
dirnode.pack_children, dirnode.pack_children,
kids, fn.get_writekey(), deep_immutable=True) kids, fn.get_writekey(), deep_immutable=True)
class FakeMutableFile: @implementer(IMutableFileNode)
implements(IMutableFileNode) class FakeMutableFile(object):
counter = 0 counter = 0
def __init__(self, initial_contents=""): def __init__(self, initial_contents=""):
data = self._get_initial_contents(initial_contents) data = self._get_initial_contents(initial_contents)

View File

@ -1,4 +1,4 @@
from zope.interface import implements from zope.interface import implementer
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from twisted.python.failure import Failure from twisted.python.failure import Failure
@ -17,8 +17,8 @@ class LostPeerError(Exception):
def flip_bit(good): # flips the last bit def flip_bit(good): # flips the last bit
return good[:-1] + chr(ord(good[-1]) ^ 0x01) return good[:-1] + chr(ord(good[-1]) ^ 0x01)
class FakeBucketReaderWriterProxy: @implementer(IStorageBucketWriter, IStorageBucketReader)
implements(IStorageBucketWriter, IStorageBucketReader) class FakeBucketReaderWriterProxy(object):
# these are used for both reading and writing # these are used for both reading and writing
def __init__(self, mode="good", peerid="peer"): def __init__(self, mode="good", peerid="peer"):
self.mode = mode self.mode = mode

View File

@ -1,5 +1,5 @@
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata.interfaces import IFilesystemNode, MustNotBeUnknownRWError, \ from allmydata.interfaces import IFilesystemNode, MustNotBeUnknownRWError, \
MustBeDeepImmutableError MustBeDeepImmutableError
@ -26,8 +26,8 @@ def strip_prefix_for_ro(ro_uri, deep_immutable):
else: else:
return ro_uri return ro_uri
class UnknownNode: @implementer(IFilesystemNode)
implements(IFilesystemNode) class UnknownNode(object):
def __init__(self, given_rw_uri, given_ro_uri, deep_immutable=False, def __init__(self, given_rw_uri, given_ro_uri, deep_immutable=False,
name=u"<unknown name>"): name=u"<unknown name>"):

View File

@ -1,7 +1,7 @@
import re import re
from zope.interface import implements from zope.interface import implementer
from twisted.python.components import registerAdapter from twisted.python.components import registerAdapter
from allmydata.storage.server import si_a2b, si_b2a from allmydata.storage.server import si_a2b, si_b2a
@ -30,7 +30,7 @@ BASE32STR_256bits = '(%s{51}%s)' % (base32.BASE32CHAR, base32.BASE32CHAR_1bits)
NUMBER='([0-9]+)' NUMBER='([0-9]+)'
class _BaseURI: class _BaseURI(object):
def __hash__(self): def __hash__(self):
return self.to_string().__hash__() return self.to_string().__hash__()
@ -50,8 +50,8 @@ class _BaseURI:
return self.storage_index return self.storage_index
@implementer(IURI, IImmutableFileURI)
class CHKFileURI(_BaseURI): class CHKFileURI(_BaseURI):
implements(IURI, IImmutableFileURI)
BASE_STRING='URI:CHK:' BASE_STRING='URI:CHK:'
STRING_RE=re.compile('^URI:CHK:'+BASE32STR_128bits+':'+ STRING_RE=re.compile('^URI:CHK:'+BASE32STR_128bits+':'+
@ -109,8 +109,8 @@ class CHKFileURI(_BaseURI):
size=self.size) size=self.size)
@implementer(IVerifierURI)
class CHKFileVerifierURI(_BaseURI): class CHKFileVerifierURI(_BaseURI):
implements(IVerifierURI)
BASE_STRING='URI:CHK-Verifier:' BASE_STRING='URI:CHK-Verifier:'
STRING_RE=re.compile('^URI:CHK-Verifier:'+BASE32STR_128bits+':'+ STRING_RE=re.compile('^URI:CHK-Verifier:'+BASE32STR_128bits+':'+
@ -158,8 +158,8 @@ class CHKFileVerifierURI(_BaseURI):
return self return self
@implementer(IURI, IImmutableFileURI)
class LiteralFileURI(_BaseURI): class LiteralFileURI(_BaseURI):
implements(IURI, IImmutableFileURI)
BASE_STRING='URI:LIT:' BASE_STRING='URI:LIT:'
STRING_RE=re.compile('^URI:LIT:'+base32.BASE32STR_anybytes+'$') STRING_RE=re.compile('^URI:LIT:'+base32.BASE32STR_anybytes+'$')
@ -199,8 +199,8 @@ class LiteralFileURI(_BaseURI):
return len(self.data) return len(self.data)
@implementer(IURI, IMutableFileURI)
class WriteableSSKFileURI(_BaseURI): class WriteableSSKFileURI(_BaseURI):
implements(IURI, IMutableFileURI)
BASE_STRING='URI:SSK:' BASE_STRING='URI:SSK:'
STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+ STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+
@ -248,8 +248,8 @@ class WriteableSSKFileURI(_BaseURI):
return SSKVerifierURI(self.storage_index, self.fingerprint) return SSKVerifierURI(self.storage_index, self.fingerprint)
@implementer(IURI, IMutableFileURI)
class ReadonlySSKFileURI(_BaseURI): class ReadonlySSKFileURI(_BaseURI):
implements(IURI, IMutableFileURI)
BASE_STRING='URI:SSK-RO:' BASE_STRING='URI:SSK-RO:'
STRING_RE=re.compile('^URI:SSK-RO:'+BASE32STR_128bits+':'+BASE32STR_256bits+'$') STRING_RE=re.compile('^URI:SSK-RO:'+BASE32STR_128bits+':'+BASE32STR_256bits+'$')
@ -295,8 +295,8 @@ class ReadonlySSKFileURI(_BaseURI):
return SSKVerifierURI(self.storage_index, self.fingerprint) return SSKVerifierURI(self.storage_index, self.fingerprint)
@implementer(IVerifierURI)
class SSKVerifierURI(_BaseURI): class SSKVerifierURI(_BaseURI):
implements(IVerifierURI)
BASE_STRING='URI:SSK-Verifier:' BASE_STRING='URI:SSK-Verifier:'
STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'$') STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'$')
@ -332,8 +332,8 @@ class SSKVerifierURI(_BaseURI):
return self return self
@implementer(IURI, IMutableFileURI)
class WriteableMDMFFileURI(_BaseURI): class WriteableMDMFFileURI(_BaseURI):
implements(IURI, IMutableFileURI)
BASE_STRING='URI:MDMF:' BASE_STRING='URI:MDMF:'
STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'(:|$)') STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'(:|$)')
@ -381,8 +381,8 @@ class WriteableMDMFFileURI(_BaseURI):
return MDMFVerifierURI(self.storage_index, self.fingerprint) return MDMFVerifierURI(self.storage_index, self.fingerprint)
@implementer(IURI, IMutableFileURI)
class ReadonlyMDMFFileURI(_BaseURI): class ReadonlyMDMFFileURI(_BaseURI):
implements(IURI, IMutableFileURI)
BASE_STRING='URI:MDMF-RO:' BASE_STRING='URI:MDMF-RO:'
STRING_RE=re.compile('^' +BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'(:|$)') STRING_RE=re.compile('^' +BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'(:|$)')
@ -430,8 +430,8 @@ class ReadonlyMDMFFileURI(_BaseURI):
return MDMFVerifierURI(self.storage_index, self.fingerprint) return MDMFVerifierURI(self.storage_index, self.fingerprint)
@implementer(IVerifierURI)
class MDMFVerifierURI(_BaseURI): class MDMFVerifierURI(_BaseURI):
implements(IVerifierURI)
BASE_STRING='URI:MDMF-Verifier:' BASE_STRING='URI:MDMF-Verifier:'
STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'(:|$)') STRING_RE=re.compile('^'+BASE_STRING+BASE32STR_128bits+':'+BASE32STR_256bits+'(:|$)')
@ -468,8 +468,8 @@ class MDMFVerifierURI(_BaseURI):
return self return self
@implementer(IURI, IDirnodeURI)
class _DirectoryBaseURI(_BaseURI): class _DirectoryBaseURI(_BaseURI):
implements(IURI, IDirnodeURI)
def __init__(self, filenode_uri=None): def __init__(self, filenode_uri=None):
self._filenode_uri = filenode_uri self._filenode_uri = filenode_uri
@ -515,8 +515,8 @@ class _DirectoryBaseURI(_BaseURI):
return self._filenode_uri.get_storage_index() return self._filenode_uri.get_storage_index()
@implementer(IDirectoryURI)
class DirectoryURI(_DirectoryBaseURI): class DirectoryURI(_DirectoryBaseURI):
implements(IDirectoryURI)
BASE_STRING='URI:DIR2:' BASE_STRING='URI:DIR2:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -534,8 +534,8 @@ class DirectoryURI(_DirectoryBaseURI):
return ReadonlyDirectoryURI(self._filenode_uri.get_readonly()) return ReadonlyDirectoryURI(self._filenode_uri.get_readonly())
@implementer(IReadonlyDirectoryURI)
class ReadonlyDirectoryURI(_DirectoryBaseURI): class ReadonlyDirectoryURI(_DirectoryBaseURI):
implements(IReadonlyDirectoryURI)
BASE_STRING='URI:DIR2-RO:' BASE_STRING='URI:DIR2-RO:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -590,8 +590,8 @@ class LiteralDirectoryURI(_ImmutableDirectoryBaseURI):
return None return None
@implementer(IDirectoryURI)
class MDMFDirectoryURI(_DirectoryBaseURI): class MDMFDirectoryURI(_DirectoryBaseURI):
implements(IDirectoryURI)
BASE_STRING='URI:DIR2-MDMF:' BASE_STRING='URI:DIR2-MDMF:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -612,8 +612,8 @@ class MDMFDirectoryURI(_DirectoryBaseURI):
return MDMFDirectoryURIVerifier(self._filenode_uri.get_verify_cap()) return MDMFDirectoryURIVerifier(self._filenode_uri.get_verify_cap())
@implementer(IReadonlyDirectoryURI)
class ReadonlyMDMFDirectoryURI(_DirectoryBaseURI): class ReadonlyMDMFDirectoryURI(_DirectoryBaseURI):
implements(IReadonlyDirectoryURI)
BASE_STRING='URI:DIR2-MDMF-RO:' BASE_STRING='URI:DIR2-MDMF-RO:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -650,8 +650,8 @@ def wrap_dirnode_cap(filecap):
raise AssertionError("cannot interpret as a directory cap: %s" % filecap.__class__) raise AssertionError("cannot interpret as a directory cap: %s" % filecap.__class__)
@implementer(IVerifierURI)
class MDMFDirectoryURIVerifier(_DirectoryBaseURI): class MDMFDirectoryURIVerifier(_DirectoryBaseURI):
implements(IVerifierURI)
BASE_STRING='URI:DIR2-MDMF-Verifier:' BASE_STRING='URI:DIR2-MDMF-Verifier:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -675,8 +675,8 @@ class MDMFDirectoryURIVerifier(_DirectoryBaseURI):
return self return self
@implementer(IVerifierURI)
class DirectoryURIVerifier(_DirectoryBaseURI): class DirectoryURIVerifier(_DirectoryBaseURI):
implements(IVerifierURI)
BASE_STRING='URI:DIR2-Verifier:' BASE_STRING='URI:DIR2-Verifier:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -700,8 +700,8 @@ class DirectoryURIVerifier(_DirectoryBaseURI):
return self return self
@implementer(IVerifierURI)
class ImmutableDirectoryURIVerifier(DirectoryURIVerifier): class ImmutableDirectoryURIVerifier(DirectoryURIVerifier):
implements(IVerifierURI)
BASE_STRING='URI:DIR2-CHK-Verifier:' BASE_STRING='URI:DIR2-CHK-Verifier:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
INNER_URI_CLASS=CHKFileVerifierURI INNER_URI_CLASS=CHKFileVerifierURI

View File

@ -3,7 +3,7 @@ from zope.interface import implementer
from ..interfaces import IConnectionStatus from ..interfaces import IConnectionStatus
@implementer(IConnectionStatus) @implementer(IConnectionStatus)
class ConnectionStatus: class ConnectionStatus(object):
def __init__(self, connected, summary, non_connected_statuses, def __init__(self, connected, summary, non_connected_statuses,
last_connection_time, last_received_time): last_connection_time, last_received_time):
self.connected = connected self.connected = connected

View File

@ -3,11 +3,11 @@
a filenode's read() method. See download_to_data() for an example of its use. a filenode's read() method. See download_to_data() for an example of its use.
""" """
from zope.interface import implements from zope.interface import implementer
from twisted.internet.interfaces import IConsumer from twisted.internet.interfaces import IConsumer
class MemoryConsumer: @implementer(IConsumer)
implements(IConsumer) class MemoryConsumer(object):
def __init__(self, progress=None): def __init__(self, progress=None):
self.chunks = [] self.chunks = []

View File

@ -2,7 +2,7 @@
import simplejson import simplejson
import urllib import urllib
from zope.interface import implements from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.interfaces import IPushProducer from twisted.internet.interfaces import IPushProducer
from twisted.python.failure import Failure from twisted.python.failure import Failure
@ -1087,8 +1087,8 @@ class DeepStatsResults(rend.Page):
s["finished"] = self.monitor.is_finished() s["finished"] = self.monitor.is_finished()
return simplejson.dumps(s, indent=1) return simplejson.dumps(s, indent=1)
@implementer(IPushProducer)
class ManifestStreamer(dirnode.DeepStats): class ManifestStreamer(dirnode.DeepStats):
implements(IPushProducer)
def __init__(self, ctx, origin): def __init__(self, ctx, origin):
dirnode.DeepStats.__init__(self, origin) dirnode.DeepStats.__init__(self, origin)
@ -1144,8 +1144,8 @@ class ManifestStreamer(dirnode.DeepStats):
self.req.write(j+"\n") self.req.write(j+"\n")
return "" return ""
@implementer(IPushProducer)
class DeepCheckStreamer(dirnode.DeepStats): class DeepCheckStreamer(dirnode.DeepStats):
implements(IPushProducer)
def __init__(self, ctx, origin, verify, repair, add_lease): def __init__(self, ctx, origin, verify, repair, add_lease):
dirnode.DeepStats.__init__(self, origin) dirnode.DeepStats.__init__(self, origin)

View File

@ -1,6 +1,6 @@
import time import time
from zope.interface import implements from zope.interface import implementer
from nevow import rend, url, tags as T from nevow import rend, url, tags as T
from nevow.inevow import IRequest from nevow.inevow import IRequest
from twisted.python.failure import Failure from twisted.python.failure import Failure
@ -18,8 +18,8 @@ DAY = 24*HOUR
(MONITOR, RENDERER, WHEN_ADDED) = range(3) (MONITOR, RENDERER, WHEN_ADDED) = range(3)
@implementer(IOpHandleTable)
class OphandleTable(rend.Page, service.Service): class OphandleTable(rend.Page, service.Service):
implements(IOpHandleTable)
UNCOLLECTED_HANDLE_LIFETIME = 4*DAY UNCOLLECTED_HANDLE_LIFETIME = 4*DAY
COLLECTED_HANDLE_LIFETIME = 1*DAY COLLECTED_HANDLE_LIFETIME = 1*DAY