]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
interfaces.py: promote immutable.encode.NotEnoughSharesError.. it isn't just for...
authorBrian Warner <warner@lothar.com>
Mon, 27 Oct 2008 20:34:49 +0000 (13:34 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 27 Oct 2008 20:34:49 +0000 (13:34 -0700)
12 files changed:
src/allmydata/immutable/download.py
src/allmydata/immutable/encode.py
src/allmydata/immutable/upload.py
src/allmydata/interfaces.py
src/allmydata/mutable/node.py
src/allmydata/mutable/retrieve.py
src/allmydata/test/common.py
src/allmydata/test/test_encode.py
src/allmydata/test/test_immutable_checker.py
src/allmydata/test/test_mutable.py
src/allmydata/test/test_system.py
src/allmydata/test/test_upload.py

index a2216bee9576ad456bfa02b1e60bc98513e15d36..80cd2460d176959509ee9b139c212ca0d0648392 100644 (file)
@@ -11,9 +11,8 @@ from allmydata.util import base32, mathutil, hashutil, log, observer
 from allmydata.util.assertutil import _assert
 from allmydata import codec, hashtree, storage, uri
 from allmydata.interfaces import IDownloadTarget, IDownloader, IFileURI, \
-     IDownloadStatus, IDownloadResults
+     IDownloadStatus, IDownloadResults, NotEnoughSharesError
 from allmydata.immutable import layout
-from allmydata.immutable.encode import NotEnoughSharesError
 from pycryptopp.cipher.aes import AES
 
 class HaveAllPeersError(Exception):
index 1982567c3a0557c4e0d8f98e5d3715691c8b956c..a2a134389cd72e29a677ca2fb6a36863abee5883 100644 (file)
@@ -10,7 +10,7 @@ from allmydata.util import mathutil, hashutil, base32, log
 from allmydata.util.assertutil import _assert, precondition
 from allmydata.codec import CRSEncoder
 from allmydata.interfaces import IEncoder, IStorageBucketWriter, \
-     IEncryptedUploadable, IUploadStatus
+     IEncryptedUploadable, IUploadStatus, NotEnoughSharesError
 
 """
 The goal of the encoder is to turn the original file into a series of
@@ -60,10 +60,6 @@ hash tree is put into the URI.
 
 """
 
-class NotEnoughSharesError(Exception):
-    servermap = None
-    pass
-
 class UploadAborted(Exception):
     pass
 
index 40fed09b7f8225b761f91c4e62bee70977dd2a8b..8c219935f3c97815ad94ba56ff169c7efe0b001c 100644 (file)
@@ -17,7 +17,7 @@ from allmydata.immutable import encode
 from allmydata.util import base32, idlib, mathutil
 from allmydata.util.assertutil import precondition
 from allmydata.interfaces import IUploadable, IUploader, IUploadResults, \
-     IEncryptedUploadable, RIEncryptedUploadable, IUploadStatus
+     IEncryptedUploadable, RIEncryptedUploadable, IUploadStatus, NotEnoughSharesError
 from allmydata.immutable import layout
 from pycryptopp.cipher.aes import AES
 
@@ -161,7 +161,7 @@ class Tahoe2PeerSelector:
 
         peers = client.get_permuted_peers("storage", storage_index)
         if not peers:
-            raise encode.NotEnoughSharesError("client gave us zero peers")
+            raise NotEnoughSharesError("client gave us zero peers")
 
         # figure out how much space to ask for
 
@@ -273,7 +273,7 @@ class Tahoe2PeerSelector:
                 if self.last_failure_msg:
                     msg += " (%s)" % (self.last_failure_msg,)
                 log.msg(msg, level=log.UNUSUAL, parent=self._log_parent)
-                raise encode.NotEnoughSharesError(msg)
+                raise NotEnoughSharesError(msg)
             else:
                 # we placed enough to be happy, so we're done
                 if self._status:
index 31d19c12bd1a778a92a6ee4dc8cadac665db5fde..7acc163d54fad2b57682fbe2248c8aebeeebdb2c 100644 (file)
@@ -649,6 +649,9 @@ class IMutableFileNode(IFileNode, IMutableFilesystemNode):
         writer-visible data using this writekey.
         """
 
+class NotEnoughSharesError(Exception):
+    servermap = None
+
 class ExistingChildError(Exception):
     """A directory node was asked to add or replace a child that already
     exists, and overwrite= was set to False."""
index b7d8800f73e8f68747a34ba22e3fdb02a122e9ed..8ab2eacf47e29d57e9637c2dbf66d5f643220d97 100644 (file)
@@ -6,12 +6,11 @@ from zope.interface import implements
 from twisted.internet import defer, reactor
 from foolscap.eventual import eventually
 from allmydata.interfaces import IMutableFileNode, IMutableFileURI, \
-     ICheckable, ICheckerResults
+     ICheckable, ICheckerResults, NotEnoughSharesError
 from allmydata.util import hashutil, log
 from allmydata.util.assertutil import precondition
 from allmydata.uri import WriteableSSKFileURI
 from allmydata.monitor import Monitor
-from allmydata.immutable.encode import NotEnoughSharesError
 from pycryptopp.publickey import rsa
 from pycryptopp.cipher.aes import AES
 
index 300475e075a969ecc7d1c5ebe2068d43f8a7554d..9ce25c0df66d9c39a2a801206cd1beeeb2b410d4 100644 (file)
@@ -6,10 +6,9 @@ from twisted.internet import defer
 from twisted.python import failure
 from foolscap import DeadReferenceError
 from foolscap.eventual import eventually, fireEventually
-from allmydata.interfaces import IRetrieveStatus
+from allmydata.interfaces import IRetrieveStatus, NotEnoughSharesError
 from allmydata.util import hashutil, idlib, log
 from allmydata import hashtree, codec, storage
-from allmydata.immutable.encode import NotEnoughSharesError
 from pycryptopp.cipher.aes import AES
 from pycryptopp.publickey import rsa
 
index b40c1fc5501a1a2a55779f89d19786a3b0efbea3..4e08af29d083594a06094c1b701932bb67e98db1 100644 (file)
@@ -10,8 +10,7 @@ from foolscap.eventual import flushEventualQueue, fireEventually
 from allmydata import uri, dirnode, client
 from allmydata.introducer.server import IntroducerNode
 from allmydata.interfaces import IURI, IMutableFileNode, IFileNode, \
-     FileTooLargeError, ICheckable
-from allmydata.immutable.encode import NotEnoughSharesError
+     FileTooLargeError, NotEnoughSharesError, ICheckable
 from allmydata.checker_results import CheckerResults, CheckAndRepairResults, \
      DeepCheckResults, DeepCheckAndRepairResults
 from allmydata.mutable.common import CorruptShareError
index 9266fdb84101a1b63b9406ab2ca0a8d5fbd2f221..0a477bbbbcd2bb217bf9ba1f5947542c8669a372 100644 (file)
@@ -9,7 +9,7 @@ from allmydata import hashtree, uri
 from allmydata.immutable import encode, upload, download
 from allmydata.util import hashutil, testutil
 from allmydata.util.assertutil import _assert
-from allmydata.interfaces import IStorageBucketWriter, IStorageBucketReader
+from allmydata.interfaces import IStorageBucketWriter, IStorageBucketReader, NotEnoughSharesError
 
 class LostPeerError(Exception):
     pass
@@ -455,7 +455,7 @@ class Roundtrip(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.send_and_recover((4,8,10), AVAILABLE_SHARES=2)
         def _done(res):
             self.failUnless(isinstance(res, Failure))
-            self.failUnless(res.check(download.NotEnoughSharesError))
+            self.failUnless(res.check(NotEnoughSharesError))
         d.addBoth(_done)
         return d
 
@@ -527,7 +527,7 @@ class Roundtrip(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.send_and_recover((4,8,10), bucket_modes=modemap)
         def _done(res):
             self.failUnless(isinstance(res, Failure))
-            self.failUnless(res.check(download.NotEnoughSharesError))
+            self.failUnless(res.check(NotEnoughSharesError))
         d.addBoth(_done)
         return d
 
@@ -550,7 +550,7 @@ class Roundtrip(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.send_and_recover((4,8,10), bucket_modes=modemap)
         def _done(res):
             self.failUnless(isinstance(res, Failure))
-            self.failUnless(res.check(download.NotEnoughSharesError))
+            self.failUnless(res.check(NotEnoughSharesError))
         d.addBoth(_done)
         return d
 
@@ -680,7 +680,7 @@ class Roundtrip(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.send_and_recover((4,8,10), bucket_modes=modemap)
         def _done(res):
             self.failUnless(isinstance(res, Failure))
-            self.failUnless(res.check(download.NotEnoughSharesError))
+            self.failUnless(res.check(NotEnoughSharesError))
         d.addBoth(_done)
         return d
 
@@ -703,7 +703,7 @@ class Roundtrip(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.send_and_recover((4,8,10), bucket_modes=modemap)
         def _done(res):
             self.failUnless(isinstance(res, Failure))
-            self.failUnless(res.check(download.NotEnoughSharesError))
+            self.failUnless(res.check(NotEnoughSharesError))
         d.addBoth(_done)
         return d
 
@@ -732,7 +732,7 @@ class Roundtrip(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.send_and_recover((4,8,10), bucket_modes=modemap)
         def _done(res):
             self.failUnless(isinstance(res, Failure))
-            self.failUnless(res.check(encode.NotEnoughSharesError), res)
+            self.failUnless(res.check(NotEnoughSharesError), res)
         d.addBoth(_done)
         return d
 
@@ -743,7 +743,7 @@ class Roundtrip(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.send_and_recover((4,8,10), bucket_modes=modemap)
         def _done(res):
             self.failUnless(isinstance(res, Failure))
-            self.failUnless(res.check(encode.NotEnoughSharesError))
+            self.failUnless(res.check(NotEnoughSharesError))
         d.addBoth(_done)
         return d
 
index 7d1d99d8f5600a4c00d4e34d00148ecc566678e9..8bf28f15410c75c3459f8f7e1752d17515c3106e 100644 (file)
@@ -1,8 +1,8 @@
-from allmydata.immutable import encode, upload
+from allmydata.immutable import upload
 from allmydata.test.common import SystemTestMixin, ShareManglingMixin
 from allmydata.util import testutil
 from allmydata.monitor import Monitor
-from allmydata.interfaces import IURI
+from allmydata.interfaces import IURI, NotEnoughSharesError
 from twisted.internet import defer
 from twisted.trial import unittest
 import random, struct
@@ -273,7 +273,7 @@ class Test(ShareManglingMixin, unittest.TestCase):
                 self.fail() # should have gotten an errback instead
                 return result
             def _after_download_errb(failure):
-                failure.trap(encode.NotEnoughSharesError)
+                failure.trap(NotEnoughSharesError)
                 return None # success!
             d.addCallbacks(_after_download_callb, _after_download_errb)
         d.addCallback(_then_download)
index bcf0d0888bcc476d7c373e39d5c7b64efdc0327d..d778b93ad1f5db1909ed18404a25241d62b08bb2 100644 (file)
@@ -6,13 +6,12 @@ from twisted.internet import defer, reactor
 from twisted.python import failure
 from allmydata import uri, storage
 from allmydata.immutable import download
-from allmydata.immutable.encode import NotEnoughSharesError
 from allmydata.util import base32, testutil, idlib
 from allmydata.util.idlib import shortnodeid_b2a
 from allmydata.util.hashutil import tagged_hash
 from allmydata.util.fileutil import make_dirs
 from allmydata.interfaces import IURI, IMutableFileURI, IUploadable, \
-     FileTooLargeError, IRepairResults
+     FileTooLargeError, NotEnoughSharesError, IRepairResults
 from allmydata.monitor import Monitor
 from allmydata.test.common import ShouldFailMixin
 from foolscap.eventual import eventually, fireEventually
index 428378413093740f0cfff2132593a67c2e22938a..e3d0ddfb55997476a50e3847405b4556e63afceb 100644 (file)
@@ -15,7 +15,7 @@ from allmydata.util import log, base32
 from allmydata.scripts import runner
 from allmydata.interfaces import IDirectoryNode, IFileNode, IFileURI, \
      ICheckerResults, ICheckAndRepairResults, IDeepCheckResults, \
-     IDeepCheckAndRepairResults, NoSuchChildError
+     IDeepCheckAndRepairResults, NoSuchChildError, NotEnoughSharesError
 from allmydata.monitor import Monitor, OperationCancelledError
 from allmydata.mutable.common import NotMutableError
 from allmydata.mutable import layout as mutable_layout
@@ -194,7 +194,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase):
                 log.msg("finished downloading non-existend URI",
                         level=log.UNUSUAL, facility="tahoe.tests")
                 self.failUnless(isinstance(res, Failure))
-                self.failUnless(res.check(download.NotEnoughSharesError),
+                self.failUnless(res.check(NotEnoughSharesError),
                                 "expected NotEnoughSharesError, got %s" % res)
                 # TODO: files that have zero peers should get a special kind
                 # of NotEnoughSharesError, which can be used to suggest that
index 221c985b4f90cff8fbd6908cb8c683a450bd417a..6bfe12ebe9be75cb277bcf43ec1eb443f674e1bc 100644 (file)
@@ -7,8 +7,8 @@ from twisted.internet import defer
 from cStringIO import StringIO
 
 from allmydata import uri
-from allmydata.immutable import upload, encode
-from allmydata.interfaces import IFileURI, FileTooLargeError
+from allmydata.immutable import upload
+from allmydata.interfaces import IFileURI, FileTooLargeError, NotEnoughSharesError
 from allmydata.util.assertutil import precondition
 from allmydata.util.deferredutil import DeferredListShouldSucceed
 from allmydata.util.testutil import ShouldFailMixin
@@ -347,7 +347,7 @@ class FullServer(unittest.TestCase):
         self.u.parent = self.node
 
     def _should_fail(self, f):
-        self.failUnless(isinstance(f, Failure) and f.check(encode.NotEnoughSharesError), f)
+        self.failUnless(isinstance(f, Failure) and f.check(NotEnoughSharesError), f)
 
     def test_data_large(self):
         data = DATA