mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
Merge pull request #600 from tahoe-lafs/3019-remove-tuple-unpacking
3019 remove tuple unpacking, Fixes: ticket:3019
This commit is contained in:
commit
27a0a7400d
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,6 +27,7 @@ Twisted-*.egg
|
||||
zope.interface-*.egg
|
||||
.pc
|
||||
|
||||
/src/allmydata/test/plugins/dropin.cache
|
||||
/_trial_temp*
|
||||
/_test_memory/
|
||||
/tmp*
|
||||
|
1
newsfragments/3019.other
Normal file
1
newsfragments/3019.other
Normal file
@ -0,0 +1 @@
|
||||
Removed tuple unpacking from function and lambda definitions for Python3 compatibility.
|
@ -10,38 +10,27 @@ src/allmydata/client.py
|
||||
src/allmydata/codec.py
|
||||
src/allmydata/control.py
|
||||
src/allmydata/deep_stats.py
|
||||
src/allmydata/frontends/auth.py
|
||||
src/allmydata/frontends/__init__.py
|
||||
src/allmydata/frontends/magic_folder.py
|
||||
src/allmydata/dirnode.py
|
||||
src/allmydata/frontends/
|
||||
src/allmydata/hashtree.py
|
||||
src/allmydata/history.py
|
||||
src/allmydata/immutable/checker.py
|
||||
src/allmydata/immutable/downloader/common.py
|
||||
src/allmydata/immutable/downloader/fetcher.py
|
||||
src/allmydata/immutable/downloader/finder.py
|
||||
src/allmydata/immutable/downloader/__init__.py
|
||||
src/allmydata/immutable/downloader/share.py
|
||||
src/allmydata/immutable/downloader/status.py
|
||||
src/allmydata/immutable/downloader/
|
||||
src/allmydata/immutable/encode.py
|
||||
src/allmydata/immutable/filenode.py
|
||||
src/allmydata/immutable/__init__.py
|
||||
src/allmydata/immutable/layout.py
|
||||
src/allmydata/immutable/literal.py
|
||||
src/allmydata/immutable/offloaded.py
|
||||
src/allmydata/immutable/repairer.py
|
||||
src/allmydata/immutable/upload.py
|
||||
src/allmydata/__init__.py
|
||||
src/allmydata/interfaces.py
|
||||
src/allmydata/introducer/
|
||||
src/allmydata/magicfolderdb.py
|
||||
src/allmydata/__main__.py
|
||||
src/allmydata/monitor.py
|
||||
src/allmydata/mutable/checker.py
|
||||
src/allmydata/mutable/common.py
|
||||
src/allmydata/mutable/__init__.py
|
||||
src/allmydata/mutable/layout.py
|
||||
src/allmydata/mutable/publish.py
|
||||
src/allmydata/mutable/repairer.py
|
||||
src/allmydata/mutable/retrieve.py
|
||||
src/allmydata/mutable/servermap.py
|
||||
src/allmydata/mutable/
|
||||
src/allmydata/nodemaker.py
|
||||
src/allmydata/node.py
|
||||
src/allmydata/scripts/admin.py
|
||||
@ -50,6 +39,7 @@ src/allmydata/scripts/cli.py
|
||||
src/allmydata/scripts/common_http.py
|
||||
src/allmydata/scripts/common.py
|
||||
src/allmydata/scripts/create_node.py
|
||||
src/allmydata/scripts/debug.py
|
||||
src/allmydata/scripts/default_nodedir.py
|
||||
src/allmydata/scripts/__init__.py
|
||||
src/allmydata/scripts/magic_folder_cli.py
|
||||
@ -84,9 +74,17 @@ src/allmydata/test/check_speed.py
|
||||
src/allmydata/test/cli/common.py
|
||||
src/allmydata/test/cli/__init__.py
|
||||
src/allmydata/test/cli/test_alias.py
|
||||
src/allmydata/test/cli/test_backup.py
|
||||
src/allmydata/test/cli/test_check.py
|
||||
src/allmydata/test/cli/test_cli.py
|
||||
src/allmydata/test/cli/test_create_alias.py
|
||||
src/allmydata/test/cli/test_create.py
|
||||
src/allmydata/test/cli/test_daemonize.py
|
||||
src/allmydata/test/cli/test_invite.py
|
||||
src/allmydata/test/cli/test_list.py
|
||||
src/allmydata/test/cli/test_magic_folder.py
|
||||
src/allmydata/test/cli/test_mv.py
|
||||
src/allmydata/test/cli/test_put.py
|
||||
src/allmydata/test/cli/test_start.py
|
||||
src/allmydata/test/cli/test_status.py
|
||||
src/allmydata/test/common.py
|
||||
@ -94,32 +92,21 @@ src/allmydata/test/common_util.py
|
||||
src/allmydata/test/common_web.py
|
||||
src/allmydata/test/eliotutil.py
|
||||
src/allmydata/test/__init__.py
|
||||
src/allmydata/test/mutable/__init__.py
|
||||
src/allmydata/test/mutable/test_checker.py
|
||||
src/allmydata/test/mutable/test_datahandle.py
|
||||
src/allmydata/test/mutable/test_different_encoding.py
|
||||
src/allmydata/test/mutable/test_exceptions.py
|
||||
src/allmydata/test/mutable/test_filehandle.py
|
||||
src/allmydata/test/mutable/test_filenode.py
|
||||
src/allmydata/test/mutable/test_interoperability.py
|
||||
src/allmydata/test/mutable/test_multiple_encodings.py
|
||||
src/allmydata/test/mutable/test_multiple_versions.py
|
||||
src/allmydata/test/mutable/test_repair.py
|
||||
src/allmydata/test/mutable/test_roundtrip.py
|
||||
src/allmydata/test/mutable/test_servermap.py
|
||||
src/allmydata/test/mutable/test_update.py
|
||||
src/allmydata/test/mutable/test_version.py
|
||||
src/allmydata/test/mutable/util.py
|
||||
src/allmydata/test/plugins/tahoe_lafs_dropin.py
|
||||
src/allmydata/test/mutable/
|
||||
src/allmydata/test/no_network.py
|
||||
src/allmydata/test/plugins/
|
||||
src/allmydata/test/status.py
|
||||
src/allmydata/test/test_auth.py
|
||||
src/allmydata/test/test_backupdb.py
|
||||
src/allmydata/test/test_checker.py
|
||||
src/allmydata/test/test_client.py
|
||||
src/allmydata/test/test_codec.py
|
||||
src/allmydata/test/test_configutil.py
|
||||
src/allmydata/test/test_connections.py
|
||||
src/allmydata/test/test_crawler.py
|
||||
src/allmydata/test/test_deepcheck.py
|
||||
src/allmydata/test/test_dirnode.py
|
||||
src/allmydata/test/test_download.py
|
||||
src/allmydata/test/test_eliotutil.py
|
||||
src/allmydata/test/test_encode.py
|
||||
src/allmydata/test/test_encodingutil.py
|
||||
@ -145,21 +132,18 @@ src/allmydata/test/test_no_network.py
|
||||
src/allmydata/test/test_observer.py
|
||||
src/allmydata/test/test_repairer.py
|
||||
src/allmydata/test/test_runner.py
|
||||
src/allmydata/test/test_sftp.py
|
||||
src/allmydata/test/test_stats.py
|
||||
src/allmydata/test/test_storage_client.py
|
||||
src/allmydata/test/test_storage.py
|
||||
src/allmydata/test/test_system.py
|
||||
src/allmydata/test/test_tor_provider.py
|
||||
src/allmydata/test/test_upload.py
|
||||
src/allmydata/test/test_uri.py
|
||||
src/allmydata/test/test_util.py
|
||||
src/allmydata/test/test_version.py
|
||||
src/allmydata/test/web/common.py
|
||||
src/allmydata/test/web/__init__.py
|
||||
src/allmydata/test/web/matchers.py
|
||||
src/allmydata/test/web/test_grid.py
|
||||
src/allmydata/test/web/test_introducer.py
|
||||
src/allmydata/test/web/test_logs.py
|
||||
src/allmydata/test/web/test_private.py
|
||||
src/allmydata/test/web/test_root.py
|
||||
src/allmydata/test/web/test_token.py
|
||||
src/allmydata/test/web/test_util.py
|
||||
src/allmydata/test/_twisted_9607.py
|
||||
src/allmydata/test/web/
|
||||
src/allmydata/unknown.py
|
||||
src/allmydata/uri.py
|
||||
src/allmydata/util/abbreviate.py
|
||||
@ -196,6 +180,7 @@ src/allmydata/util/progress.py
|
||||
src/allmydata/util/repeatable_random.py
|
||||
src/allmydata/util/rrefutil.py
|
||||
src/allmydata/util/sibpath.py
|
||||
src/allmydata/util/spans.py
|
||||
src/allmydata/util/statistics.py
|
||||
src/allmydata/util/time_format.py
|
||||
src/allmydata/util/tor_provider.py
|
||||
|
@ -532,7 +532,7 @@ class DirectoryNode(object):
|
||||
path-name elements.
|
||||
"""
|
||||
d = self.get_child_and_metadata_at_path(pathx)
|
||||
d.addCallback(lambda (node, metadata): node)
|
||||
d.addCallback(lambda node_and_metadata: node_and_metadata[0])
|
||||
return d
|
||||
|
||||
def get_child_and_metadata_at_path(self, pathx):
|
||||
@ -709,7 +709,8 @@ class DirectoryNode(object):
|
||||
return defer.succeed("redundant rename/relink")
|
||||
|
||||
d = self.get_child_and_metadata(current_child_name)
|
||||
def _got_child( (child, metadata) ):
|
||||
def _got_child(child_and_metadata):
|
||||
(child, metadata) = child_and_metadata
|
||||
return new_parent.set_node(new_child_name, child, metadata,
|
||||
overwrite=overwrite)
|
||||
d.addCallback(_got_child)
|
||||
|
@ -83,8 +83,8 @@ class Handler(object):
|
||||
|
||||
def makeDirectory(self, path):
|
||||
d = self._get_root(path)
|
||||
d.addCallback(lambda (root,path):
|
||||
self._get_or_create_directories(root, path))
|
||||
d.addCallback(lambda root_and_path:
|
||||
self._get_or_create_directories(root_and_path[0], root_and_path[1]))
|
||||
return d
|
||||
|
||||
def _get_or_create_directories(self, node, path):
|
||||
@ -110,7 +110,8 @@ class Handler(object):
|
||||
raise NoParentError
|
||||
childname = path[-1]
|
||||
d = self._get_root(path)
|
||||
def _got_root((root, path)):
|
||||
def _got_root(root_and_path):
|
||||
(root, path) = root_and_path
|
||||
if not path:
|
||||
raise NoParentError
|
||||
return root.get_child_at_path(path[:-1])
|
||||
@ -126,7 +127,8 @@ class Handler(object):
|
||||
f.trap(NoParentError)
|
||||
raise ftp.PermissionDeniedError("cannot delete root directory")
|
||||
d.addErrback(_convert_error)
|
||||
def _got_parent( (parent, childname) ):
|
||||
def _got_parent(parent_and_childname):
|
||||
(parent, childname) = parent_and_childname
|
||||
d = parent.get(childname)
|
||||
def _got_child(child):
|
||||
if must_be_directory and not IDirectoryNode.providedBy(child):
|
||||
@ -149,11 +151,12 @@ class Handler(object):
|
||||
def rename(self, fromPath, toPath):
|
||||
# the target directory must already exist
|
||||
d = self._get_parent(fromPath)
|
||||
def _got_from_parent( (fromparent, childname) ):
|
||||
def _got_from_parent(fromparent_and_childname):
|
||||
(fromparent, childname) = fromparent_and_childname
|
||||
d = self._get_parent(toPath)
|
||||
d.addCallback(lambda (toparent, tochildname):
|
||||
d.addCallback(lambda toparent_and_tochildname:
|
||||
fromparent.move_child_to(childname,
|
||||
toparent, tochildname,
|
||||
toparent_and_tochildname[0], toparent_and_tochildname[1],
|
||||
overwrite=False))
|
||||
return d
|
||||
d.addCallback(_got_from_parent)
|
||||
@ -192,7 +195,8 @@ class Handler(object):
|
||||
|
||||
def _get_node_and_metadata_for_path(self, path):
|
||||
d = self._get_root(path)
|
||||
def _got_root((root,path)):
|
||||
def _got_root(root_and_path):
|
||||
(root,path) = root_and_path
|
||||
if path:
|
||||
return root.get_child_and_metadata_at_path(path)
|
||||
else:
|
||||
@ -200,7 +204,8 @@ class Handler(object):
|
||||
d.addCallback(_got_root)
|
||||
return d
|
||||
|
||||
def _populate_row(self, keys, (childnode, metadata)):
|
||||
def _populate_row(self, keys, childnode_and_metadata):
|
||||
(childnode, metadata) = childnode_and_metadata
|
||||
values = []
|
||||
isdir = bool(IDirectoryNode.providedBy(childnode))
|
||||
for key in keys:
|
||||
@ -238,7 +243,8 @@ class Handler(object):
|
||||
def stat(self, path, keys=()):
|
||||
# for files only, I think
|
||||
d = self._get_node_and_metadata_for_path(path)
|
||||
def _render((node,metadata)):
|
||||
def _render(node_and_metadata):
|
||||
(node, metadata) = node_and_metadata
|
||||
assert not IDirectoryNode.providedBy(node)
|
||||
return self._populate_row(keys, (node,metadata))
|
||||
d.addCallback(_render)
|
||||
@ -249,7 +255,8 @@ class Handler(object):
|
||||
# the interface claims that path is a list of unicodes, but in
|
||||
# practice it is not
|
||||
d = self._get_node_and_metadata_for_path(path)
|
||||
def _list((node, metadata)):
|
||||
def _list(node_and_metadata):
|
||||
(node, metadata) = node_and_metadata
|
||||
if IDirectoryNode.providedBy(node):
|
||||
return node.list()
|
||||
return { path[-1]: (node, metadata) } # need last-edge metadata
|
||||
@ -269,7 +276,7 @@ class Handler(object):
|
||||
|
||||
def openForReading(self, path):
|
||||
d = self._get_node_and_metadata_for_path(path)
|
||||
d.addCallback(lambda (node,metadata): ReadFile(node))
|
||||
d.addCallback(lambda node_and_metadata: ReadFile(node_and_metadata[0]))
|
||||
d.addErrback(self._convert_error)
|
||||
return d
|
||||
|
||||
@ -279,7 +286,8 @@ class Handler(object):
|
||||
raise ftp.PermissionDeniedError("cannot STOR to root directory")
|
||||
childname = path[-1]
|
||||
d = self._get_root(path)
|
||||
def _got_root((root, path)):
|
||||
def _got_root(root_and_path):
|
||||
(root, path) = root_and_path
|
||||
if not path:
|
||||
raise ftp.PermissionDeniedError("cannot STOR to root directory")
|
||||
return root.get_child_at_path(path[:-1])
|
||||
|
@ -1346,7 +1346,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
|
||||
d = delay or defer.succeed(None)
|
||||
d.addCallback(lambda ign: self._get_root(path))
|
||||
def _got_root( (root, path) ):
|
||||
def _got_root(root_and_path):
|
||||
(root, path) = root_and_path
|
||||
if root.is_unknown():
|
||||
raise SFTPError(FX_PERMISSION_DENIED,
|
||||
"cannot open an unknown cap (or child of an unknown object). "
|
||||
@ -1424,7 +1425,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
if noisy: self.log("%r.get_child_and_metadata(%r)" % (parent, childname), level=NOISY)
|
||||
d3.addCallback(lambda ign: parent.get_child_and_metadata(childname))
|
||||
|
||||
def _got_child( (filenode, current_metadata) ):
|
||||
def _got_child(filenode_and_current_metadata):
|
||||
(filenode, current_metadata) = filenode_and_current_metadata
|
||||
if noisy: self.log("_got_child( (%r, %r) )" % (filenode, current_metadata), level=NOISY)
|
||||
|
||||
metadata = update_metadata(current_metadata, desired_metadata, time())
|
||||
@ -1485,7 +1487,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
# the target directory must already exist
|
||||
d = deferredutil.gatherResults([self._get_parent_or_node(from_path),
|
||||
self._get_parent_or_node(to_path)])
|
||||
def _got( (from_pair, to_pair) ):
|
||||
def _got(from_pair_and_to_pair):
|
||||
(from_pair, to_pair) = from_pair_and_to_pair
|
||||
if noisy: self.log("_got( (%r, %r) ) in .renameFile(%r, %r, overwrite=%r)" %
|
||||
(from_pair, to_pair, from_pathstring, to_pathstring, overwrite), level=NOISY)
|
||||
(from_parent, from_childname) = from_pair
|
||||
@ -1556,8 +1559,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
return defer.execute(_denied)
|
||||
|
||||
d = self._get_root(path)
|
||||
d.addCallback(lambda (root, path):
|
||||
self._get_or_create_directories(root, path, metadata))
|
||||
d.addCallback(lambda root_and_path:
|
||||
self._get_or_create_directories(root_and_path[0], root_and_path[1], metadata))
|
||||
d.addBoth(_convert_error, request)
|
||||
return d
|
||||
|
||||
@ -1599,7 +1602,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
def _remove_object(self, path, must_be_directory=False, must_be_file=False):
|
||||
userpath = self._path_to_utf8(path)
|
||||
d = self._get_parent_or_node(path)
|
||||
def _got_parent( (parent, childname) ):
|
||||
def _got_parent(parent_and_childname):
|
||||
(parent, childname) = parent_and_childname
|
||||
if childname is None:
|
||||
raise SFTPError(FX_NO_SUCH_FILE, "cannot remove an object specified by URI")
|
||||
|
||||
@ -1621,7 +1625,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
|
||||
path = self._path_from_string(pathstring)
|
||||
d = self._get_parent_or_node(path)
|
||||
def _got_parent_or_node( (parent_or_node, childname) ):
|
||||
def _got_parent_or_node(parent_or_node__and__childname):
|
||||
(parent_or_node, childname) = parent_or_node__and__childname
|
||||
if noisy: self.log("_got_parent_or_node( (%r, %r) ) in openDirectory(%r)" %
|
||||
(parent_or_node, childname, pathstring), level=NOISY)
|
||||
if childname is None:
|
||||
@ -1668,7 +1673,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
path = self._path_from_string(pathstring)
|
||||
userpath = self._path_to_utf8(path)
|
||||
d = self._get_parent_or_node(path)
|
||||
def _got_parent_or_node( (parent_or_node, childname) ):
|
||||
def _got_parent_or_node(parent_or_node__and__childname):
|
||||
(parent_or_node, childname) = parent_or_node__and__childname
|
||||
if noisy: self.log("_got_parent_or_node( (%r, %r) )" % (parent_or_node, childname), level=NOISY)
|
||||
|
||||
# Some clients will incorrectly try to get the attributes
|
||||
@ -1688,7 +1694,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
else:
|
||||
parent = parent_or_node
|
||||
d2.addCallback(lambda ign: parent.get_child_and_metadata_at_path([childname]))
|
||||
def _got( (child, metadata) ):
|
||||
def _got(child_and_metadata):
|
||||
(child, metadata) = child_and_metadata
|
||||
if noisy: self.log("_got( (%r, %r) )" % (child, metadata), level=NOISY)
|
||||
_assert(IDirectoryNode.providedBy(parent), parent=parent)
|
||||
metadata['no-write'] = _no_write(parent.is_readonly(), child, metadata)
|
||||
@ -1726,7 +1733,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
path = self._path_from_string(pathstring)
|
||||
userpath = self._path_to_utf8(path)
|
||||
d = self._get_parent_or_node(path)
|
||||
def _got_parent_or_node( (parent_or_node, childname) ):
|
||||
def _got_parent_or_node(parent_or_node__and__childname):
|
||||
(parent_or_node, childname) = parent_or_node__and__childname
|
||||
if noisy: self.log("_got_parent_or_node( (%r, %r) )" % (parent_or_node, childname), level=NOISY)
|
||||
|
||||
direntry = _direntry_for(parent_or_node, childname)
|
||||
@ -1871,7 +1879,8 @@ class SFTPUserHandler(ConchUser, PrefixingLogMixin):
|
||||
def _get_parent_or_node(self, path):
|
||||
# return Deferred (parent, childname) or (node, None)
|
||||
d = self._get_root(path)
|
||||
def _got_root( (root, remaining_path) ):
|
||||
def _got_root(root_and_remaining_path):
|
||||
(root, remaining_path) = root_and_remaining_path
|
||||
if not remaining_path:
|
||||
return (root, None)
|
||||
else:
|
||||
|
@ -473,7 +473,8 @@ class DownloadNode:
|
||||
d.addCallback(_process)
|
||||
return d
|
||||
|
||||
def _check_ciphertext_hash(self, (segment, decodetime), segnum):
|
||||
def _check_ciphertext_hash(self, segment_and_decodetime, segnum):
|
||||
(segment, decodetime) = segment_and_decodetime
|
||||
start = now()
|
||||
assert self._active_segment.segnum == segnum
|
||||
assert self.segment_size is not None
|
||||
|
@ -90,7 +90,8 @@ class Segmentation(object):
|
||||
self._cancel_segment_request = None
|
||||
return res
|
||||
|
||||
def _got_segment(self, (segment_start,segment,decodetime), wanted_segnum):
|
||||
def _got_segment(self, segment_args, wanted_segnum):
|
||||
(segment_start, segment, decodetime) = segment_args
|
||||
self._cancel_segment_request = None
|
||||
# we got file[segment_start:segment_start+len(segment)]
|
||||
# we want file[self._offset:self._offset+self._size]
|
||||
|
@ -425,12 +425,13 @@ class Encoder(object):
|
||||
d.addCallback(_got)
|
||||
return d
|
||||
|
||||
def _send_segment(self, (shares, shareids), segnum):
|
||||
def _send_segment(self, shares_and_shareids, segnum):
|
||||
# To generate the URI, we must generate the roothash, so we must
|
||||
# generate all shares, even if we aren't actually giving them to
|
||||
# anybody. This means that the set of shares we create will be equal
|
||||
# to or larger than the set of landlords. If we have any landlord who
|
||||
# *doesn't* have a share, that's an error.
|
||||
(shares, shareids) = shares_and_shareids
|
||||
_assert(set(self.landlords.keys()).issubset(set(shareids)),
|
||||
shareids=shareids, landlords=self.landlords)
|
||||
start = time.time()
|
||||
|
@ -146,8 +146,7 @@ def _compute_maximum_graph(graph, shareIndices):
|
||||
# is the amount of unused capacity on that edge. Taking the
|
||||
# minimum of a list of those values for each edge in the
|
||||
# augmenting path gives us our delta.
|
||||
delta = min(map(lambda (u, v), rf=residual_function: rf[u][v],
|
||||
path))
|
||||
delta = min(residual_function[u][v] for (u, v) in path)
|
||||
for (u, v) in path:
|
||||
flow_function[u][v] += delta
|
||||
flow_function[v][u] -= delta
|
||||
|
@ -276,8 +276,9 @@ class ServerTracker(object):
|
||||
rref = self._server.get_rref()
|
||||
return rref.callRemote("get_buckets", self.storage_index)
|
||||
|
||||
def _buckets_allocated(self, (alreadygot, buckets)):
|
||||
def _buckets_allocated(self, alreadygot_and_buckets):
|
||||
#log.msg("%s._got_reply(%s)" % (self, (alreadygot, buckets)))
|
||||
(alreadygot, buckets) = alreadygot_and_buckets
|
||||
b = {}
|
||||
for sharenum, rref in buckets.iteritems():
|
||||
bp = self.wbp_class(rref, self._server, self.sharesize,
|
||||
@ -1536,7 +1537,8 @@ class AssistedUploader:
|
||||
d.addCallback(self._contacted_helper)
|
||||
return d
|
||||
|
||||
def _contacted_helper(self, (helper_upload_results, upload_helper)):
|
||||
def _contacted_helper(self, helper_upload_results_and_upload_helper):
|
||||
(helper_upload_results, upload_helper) = helper_upload_results_and_upload_helper
|
||||
now = time.time()
|
||||
elapsed = now - self._time_contacting_helper_start
|
||||
self._elapsed_time_contacting_helper = elapsed
|
||||
|
@ -119,7 +119,7 @@ class MutableFileNode(object):
|
||||
|
||||
return self
|
||||
|
||||
def create_with_keys(self, (pubkey, privkey), contents,
|
||||
def create_with_keys(self, keypair, contents,
|
||||
version=SDMF_VERSION):
|
||||
"""Call this to create a brand-new mutable file. It will create the
|
||||
shares, find homes for them, and upload the initial contents (created
|
||||
@ -127,6 +127,7 @@ class MutableFileNode(object):
|
||||
Deferred that fires (with the MutableFileNode instance you should
|
||||
use) when it completes.
|
||||
"""
|
||||
(pubkey, privkey) = keypair
|
||||
self._pubkey, self._privkey = pubkey, privkey
|
||||
pubkey_s = self._pubkey.serialize()
|
||||
privkey_s = self._privkey.serialize()
|
||||
@ -338,7 +339,8 @@ class MutableFileNode(object):
|
||||
representing the best recoverable version of the file.
|
||||
"""
|
||||
d = self._get_version_from_servermap(MODE_READ, servermap, version)
|
||||
def _build_version((servermap, their_version)):
|
||||
def _build_version(servermap_and_their_version):
|
||||
(servermap, their_version) = servermap_and_their_version
|
||||
assert their_version in servermap.recoverable_versions()
|
||||
assert their_version in servermap.make_versionmap()
|
||||
|
||||
@ -490,8 +492,9 @@ class MutableFileNode(object):
|
||||
# get_mutable_version => write intent, so we require that the
|
||||
# servermap is updated in MODE_WRITE
|
||||
d = self._get_version_from_servermap(MODE_WRITE, servermap, version)
|
||||
def _build_version((servermap, smap_version)):
|
||||
def _build_version(servermap_and_smap_version):
|
||||
# these should have been set by the servermap update.
|
||||
(servermap, smap_version) = servermap_and_smap_version
|
||||
assert self._secret_holder
|
||||
assert self._writekey
|
||||
|
||||
|
@ -960,7 +960,8 @@ def trial(config):
|
||||
print("'tahoe debug trial' is obsolete. Please run 'tox', or use 'trial' in a virtualenv.", file=config.stderr)
|
||||
return 1
|
||||
|
||||
def fixOptionsClass( (subcmd, shortcut, OptionsClass, desc) ):
|
||||
def fixOptionsClass(args):
|
||||
(subcmd, shortcut, OptionsClass, desc) = args
|
||||
class FixedOptionsClass(OptionsClass):
|
||||
def getSynopsis(self):
|
||||
t = OptionsClass.getSynopsis(self)
|
||||
|
@ -78,7 +78,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
|
||||
d.addCallback(lambda res: do_backup(True))
|
||||
def _check0((rc, out, err)):
|
||||
def _check0(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
(
|
||||
@ -134,7 +135,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
d.addCallback(_check0)
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("ls", "--uri", "tahoe:backups"))
|
||||
def _check1((rc, out, err)):
|
||||
def _check1(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.split("\n")
|
||||
@ -145,25 +147,29 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
self.failUnlessReallyEqual(sorted(childnames), ["Archives", "Latest"])
|
||||
d.addCallback(_check1)
|
||||
d.addCallback(lambda res: self.do_cli("ls", "tahoe:backups/Latest"))
|
||||
def _check2((rc, out, err)):
|
||||
def _check2(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(sorted(out.split()), ["empty", "parent"])
|
||||
d.addCallback(_check2)
|
||||
d.addCallback(lambda res: self.do_cli("ls", "tahoe:backups/Latest/empty"))
|
||||
def _check2a((rc, out, err)):
|
||||
def _check2a(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(out.strip(), "")
|
||||
d.addCallback(_check2a)
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:backups/Latest/parent/subdir/foo.txt"))
|
||||
def _check3((rc, out, err)):
|
||||
def _check3(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(out, "foo")
|
||||
d.addCallback(_check3)
|
||||
d.addCallback(lambda res: self.do_cli("ls", "tahoe:backups/Archives"))
|
||||
def _check4((rc, out, err)):
|
||||
def _check4(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.old_archives = out.split()
|
||||
@ -173,9 +179,10 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(self.stall, 1.1)
|
||||
d.addCallback(lambda res: do_backup())
|
||||
def _check4a((rc, out, err)):
|
||||
def _check4a(args):
|
||||
# second backup should reuse everything, if the backupdb is
|
||||
# available
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
fu, fr, fs, dc, dr, ds = self.count_output(out)
|
||||
@ -203,10 +210,11 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(self.stall, 1.1)
|
||||
d.addCallback(lambda res: do_backup(verbose=True))
|
||||
def _check4b((rc, out, err)):
|
||||
def _check4b(args):
|
||||
# we should check all files, and re-use all of them. None of
|
||||
# the directories should have been changed, so we should
|
||||
# re-use all of them too.
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
fu, fr, fs, dc, dr, ds = self.count_output(out)
|
||||
@ -222,7 +230,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
d.addCallback(_check4b)
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("ls", "tahoe:backups/Archives"))
|
||||
def _check5((rc, out, err)):
|
||||
def _check5(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.new_archives = out.split()
|
||||
@ -246,9 +255,10 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
self.writeto("empty", "imagine nothing being here")
|
||||
return do_backup()
|
||||
d.addCallback(_modify)
|
||||
def _check5a((rc, out, err)):
|
||||
def _check5a(args):
|
||||
# second backup should reuse bar.txt (if backupdb is available),
|
||||
# and upload the rest. None of the directories can be reused.
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
fu, fr, fs, dc, dr, ds = self.count_output(out)
|
||||
@ -263,7 +273,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
self.failUnlessReallyEqual(ds, 0)
|
||||
d.addCallback(_check5a)
|
||||
d.addCallback(lambda res: self.do_cli("ls", "tahoe:backups/Archives"))
|
||||
def _check6((rc, out, err)):
|
||||
def _check6(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.new_archives = out.split()
|
||||
@ -272,14 +283,16 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
self.old_archives[0])
|
||||
d.addCallback(_check6)
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:backups/Latest/parent/subdir/foo.txt"))
|
||||
def _check7((rc, out, err)):
|
||||
def _check7(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(out, "FOOF!")
|
||||
# the old snapshot should not be modified
|
||||
return self.do_cli("get", "tahoe:backups/Archives/%s/parent/subdir/foo.txt" % self.old_archives[0])
|
||||
d.addCallback(_check7)
|
||||
def _check8((rc, out, err)):
|
||||
def _check8(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(out, "foo")
|
||||
@ -418,7 +431,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
d.addCallback(lambda res: self.do_cli("backup", "--verbose", source, "tahoe:test"))
|
||||
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 2)
|
||||
foo2 = os.path.join(source, "foo2.txt")
|
||||
self.failUnlessIn("WARNING: cannot backup symlink ", err)
|
||||
@ -449,7 +463,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
d.addCallback(lambda res: self.do_cli("backup", source, "tahoe:test"))
|
||||
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 2)
|
||||
self.failUnlessReallyEqual(err, "WARNING: permission denied on file %s\n" % os.path.join(source, "foo.txt"))
|
||||
|
||||
@ -484,7 +499,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
d.addCallback(lambda res: self.do_cli("backup", source, "tahoe:test"))
|
||||
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 2)
|
||||
self.failUnlessReallyEqual(err, "WARNING: permission denied on directory %s\n" % os.path.join(source, "test"))
|
||||
|
||||
@ -513,7 +529,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
self.set_up_grid(oneshare=True)
|
||||
source = os.path.join(self.basedir, "file1")
|
||||
d = self.do_cli('backup', source, source)
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -527,7 +544,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||
self.set_up_grid(oneshare=True)
|
||||
source = os.path.join(self.basedir, "file1")
|
||||
d = self.do_cli("backup", source, "nonexistent:" + source)
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessIn("nonexistent", err)
|
||||
|
@ -28,7 +28,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_stash_uri)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", self.uri))
|
||||
def _check1((rc, out, err)):
|
||||
def _check1(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -37,7 +38,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check1)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", "--raw", self.uri))
|
||||
def _check2((rc, out, err)):
|
||||
def _check2(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
data = json.loads(out)
|
||||
@ -51,7 +53,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_stash_lit_uri)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", self.lit_uri))
|
||||
def _check_lit((rc, out, err)):
|
||||
def _check_lit(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -59,7 +62,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check_lit)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", "--raw", self.lit_uri))
|
||||
def _check_lit_raw((rc, out, err)):
|
||||
def _check_lit_raw(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
data = json.loads(out)
|
||||
@ -94,7 +98,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_clobber_shares)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", "--verify", self.uri))
|
||||
def _check3((rc, out, err)):
|
||||
def _check3(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -107,7 +112,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check3)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", "--verify", "--raw", self.uri))
|
||||
def _check3_raw((rc, out, err)):
|
||||
def _check3_raw(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
data = json.loads(out)
|
||||
@ -120,7 +126,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("check", "--verify", "--repair", self.uri))
|
||||
def _check4((rc, out, err)):
|
||||
def _check4(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -133,7 +140,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("check", "--verify", "--repair", self.uri))
|
||||
def _check5((rc, out, err)):
|
||||
def _check5(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -174,7 +182,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_stash_uri, "mutable")
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("deep-check", self.rooturi))
|
||||
def _check1((rc, out, err)):
|
||||
def _check1(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -189,7 +198,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("deep-check", "--verbose",
|
||||
self.rooturi))
|
||||
def _check2((rc, out, err)):
|
||||
def _check2(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -202,7 +212,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check2)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("stats", self.rooturi))
|
||||
def _check_stats((rc, out, err)):
|
||||
def _check_stats(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -240,7 +251,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("deep-check", "--verbose", self.rooturi))
|
||||
def _check3((rc, out, err)):
|
||||
def _check3(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -256,7 +268,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("deep-check", "--verbose", "--verify",
|
||||
self.rooturi))
|
||||
def _check4((rc, out, err)):
|
||||
def _check4(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -274,7 +287,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("deep-check", "--raw",
|
||||
self.rooturi))
|
||||
def _check5((rc, out, err)):
|
||||
def _check5(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -287,7 +301,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.do_cli("deep-check",
|
||||
"--verbose", "--verify", "--repair",
|
||||
self.rooturi))
|
||||
def _check6((rc, out, err)):
|
||||
def _check6(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -322,7 +337,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# root/subfile
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("manifest", self.rooturi))
|
||||
def _manifest_failed((rc, out, err)):
|
||||
def _manifest_failed(args):
|
||||
(rc, out, err) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnlessIn("ERROR: UnrecoverableFileError", err)
|
||||
# the fatal directory should still show up, as the last line
|
||||
@ -330,7 +346,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_manifest_failed)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("deep-check", self.rooturi))
|
||||
def _deep_check_failed((rc, out, err)):
|
||||
def _deep_check_failed(args):
|
||||
(rc, out, err) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnlessIn("ERROR: UnrecoverableFileError", err)
|
||||
# we want to make sure that the error indication is the last
|
||||
@ -360,7 +377,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Check/check_without_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("check")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -375,7 +393,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Check/check_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("check", "nonexistent:")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessIn("nonexistent", err)
|
||||
@ -396,7 +415,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_stash_uri)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", self.uriList[0], self.uriList[1]))
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
#Ensure healthy appears for each uri
|
||||
@ -405,7 +425,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check)
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("check", self.uriList[0], "nonexistent:"))
|
||||
def _check2((rc, out, err)):
|
||||
def _check2(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("Healthy", out)
|
||||
self.failUnlessIn("error:", err)
|
||||
|
@ -685,7 +685,8 @@ class Ln(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Ln/ln_without_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("ln", "from", "to")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -705,7 +706,8 @@ class Ln(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Ln/ln_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("ln", "havasu:from", "havasu:to")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
d.addCallback(_check)
|
||||
@ -723,7 +725,8 @@ class Ln(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
class Admin(unittest.TestCase):
|
||||
def test_generate_keypair(self):
|
||||
d = run_cli("admin", "generate-keypair")
|
||||
def _done( (rc, stdout, stderr) ):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
lines = [line.strip() for line in stdout.splitlines()]
|
||||
privkey_bits = lines[0].split()
|
||||
pubkey_bits = lines[1].split()
|
||||
@ -743,7 +746,8 @@ class Admin(unittest.TestCase):
|
||||
def test_derive_pubkey(self):
|
||||
priv1,pub1 = keyutil.make_keypair()
|
||||
d = run_cli("admin", "derive-pubkey", priv1)
|
||||
def _done( (rc, stdout, stderr) ):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
lines = stdout.split("\n")
|
||||
privkey_line = lines[0].strip()
|
||||
pubkey_line = lines[1].strip()
|
||||
@ -777,7 +781,8 @@ class Errors(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
in_pending_msg_regex = "ran out of shares: complete= pending=Share\(.+\) overdue= unused= need 3"
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("get", self.uri_1share))
|
||||
def _check1((rc, out, err)):
|
||||
def _check1(args):
|
||||
(rc, out, err) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnless("410 Gone" in err, err)
|
||||
self.failUnlessIn("NotEnoughSharesError: ", err)
|
||||
@ -786,7 +791,8 @@ class Errors(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
targetf = os.path.join(self.basedir, "output")
|
||||
d.addCallback(lambda ign: self.do_cli("get", self.uri_1share, targetf))
|
||||
def _check2((rc, out, err)):
|
||||
def _check2(args):
|
||||
(rc, out, err) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnless("410 Gone" in err, err)
|
||||
self.failUnlessIn("NotEnoughSharesError: ", err)
|
||||
@ -809,7 +815,8 @@ class Errors(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
"endheaders", _socket_error)
|
||||
|
||||
d = self.do_cli("mkdir")
|
||||
def _check_invalid((rc,stdout,stderr)):
|
||||
def _check_invalid(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnlessIn("Error trying to connect to http://127.0.0.1", stderr)
|
||||
d.addCallback(_check_invalid)
|
||||
@ -824,7 +831,8 @@ class Get(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Get/get_without_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli('get', 'file')
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -837,7 +845,8 @@ class Get(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Get/get_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("get", "nonexistent:file")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessIn("nonexistent", err)
|
||||
@ -854,7 +863,8 @@ class Manifest(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Manifest/manifest_without_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("manifest")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -867,7 +877,8 @@ class Manifest(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Manifest/manifest_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("manifest", "nonexistent:")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessIn("nonexistent", err)
|
||||
@ -883,7 +894,8 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
d.addCallback(lambda res: self.do_cli("mkdir", "test"))
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessIn("URI:", out)
|
||||
@ -895,7 +907,8 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = os.path.dirname(self.mktemp())
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
def _check((rc, out, err), st):
|
||||
def _check(args, st):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessIn(st, out)
|
||||
@ -924,7 +937,8 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = os.path.dirname(self.mktemp())
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("mkdir", "--format=SDMF")
|
||||
def _check((rc, out, err), st):
|
||||
def _check(args, st):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessIn(st, out)
|
||||
@ -967,7 +981,8 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
d.addCallback(lambda res: self.do_cli("mkdir", motorhead_arg))
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessIn("URI:", out)
|
||||
@ -981,7 +996,8 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Mkdir/mkdir_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("mkdir", "havasu:")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -1004,7 +1020,8 @@ class Unlink(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Unlink/%s_without_alias" % (self.command,)
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli(self.command, "afile")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -1020,7 +1037,8 @@ class Unlink(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Unlink/%s_with_nonexistent_alias" % (self.command,)
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli(self.command, "nonexistent:afile")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessIn("nonexistent", err)
|
||||
@ -1038,13 +1056,15 @@ class Unlink(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self._create_test_file()
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
d.addCallback(lambda ign: self.do_cli("put", self.datafile, "tahoe:test"))
|
||||
def _do_unlink((rc, out, err)):
|
||||
def _do_unlink(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnless(out.startswith("URI:"), out)
|
||||
return self.do_cli(self.command, out.strip('\n'))
|
||||
d.addCallback(_do_unlink)
|
||||
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("'tahoe %s'" % (self.command,), err)
|
||||
self.failUnlessIn("path must be given", err)
|
||||
@ -1072,7 +1092,8 @@ class Stats(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
# make sure we can get stats on an empty directory too
|
||||
d.addCallback(lambda ign: self.do_cli("stats", self.rooturi))
|
||||
def _check_stats((rc, out, err)):
|
||||
def _check_stats(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
lines = out.splitlines()
|
||||
@ -1093,7 +1114,8 @@ class Stats(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Stats/stats_without_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("stats")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -1106,7 +1128,8 @@ class Stats(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Stats/stats_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("stats", "havasu:")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -1122,7 +1145,8 @@ class Webopen(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Webopen/webopen_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("webopen", "fake:")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -1146,14 +1170,16 @@ class Webopen(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Webopen/webopen"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("create-alias", "alias:")
|
||||
def _check_alias((rc, out, err)):
|
||||
def _check_alias(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0, repr((rc, out, err)))
|
||||
self.failUnlessIn("Alias 'alias' created", out)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.alias_uri = get_aliases(self.get_clientdir())["alias"]
|
||||
d.addCallback(_check_alias)
|
||||
d.addCallback(lambda res: self.do_cli("webopen", "alias:"))
|
||||
def _check_webopen((rc, out, err)):
|
||||
def _check_webopen(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0, repr((rc, out, err)))
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
|
@ -49,15 +49,16 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda res: self.do_cli("cp", fn1_arg, "tahoe:"))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:" + artonwall_arg))
|
||||
d.addCallback(lambda (rc,out,err): self.failUnlessReallyEqual(out, DATA1))
|
||||
d.addCallback(lambda rc_out_err: self.failUnlessReallyEqual(rc_out_err[1], DATA1))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("cp", fn2, "tahoe:"))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:Metallica"))
|
||||
d.addCallback(lambda (rc,out,err): self.failUnlessReallyEqual(out, DATA2))
|
||||
d.addCallback(lambda rc_out_err: self.failUnlessReallyEqual(rc_out_err[1], DATA2))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("ls", "tahoe:"))
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
try:
|
||||
unicode_to_output(u"\u00C4rtonwall")
|
||||
except UnicodeEncodeError:
|
||||
@ -104,7 +105,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
d.addCallback(lambda ign: self.do_cli("put", fn1))
|
||||
def _put_file((rc, out, err)):
|
||||
def _put_file(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessIn("200 OK", err)
|
||||
# keep track of the filecap
|
||||
@ -113,7 +115,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
# Let's try copying this to the disk using the filecap.
|
||||
d.addCallback(lambda ign: self.do_cli("cp", self.filecap, fn2))
|
||||
def _copy_file((rc, out, err)):
|
||||
def _copy_file(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
results = fileutil.read(fn2)
|
||||
self.failUnlessReallyEqual(results, DATA1)
|
||||
@ -122,7 +125,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# Test copying a filecap to local dir, which should fail without a
|
||||
# destination filename (#761).
|
||||
d.addCallback(lambda ign: self.do_cli("cp", self.filecap, outdir))
|
||||
def _resp((rc, out, err)):
|
||||
def _resp(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("when copying into a directory, all source files must have names, but",
|
||||
err)
|
||||
@ -131,7 +135,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
# Create a directory, linked at tahoe:test .
|
||||
d.addCallback(lambda ign: self.do_cli("mkdir", "tahoe:test"))
|
||||
def _get_dir((rc, out, err)):
|
||||
def _get_dir(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.dircap = out.strip()
|
||||
d.addCallback(_get_dir)
|
||||
@ -139,13 +144,14 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# Upload a file to the directory.
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("put", fn1, "tahoe:test/test_file"))
|
||||
d.addCallback(lambda (rc, out, err): self.failUnlessReallyEqual(rc, 0))
|
||||
d.addCallback(lambda rc_out_err: self.failUnlessReallyEqual(rc_out_err[0], 0))
|
||||
|
||||
# Copying DIRCAP/filename to a local dir should work, because the
|
||||
# destination filename can be inferred.
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("cp", self.dircap + "/test_file", outdir))
|
||||
def _get_resp((rc, out, err)):
|
||||
def _get_resp(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
results = fileutil.read(os.path.join(outdir, "test_file"))
|
||||
self.failUnlessReallyEqual(results, DATA1)
|
||||
@ -154,7 +160,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# ... and to an explicit filename different from the source filename.
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("cp", self.dircap + "/test_file", fn3))
|
||||
def _get_resp2((rc, out, err)):
|
||||
def _get_resp2(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
results = fileutil.read(fn3)
|
||||
self.failUnlessReallyEqual(results, DATA1)
|
||||
@ -163,7 +170,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# Test that the --verbose option prints correct indices (#1805).
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("cp", "--verbose", fn3, self.dircap))
|
||||
def _test_for_wrong_indices((rc, out, err)):
|
||||
def _test_for_wrong_indices(args):
|
||||
(rc, out, err) = args
|
||||
lines = err.split('\n')
|
||||
self.failUnlessIn('examining 1 of 1', lines)
|
||||
self.failUnlessIn('starting copy, 1 files, 1 directories', lines)
|
||||
@ -177,7 +185,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Cp/cp_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("cp", "fake:file1", "fake:file2")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
d.addCallback(_check)
|
||||
@ -209,7 +218,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda res: self.do_cli("mkdir", "tahoe:test/" + artonwall_arg))
|
||||
d.addCallback(lambda res: self.do_cli("cp", "-r", "tahoe:test", "tahoe:test2"))
|
||||
d.addCallback(lambda res: self.do_cli("ls", "tahoe:test2/test"))
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
try:
|
||||
unicode_to_output(u"\u00C4rtonwall")
|
||||
except UnicodeEncodeError:
|
||||
@ -245,7 +255,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.do_cli("put", "--mutable", test_txt_path, "tahoe:test/test.txt"))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test/test.txt"))
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(out, test_txt_contents)
|
||||
d.addCallback(_check)
|
||||
@ -254,7 +265,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# file we've just uploaded.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:test/test.txt"))
|
||||
def _get_test_txt_uris((rc, out, err)):
|
||||
def _get_test_txt_uris(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
filetype, data = json.loads(out)
|
||||
|
||||
@ -281,13 +293,14 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# If we get test.txt now, we should see the new data.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test/test.txt"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, new_txt_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], new_txt_contents))
|
||||
# If we get the json of the new file, we should see that the old
|
||||
# uri is there
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:test/test.txt"))
|
||||
def _check_json((rc, out, err)):
|
||||
def _check_json(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
filetype, data = json.loads(out)
|
||||
|
||||
@ -304,8 +317,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# should give us the new contents.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", self.rw_uri))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, new_txt_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], new_txt_contents))
|
||||
# Now copy the old test.txt without an explicit destination
|
||||
# file. tahoe cp will match it to the existing file and
|
||||
# overwrite it appropriately.
|
||||
@ -313,15 +326,15 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.do_cli("cp", test_txt_path, "tahoe:test"))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test/test.txt"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, test_txt_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], test_txt_contents))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:test/test.txt"))
|
||||
d.addCallback(_check_json)
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", self.rw_uri))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, test_txt_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], test_txt_contents))
|
||||
|
||||
# Now we'll make a more complicated directory structure.
|
||||
# test2/
|
||||
@ -346,7 +359,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.do_cli("put", imm_test_txt_path, "tahoe:test2/imm2"))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:test2"))
|
||||
def _process_directory_json((rc, out, err)):
|
||||
def _process_directory_json(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
|
||||
filetype, data = json.loads(out)
|
||||
@ -389,7 +403,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
# We expect that mutable1 and mutable2 are overwritten in-place,
|
||||
# so they'll retain their URIs but have different content.
|
||||
def _process_file_json((rc, out, err), fn):
|
||||
def _process_file_json(args, fn):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
filetype, data = json.loads(out)
|
||||
self.failUnlessEqual(filetype, "filenode")
|
||||
@ -406,8 +421,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
for fn in ("mutable1", "mutable2"):
|
||||
d.addCallback(lambda ignored, fn=fn:
|
||||
self.do_cli("get", "tahoe:test2/%s" % fn))
|
||||
d.addCallback(lambda (rc, out, err), fn=fn:
|
||||
self.failUnlessEqual(out, fn * 1000))
|
||||
d.addCallback(lambda rc_out_err, fn=fn:
|
||||
self.failUnlessEqual(rc_out_err[1], fn * 1000))
|
||||
d.addCallback(lambda ignored, fn=fn:
|
||||
self.do_cli("ls", "--json", "tahoe:test2/%s" % fn))
|
||||
d.addCallback(_process_file_json, fn=fn)
|
||||
@ -416,8 +431,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# should be different.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test2/imm1"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, "imm1" * 1000))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], "imm1" * 1000))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:test2/imm1"))
|
||||
d.addCallback(_process_file_json, fn="imm1")
|
||||
@ -425,18 +440,19 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# imm3 should have been created.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test2/imm3"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, "imm3" * 1000))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], "imm3" * 1000))
|
||||
|
||||
# imm2 should be exactly as we left it, since our newly-copied
|
||||
# directory didn't contain an imm2 entry.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test2/imm2"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, imm_test_txt_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], imm_test_txt_contents))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:test2/imm2"))
|
||||
def _process_imm2_json((rc, out, err)):
|
||||
def _process_imm2_json(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
filetype, data = json.loads(out)
|
||||
self.failUnlessEqual(filetype, "filenode")
|
||||
@ -467,14 +483,16 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d = self.do_cli("create-alias", "tahoe:")
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("put", "--mutable", test_file_path))
|
||||
def _get_test_uri((rc, out, err)):
|
||||
def _get_test_uri(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
# this should be a write uri
|
||||
self._test_write_uri = out
|
||||
d.addCallback(_get_test_uri)
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", self._test_write_uri))
|
||||
def _process_test_json((rc, out, err)):
|
||||
def _process_test_json(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
filetype, data = json.loads(out)
|
||||
|
||||
@ -486,12 +504,13 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# Now we'll link the readonly URI into the tahoe: alias.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ln", self._test_read_uri, "tahoe:test_file.txt"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(rc, 0))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[0], 0))
|
||||
# Let's grab the json of that to make sure that we did it right.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:"))
|
||||
def _process_tahoe_json((rc, out, err)):
|
||||
def _process_tahoe_json(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
|
||||
filetype, data = json.loads(out)
|
||||
@ -511,40 +530,41 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# place of that one. We should get an error.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("cp", replacement_file_path, "tahoe:test_file.txt"))
|
||||
def _check_error_message((rc, out, err)):
|
||||
def _check_error_message(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 1)
|
||||
self.failUnlessIn("replace or update requested with read-only cap", err)
|
||||
d.addCallback(_check_error_message)
|
||||
# Make extra sure that that didn't work.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test_file.txt"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, test_file_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], test_file_contents))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", self._test_read_uri))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, test_file_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], test_file_contents))
|
||||
# Now we'll do it without an explicit destination.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("cp", test_file_path, "tahoe:"))
|
||||
d.addCallback(_check_error_message)
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", "tahoe:test_file.txt"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, test_file_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], test_file_contents))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", self._test_read_uri))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(out, test_file_contents))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[1], test_file_contents))
|
||||
# Now we'll link a readonly file into a subdirectory.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("mkdir", "tahoe:testdir"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(rc, 0))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[0], 0))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ln", self._test_read_uri, "tahoe:test/file2.txt"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessEqual(rc, 0))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessEqual(rc_out_err[0], 0))
|
||||
|
||||
test_dir_path = os.path.join(self.basedir, "test")
|
||||
fileutil.make_dirs(test_dir_path)
|
||||
@ -556,7 +576,8 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check_error_message)
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", "tahoe:test"))
|
||||
def _got_testdir_json((rc, out, err)):
|
||||
def _got_testdir_json(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
|
||||
filetype, data = json.loads(out)
|
||||
|
@ -32,7 +32,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
aliasfile = os.path.join(self.get_clientdir(), "private", "aliases")
|
||||
|
||||
d = self.do_cli("create-alias", "tahoe")
|
||||
def _done((rc,stdout,stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.assertEqual(stderr, "")
|
||||
self.assertIn("Alias 'tahoe' created", stdout)
|
||||
aliases = get_aliases(self.get_clientdir())
|
||||
@ -54,7 +55,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_stash_urls)
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("create-alias", "two")) # dup
|
||||
def _check_create_duplicate((rc,stdout,stderr)):
|
||||
def _check_create_duplicate(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnless("Alias 'two' already exists!" in stderr)
|
||||
aliases = get_aliases(self.get_clientdir())
|
||||
@ -62,14 +64,16 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check_create_duplicate)
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("add-alias", "added", self.two_uri))
|
||||
def _check_add((rc,stdout,stderr)):
|
||||
def _check_add(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnless("Alias 'added' added" in stdout)
|
||||
d.addCallback(_check_add)
|
||||
|
||||
# check add-alias with a duplicate
|
||||
d.addCallback(lambda res: self.do_cli("add-alias", "two", self.two_uri))
|
||||
def _check_add_duplicate((rc,stdout,stderr)):
|
||||
def _check_add_duplicate(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnless("Alias 'two' already exists!" in stderr)
|
||||
aliases = get_aliases(self.get_clientdir())
|
||||
@ -77,7 +81,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check_add_duplicate)
|
||||
|
||||
# check create-alias and add-alias with invalid aliases
|
||||
def _check_invalid((rc,stdout,stderr)):
|
||||
def _check_invalid(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnlessIn("cannot contain", stderr)
|
||||
|
||||
@ -116,7 +121,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
fileutil.write(aliasfile, old.rstrip())
|
||||
return self.do_cli("create-alias", "un-corrupted1")
|
||||
d.addCallback(_remove_trailing_newline_and_create_alias)
|
||||
def _check_not_corrupted1((rc,stdout,stderr)):
|
||||
def _check_not_corrupted1(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnless("Alias 'un-corrupted1' created" in stdout, stdout)
|
||||
self.failIf(stderr)
|
||||
# the old behavior was to simply append the new record, causing a
|
||||
@ -139,7 +145,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
fileutil.write(aliasfile, old.rstrip())
|
||||
return self.do_cli("add-alias", "un-corrupted2", self.two_uri)
|
||||
d.addCallback(_remove_trailing_newline_and_add_alias)
|
||||
def _check_not_corrupted((rc,stdout,stderr)):
|
||||
def _check_not_corrupted(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnless("Alias 'un-corrupted2' added" in stdout, stdout)
|
||||
self.failIf(stderr)
|
||||
aliases = get_aliases(self.get_clientdir())
|
||||
@ -162,7 +169,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.")
|
||||
|
||||
d = self.do_cli("create-alias", etudes_arg)
|
||||
def _check_create_unicode((rc, out, err)):
|
||||
def _check_create_unicode(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessIn("Alias %s created" % quote_output(u"\u00E9tudes"), out)
|
||||
@ -172,7 +180,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check_create_unicode)
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("ls", etudes_arg + ":"))
|
||||
def _check_ls1((rc, out, err)):
|
||||
def _check_ls1(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -182,14 +191,16 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
stdin="Blah blah blah"))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("ls", etudes_arg + ":"))
|
||||
def _check_ls2((rc, out, err)):
|
||||
def _check_ls2(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(out, "uploaded.txt\n")
|
||||
d.addCallback(_check_ls2)
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("get", etudes_arg + ":uploaded.txt"))
|
||||
def _check_get((rc, out, err)):
|
||||
def _check_get(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(out, "Blah blah blah")
|
||||
@ -201,7 +212,8 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("get",
|
||||
get_aliases(self.get_clientdir())[u"\u00E9tudes"] + "/" + lumiere_arg))
|
||||
def _check_get2((rc, out, err)):
|
||||
def _check_get2(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(out, "Let the sunshine In!")
|
||||
|
@ -47,7 +47,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda ign:
|
||||
self.do_cli("add-alias", "tahoe", self.rooturi))
|
||||
d.addCallback(lambda ign: self.do_cli("ls"))
|
||||
def _check1((rc,out,err)):
|
||||
def _check1(args):
|
||||
(rc, out, err) = args
|
||||
if good_out is None:
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("files whose names could not be converted", err)
|
||||
@ -59,13 +60,15 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessReallyEqual(sorted(out.splitlines()), sorted(["0share", "1share", good_out]))
|
||||
d.addCallback(_check1)
|
||||
d.addCallback(lambda ign: self.do_cli("ls", "missing"))
|
||||
def _check2((rc,out,err)):
|
||||
def _check2(args):
|
||||
(rc, out, err) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err.strip(), "No such file or directory")
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
d.addCallback(_check2)
|
||||
d.addCallback(lambda ign: self.do_cli("ls", "1share"))
|
||||
def _check3((rc,out,err)):
|
||||
def _check3(args):
|
||||
(rc, out, err) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnlessIn("Error during GET: 410 Gone", err)
|
||||
self.failUnlessIn("UnrecoverableFileError:", err)
|
||||
@ -75,7 +78,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check3)
|
||||
d.addCallback(lambda ign: self.do_cli("ls", "0share"))
|
||||
d.addCallback(_check3)
|
||||
def _check4((rc, out, err)):
|
||||
def _check4(args):
|
||||
(rc, out, err) = args
|
||||
if good_out is None:
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("files whose names could not be converted", err)
|
||||
@ -99,9 +103,10 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda ign: self.do_cli("ls", "-l", self.rooturi + ":./" + good_arg))
|
||||
d.addCallback(_check4)
|
||||
|
||||
def _check5((rc, out, err)):
|
||||
def _check5(args):
|
||||
# listing a raw filecap should not explode, but it will have no
|
||||
# metadata, just the size
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual("-r-- %d -" % len(small), out.strip())
|
||||
d.addCallback(lambda ign: self.do_cli("ls", "-l", self.goodcap))
|
||||
@ -112,14 +117,16 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda ign: self.rootnode.move_child_to(u"g\u00F6\u00F6d", self.rootnode, u"good"))
|
||||
|
||||
d.addCallback(lambda ign: self.do_cli("ls"))
|
||||
def _check1_ascii((rc,out,err)):
|
||||
def _check1_ascii(args):
|
||||
(rc,out,err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessReallyEqual(err, "")
|
||||
self.failUnlessReallyEqual(sorted(out.splitlines()), sorted(["0share", "1share", "good"]))
|
||||
d.addCallback(_check1_ascii)
|
||||
def _check4_ascii((rc, out, err)):
|
||||
def _check4_ascii(args):
|
||||
# listing a file (as dir/filename) should have the edge metadata,
|
||||
# including the filename
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessIn("good", out)
|
||||
self.failIfIn("-r-- %d -" % len(small), out,
|
||||
@ -141,19 +148,21 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
return self.rootnode.create_subdirectory(u"unknown", initial_children=kids,
|
||||
mutable=False)
|
||||
d.addCallback(_create_unknown)
|
||||
def _check6((rc, out, err)):
|
||||
def _check6(args):
|
||||
# listing a directory referencing an unknown object should print
|
||||
# an extra message to stderr
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessIn("?r-- ? - unknownchild-imm\n", out)
|
||||
self.failUnlessIn("included unknown objects", err)
|
||||
d.addCallback(lambda ign: self.do_cli("ls", "-l", "unknown"))
|
||||
d.addCallback(_check6)
|
||||
def _check7((rc, out, err)):
|
||||
def _check7(args):
|
||||
# listing an unknown cap directly should print an extra message
|
||||
# to stderr (currently this only works if the URI starts with 'URI:'
|
||||
# after any 'ro.' or 'imm.' prefix, otherwise it will be confused
|
||||
# with an alias).
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 0)
|
||||
self.failUnlessIn("?r-- ? -\n", out)
|
||||
self.failUnlessIn("included unknown objects", err)
|
||||
@ -167,7 +176,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/List/list_without_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("ls")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -180,7 +190,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/List/list_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("ls", "nonexistent:")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessIn("nonexistent", err)
|
||||
@ -231,7 +242,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d3 = n.add_file(u"immutable", immutable_data)
|
||||
ds = [d1, d2, d3]
|
||||
dl = defer.DeferredList(ds)
|
||||
def _made_files((r1, r2, r3)):
|
||||
def _made_files(args):
|
||||
(r1, r2, r3) = args
|
||||
self.failUnless(r1[0])
|
||||
self.failUnless(r2[0])
|
||||
self.failUnless(r3[0])
|
||||
@ -263,7 +275,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d = self._create_directory_structure()
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", self._dircap))
|
||||
def _got_ls((rc, out, err)):
|
||||
def _got_ls(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessIn("immutable", out)
|
||||
@ -280,7 +293,8 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d = self._create_directory_structure()
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("ls", "--json", self._dircap))
|
||||
def _got_json((rc, out, err)):
|
||||
def _got_json(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessIn(self._mdmf_uri, out)
|
||||
|
@ -49,7 +49,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
client_num=client_num,
|
||||
)
|
||||
)
|
||||
def _done((rc,stdout,stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0, stdout + stderr)
|
||||
self.assertIn("Alias 'magic' created", stdout)
|
||||
# self.failUnlessIn("joined new magic-folder", stdout)
|
||||
@ -78,7 +79,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
client_num=client_num,
|
||||
)
|
||||
)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
return (rc, stdout, stderr)
|
||||
d.addCallback(_done)
|
||||
@ -89,7 +91,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
if json:
|
||||
args = args + ("--json",)
|
||||
d = self.do_cli(*args, client_num=client_num)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
return (rc, stdout, stderr)
|
||||
d.addCallback(_done)
|
||||
return d
|
||||
@ -99,7 +102,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
if name is not None:
|
||||
args = args + ("--name", name)
|
||||
d = self.do_cli(*args, client_num=client_num)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
return (rc, stdout, stderr)
|
||||
d.addCallback(_done)
|
||||
return d
|
||||
@ -124,7 +128,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
client_num=client_num,
|
||||
)
|
||||
)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(stdout, "")
|
||||
self.failUnlessEqual(stderr, "")
|
||||
@ -134,7 +139,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
|
||||
def do_leave(self, client_num):
|
||||
d = self.do_cli("magic-folder", "leave", client_num=client_num)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
return (rc, stdout, stderr)
|
||||
d.addCallback(_done)
|
||||
@ -154,11 +160,13 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
client_num=client_num,
|
||||
)
|
||||
)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
return (rc, stdout, stderr)
|
||||
d.addCallback(_done)
|
||||
def test_joined_magic_folder((rc,stdout,stderr)):
|
||||
def test_joined_magic_folder(args):
|
||||
(rc, stdout, stderr) = args
|
||||
readonly_cap = unicode(uri.from_string(upload_dircap).get_readonly().to_string(), 'utf-8')
|
||||
s = re.search(readonly_cap, stdout)
|
||||
self.failUnless(s is not None)
|
||||
@ -186,7 +194,8 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin, NonASCIIPathMixin):
|
||||
local_dir_arg = unicode_to_argv(local_dir)
|
||||
# the --debug means we get real exceptions on failures
|
||||
d = self.do_cli("magic-folder", "--debug", "create", "magic:", nickname_arg, local_dir_arg)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0, stdout + stderr)
|
||||
|
||||
client = self.get_client()
|
||||
@ -487,7 +496,8 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||
|
||||
d = self.do_create_magic_folder(0)
|
||||
d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname))
|
||||
def get_invite_code_and_join((rc, stdout, stderr)):
|
||||
def get_invite_code_and_join(args):
|
||||
(rc, stdout, stderr) = args
|
||||
invite_code = stdout.strip()
|
||||
return self.do_join(0, unicode(local_dir), invite_code)
|
||||
d.addCallback(get_invite_code_and_join)
|
||||
@ -503,7 +513,8 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||
self.set_up_grid(oneshare=True)
|
||||
|
||||
d = self.do_cli("magic-folder", "create", "m a g i c:", client_num=0)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failIfEqual(rc, 0)
|
||||
self.failUnlessIn("Alias names cannot contain spaces.", stderr)
|
||||
d.addCallback(_done)
|
||||
@ -604,7 +615,8 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||
abs_local_dir_u = abspath_expanduser_unicode(unicode(local_dir), long_path=False)
|
||||
|
||||
d = self.do_cli("magic-folder", "create", "magic:", "Alice", local_dir)
|
||||
def _done((rc, stdout, stderr)):
|
||||
def _done(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.collective_dircap, self.upload_dircap = self.get_caps_from_files(0)
|
||||
d.addCallback(_done)
|
||||
@ -657,7 +669,8 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||
|
||||
d = self.do_create_magic_folder(0)
|
||||
d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname))
|
||||
def get_invite_code_and_join((rc, stdout, stderr)):
|
||||
def get_invite_code_and_join(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.invite_code = stdout.strip()
|
||||
return self.do_join(0, unicode(local_dir), self.invite_code)
|
||||
d.addCallback(get_invite_code_and_join)
|
||||
@ -687,7 +700,8 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||
self.invite_code = None
|
||||
d = self.do_create_magic_folder(0)
|
||||
d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname))
|
||||
def get_invite_code_and_join((rc, stdout, stderr)):
|
||||
def get_invite_code_and_join(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.invite_code = stdout.strip()
|
||||
return self.do_join(0, unicode(local_dir), self.invite_code)
|
||||
@ -719,7 +733,8 @@ class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):
|
||||
self.invite_code = None
|
||||
d = self.do_create_magic_folder(0)
|
||||
d.addCallback(lambda ign: self.do_invite(0, self.alice_nickname))
|
||||
def get_invite_code_and_join((rc, stdout, stderr)):
|
||||
def get_invite_code_and_join(args):
|
||||
(rc, stdout, stderr) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.invite_code = stdout.strip()
|
||||
return self.do_join(0, unicode(local_dir), self.invite_code)
|
||||
|
@ -28,16 +28,16 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# (we should be able to rename files)
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mv", "tahoe:file1", "tahoe:file3"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessIn("OK", out, "mv didn't rename a file"))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessIn("OK", rc_out_err[1], "mv didn't rename a file"))
|
||||
|
||||
# do mv file3 file2
|
||||
# (This should succeed without issue)
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mv", "tahoe:file3", "tahoe:file2"))
|
||||
# Out should contain "OK" to show that the transfer worked.
|
||||
d.addCallback(lambda (rc,out,err):
|
||||
self.failUnlessIn("OK", out, "mv didn't output OK after mving"))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessIn("OK", rc_out_err[1], "mv didn't output OK after mving"))
|
||||
|
||||
# Next, make a remote directory.
|
||||
d.addCallback(lambda res:
|
||||
@ -48,9 +48,9 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# client should support this)
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mv", "tahoe:file2", "tahoe:directory"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessIn(
|
||||
"Error: You can't overwrite a directory with a file", err,
|
||||
"Error: You can't overwrite a directory with a file", rc_out_err[2],
|
||||
"mv shouldn't overwrite directories" ))
|
||||
|
||||
# mv file2 directory/
|
||||
@ -58,20 +58,20 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mv", "tahoe:file2", "tahoe:directory/"))
|
||||
# We should see an "OK"...
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessIn("OK", out,
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessIn("OK", rc_out_err[1],
|
||||
"mv didn't mv a file into a directory"))
|
||||
# ... and be able to GET the file
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:directory/file2", self.basedir + "new"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnless(os.path.exists(self.basedir + "new"),
|
||||
"mv didn't write the destination file"))
|
||||
# ... and not find the file where it was before.
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:file2", "file2"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessIn("404", err,
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessIn("404", rc_out_err[2],
|
||||
"mv left the source file intact"))
|
||||
|
||||
# Let's build:
|
||||
@ -92,13 +92,13 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# We should have just some_file in tahoe:directory3
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:directory3/some_file", "some_file"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnless("404" not in err,
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnless("404" not in rc_out_err[2],
|
||||
"mv didn't handle nested directories correctly"))
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:directory3/directory", "directory"))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessIn("404", err,
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessIn("404", rc_out_err[2],
|
||||
"mv moved the wrong thing"))
|
||||
return d
|
||||
|
||||
@ -131,7 +131,8 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# do mv file1 file2
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("mv", "tahoe:file1", "tahoe:file2"))
|
||||
def _check( (rc, out, err) ):
|
||||
def _check(args ):
|
||||
(rc, out, err) = args
|
||||
self.failIfIn("OK", out, "mv printed 'OK' even though the DELETE failed")
|
||||
self.failUnlessEqual(rc, 2)
|
||||
d.addCallback(_check)
|
||||
@ -149,7 +150,8 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Mv/mv_without_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("mv", "afile", "anotherfile")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -175,7 +177,8 @@ class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Mv/mv_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("mv", "fake:afile", "fake:anotherfile")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessIn("fake", err)
|
||||
|
@ -36,8 +36,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessReallyEqual(out, DATA)
|
||||
d.addCallback(_downloaded)
|
||||
d.addCallback(lambda res: self.do_cli("put", "-", stdin=DATA))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessReallyEqual(out, self.readcap))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessReallyEqual(rc_out_err[1], self.readcap))
|
||||
return d
|
||||
|
||||
def test_unlinked_immutable_from_file(self):
|
||||
@ -53,17 +53,18 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# we make the file small enough to fit in a LIT file, for speed
|
||||
fileutil.write(rel_fn, "short file")
|
||||
d = self.do_cli("put", rel_fn)
|
||||
def _uploaded((rc, out, err)):
|
||||
def _uploaded(args):
|
||||
(rc, out, err) = args
|
||||
readcap = out
|
||||
self.failUnless(readcap.startswith("URI:LIT:"), readcap)
|
||||
self.readcap = readcap
|
||||
d.addCallback(_uploaded)
|
||||
d.addCallback(lambda res: self.do_cli("put", "./" + rel_fn))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, self.readcap))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], self.readcap))
|
||||
d.addCallback(lambda res: self.do_cli("put", abs_fn))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, self.readcap))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], self.readcap))
|
||||
# we just have to assume that ~ is handled properly
|
||||
return d
|
||||
|
||||
@ -88,7 +89,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("put", rel_fn, "uploaded.txt"))
|
||||
def _uploaded((rc, out, err)):
|
||||
def _uploaded(args):
|
||||
(rc, out, err) = args
|
||||
readcap = out.strip()
|
||||
self.failUnless(readcap.startswith("URI:LIT:"), readcap)
|
||||
self.failUnlessIn("201 Created", err)
|
||||
@ -96,12 +98,13 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_uploaded)
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:uploaded.txt"))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, DATA))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], DATA))
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("put", "-", "uploaded.txt", stdin=DATA2))
|
||||
def _replaced((rc, out, err)):
|
||||
def _replaced(args):
|
||||
(rc, out, err) = args
|
||||
readcap = out.strip()
|
||||
self.failUnless(readcap.startswith("URI:LIT:"), readcap)
|
||||
self.failUnlessIn("200 OK", err)
|
||||
@ -110,21 +113,21 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("put", rel_fn, "subdir/uploaded2.txt"))
|
||||
d.addCallback(lambda res: self.do_cli("get", "subdir/uploaded2.txt"))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, DATA))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], DATA))
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("put", rel_fn, "tahoe:uploaded3.txt"))
|
||||
d.addCallback(lambda res: self.do_cli("get", "tahoe:uploaded3.txt"))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, DATA))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], DATA))
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("put", rel_fn, "tahoe:subdir/uploaded4.txt"))
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:subdir/uploaded4.txt"))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, DATA))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], DATA))
|
||||
|
||||
def _get_dircap(res):
|
||||
self.dircap = get_aliases(self.get_clientdir())["tahoe"]
|
||||
@ -135,16 +138,16 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.dircap+":./uploaded5.txt"))
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:uploaded5.txt"))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, DATA))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], DATA))
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("put", rel_fn,
|
||||
self.dircap+":./subdir/uploaded6.txt"))
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:subdir/uploaded6.txt"))
|
||||
d.addCallback(lambda (rc,stdout,stderr):
|
||||
self.failUnlessReallyEqual(stdout, DATA))
|
||||
d.addCallback(lambda rc_stdout_stderr:
|
||||
self.failUnlessReallyEqual(rc_stdout_stderr[1], DATA))
|
||||
|
||||
return d
|
||||
|
||||
@ -172,7 +175,7 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnless(self.filecap.startswith("URI:SSK:"), self.filecap)
|
||||
d.addCallback(_created)
|
||||
d.addCallback(lambda res: self.do_cli("get", self.filecap))
|
||||
d.addCallback(lambda (rc,out,err): self.failUnlessReallyEqual(out, DATA))
|
||||
d.addCallback(lambda rc_out_err: self.failUnlessReallyEqual(rc_out_err[1], DATA))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("put", "-", self.filecap, stdin=DATA2))
|
||||
def _replaced(res):
|
||||
@ -182,7 +185,7 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessReallyEqual(self.filecap, out)
|
||||
d.addCallback(_replaced)
|
||||
d.addCallback(lambda res: self.do_cli("get", self.filecap))
|
||||
d.addCallback(lambda (rc,out,err): self.failUnlessReallyEqual(out, DATA2))
|
||||
d.addCallback(lambda rc_out_err: self.failUnlessReallyEqual(rc_out_err[1], DATA2))
|
||||
|
||||
d.addCallback(lambda res: self.do_cli("put", rel_fn, self.filecap))
|
||||
def _replaced2(res):
|
||||
@ -191,7 +194,7 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessReallyEqual(self.filecap, out)
|
||||
d.addCallback(_replaced2)
|
||||
d.addCallback(lambda res: self.do_cli("get", self.filecap))
|
||||
d.addCallback(lambda (rc,out,err): self.failUnlessReallyEqual(out, DATA3))
|
||||
d.addCallback(lambda rc_out_err: self.failUnlessReallyEqual(rc_out_err[1], DATA3))
|
||||
|
||||
return d
|
||||
|
||||
@ -229,10 +232,11 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
d.addCallback(_check2)
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:uploaded.txt"))
|
||||
d.addCallback(lambda (rc,out,err): self.failUnlessReallyEqual(out, DATA2))
|
||||
d.addCallback(lambda rc_out_err: self.failUnlessReallyEqual(rc_out_err[1], DATA2))
|
||||
return d
|
||||
|
||||
def _check_mdmf_json(self, (rc, json, err)):
|
||||
def _check_mdmf_json(self, args):
|
||||
(rc, json, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessIn('"format": "MDMF"', json)
|
||||
@ -241,7 +245,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessIn("URI:MDMF-RO", json)
|
||||
self.failUnlessIn("URI:MDMF-Verifier", json)
|
||||
|
||||
def _check_sdmf_json(self, (rc, json, err)):
|
||||
def _check_sdmf_json(self, args):
|
||||
(rc, json, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessIn('"format": "SDMF"', json)
|
||||
@ -250,7 +255,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.failUnlessIn("URI:SSK-RO", json)
|
||||
self.failUnlessIn("URI:SSK-Verifier", json)
|
||||
|
||||
def _check_chk_json(self, (rc, json, err)):
|
||||
def _check_chk_json(self, args):
|
||||
(rc, json, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessIn('"format": "CHK"', json)
|
||||
@ -273,7 +279,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
# unlinked
|
||||
args = ["put"] + cmdargs + [fn1]
|
||||
d2 = self.do_cli(*args)
|
||||
def _list((rc, out, err)):
|
||||
def _list(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0) # don't allow failure
|
||||
if filename:
|
||||
return self.do_cli("ls", "--json", filename)
|
||||
@ -332,7 +339,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
fn1 = os.path.join(self.basedir, "data")
|
||||
fileutil.write(fn1, data)
|
||||
d = self.do_cli("put", "--format=MDMF", fn1)
|
||||
def _got_cap((rc, out, err)):
|
||||
def _got_cap(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.cap = out.strip()
|
||||
d.addCallback(_got_cap)
|
||||
@ -342,14 +350,16 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
fileutil.write(fn2, data2)
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("put", fn2, self.cap))
|
||||
def _got_put((rc, out, err)):
|
||||
def _got_put(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessIn(self.cap, out)
|
||||
d.addCallback(_got_put)
|
||||
# Now get the cap. We should see the data we just put there.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", self.cap))
|
||||
def _got_data((rc, out, err)):
|
||||
def _got_data(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(out, data2)
|
||||
d.addCallback(_got_data)
|
||||
@ -365,7 +375,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.do_cli("put", fn3, self.cap))
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", self.cap))
|
||||
def _got_data3((rc, out, err)):
|
||||
def _got_data3(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(out, data3)
|
||||
d.addCallback(_got_data3)
|
||||
@ -378,7 +389,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
fn1 = os.path.join(self.basedir, "data")
|
||||
fileutil.write(fn1, data)
|
||||
d = self.do_cli("put", "--format=SDMF", fn1)
|
||||
def _got_cap((rc, out, err)):
|
||||
def _got_cap(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.cap = out.strip()
|
||||
d.addCallback(_got_cap)
|
||||
@ -388,14 +400,16 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
fileutil.write(fn2, data2)
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("put", fn2, self.cap))
|
||||
def _got_put((rc, out, err)):
|
||||
def _got_put(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessIn(self.cap, out)
|
||||
d.addCallback(_got_put)
|
||||
# Now get the cap. We should see the data we just put there.
|
||||
d.addCallback(lambda ignored:
|
||||
self.do_cli("get", self.cap))
|
||||
def _got_data((rc, out, err)):
|
||||
def _got_data(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnlessEqual(out, data2)
|
||||
d.addCallback(_got_data)
|
||||
@ -413,7 +427,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
self.basedir = "cli/Put/put_with_nonexistent_alias"
|
||||
self.set_up_grid(oneshare=True)
|
||||
d = self.do_cli("put", "somefile", "fake:afile")
|
||||
def _check((rc, out, err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessReallyEqual(rc, 1)
|
||||
self.failUnlessIn("error:", err)
|
||||
self.failUnlessReallyEqual(out, "")
|
||||
@ -442,7 +457,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("put", rel_fn.encode(get_io_encoding()), a_trier_arg))
|
||||
def _uploaded((rc, out, err)):
|
||||
def _uploaded(args):
|
||||
(rc, out, err) = args
|
||||
readcap = out.strip()
|
||||
self.failUnless(readcap.startswith("URI:LIT:"), readcap)
|
||||
self.failUnlessIn("201 Created", err)
|
||||
@ -451,8 +467,8 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||
|
||||
d.addCallback(lambda res:
|
||||
self.do_cli("get", "tahoe:" + a_trier_arg))
|
||||
d.addCallback(lambda (rc, out, err):
|
||||
self.failUnlessReallyEqual(out, DATA))
|
||||
d.addCallback(lambda rc_out_err:
|
||||
self.failUnlessReallyEqual(rc_out_err[1], DATA))
|
||||
|
||||
return d
|
||||
|
||||
|
@ -208,7 +208,8 @@ class Problems(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin):
|
||||
# the choice of server for share[0].
|
||||
|
||||
d = nm.key_generator.generate(TEST_RSA_KEY_SIZE)
|
||||
def _got_key( (pubkey, privkey) ):
|
||||
def _got_key(keypair):
|
||||
(pubkey, privkey) = keypair
|
||||
nm.key_generator = SameKeyGenerator(pubkey, privkey)
|
||||
pubkey_s = pubkey.serialize()
|
||||
privkey_s = privkey.serialize()
|
||||
|
@ -497,7 +497,8 @@ class GridTestMixin(object):
|
||||
for sharefile, data in shares.items():
|
||||
open(sharefile, "wb").write(data)
|
||||
|
||||
def delete_share(self, (shnum, serverid, sharefile)):
|
||||
def delete_share(self, sharenum_and_serverid_and_sharefile):
|
||||
(shnum, serverid, sharefile) = sharenum_and_serverid_and_sharefile
|
||||
os.unlink(sharefile)
|
||||
|
||||
def delete_shares_numbered(self, uri, shnums):
|
||||
@ -511,7 +512,8 @@ class GridTestMixin(object):
|
||||
if prefixdir != 'incoming':
|
||||
fileutil.rm_dir(os.path.join(sharedir, prefixdir))
|
||||
|
||||
def corrupt_share(self, (shnum, serverid, sharefile), corruptor_function):
|
||||
def corrupt_share(self, sharenum_and_serverid_and_sharefile, corruptor_function):
|
||||
(shnum, serverid, sharefile) = sharenum_and_serverid_and_sharefile
|
||||
sharedata = open(sharefile, "rb").read()
|
||||
corruptdata = corruptor_function(sharedata)
|
||||
open(sharefile, "wb").write(corruptdata)
|
||||
|
@ -15,7 +15,8 @@ class T(unittest.TestCase):
|
||||
assert params == (size, required_shares, max_shares)
|
||||
log.msg("params: %s" % (params,))
|
||||
d = enc.encode(data0s)
|
||||
def _done_encoding_all((shares, shareids)):
|
||||
def _done_encoding_all(shares_and_shareids):
|
||||
(shares, shareids) = shares_and_shareids
|
||||
self.failUnlessEqual(len(shares), max_shares)
|
||||
self.shares = shares
|
||||
self.shareids = shareids
|
||||
@ -24,11 +25,13 @@ class T(unittest.TestCase):
|
||||
# also validate that the desired_shareids= parameter works
|
||||
desired_shareids = random.sample(range(max_shares), fewer_shares)
|
||||
d.addCallback(lambda res: enc.encode(data0s, desired_shareids))
|
||||
def _check_fewer_shares((some_shares, their_shareids)):
|
||||
def _check_fewer_shares(some_shares_and_their_shareids):
|
||||
(some_shares, their_shareids) = some_shares_and_their_shareids
|
||||
self.failUnlessEqual(tuple(their_shareids), tuple(desired_shareids))
|
||||
d.addCallback(_check_fewer_shares)
|
||||
|
||||
def _decode((shares, shareids)):
|
||||
def _decode(shares_and_shareids):
|
||||
(shares, shareids) = shares_and_shareids
|
||||
dec = CRSDecoder()
|
||||
dec.set_params(*params)
|
||||
d1 = dec.decode(shares, shareids)
|
||||
|
@ -131,7 +131,8 @@ class DeepCheckBase(GridTestMixin, ErrorMixin, StallMixin, ShouldFailMixin,
|
||||
d.addCallback(self.decode_json)
|
||||
return d
|
||||
|
||||
def decode_json(self, (s,url)):
|
||||
def decode_json(self, args):
|
||||
(s, url) = args
|
||||
try:
|
||||
data = json.loads(s)
|
||||
except ValueError:
|
||||
@ -357,8 +358,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_web_stream_manifest(self, ignored):
|
||||
d = self.web(self.root, method="POST", t="stream-manifest")
|
||||
d.addCallback(lambda (output,url):
|
||||
self._check_streamed_manifest(output))
|
||||
d.addCallback(lambda output_and_url:
|
||||
self._check_streamed_manifest(output_and_url[0]))
|
||||
return d
|
||||
|
||||
def _check_streamed_manifest(self, output):
|
||||
@ -733,7 +734,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_cli_manifest_stream1(self):
|
||||
d = self.do_cli("manifest", self.root_uri)
|
||||
def _check((rc,out,err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(err, "")
|
||||
lines = [l for l in out.split("\n") if l]
|
||||
self.failUnlessEqual(len(lines), 8)
|
||||
@ -758,7 +760,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_cli_manifest_stream2(self):
|
||||
d = self.do_cli("manifest", "--raw", self.root_uri)
|
||||
def _check((rc,out,err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(err, "")
|
||||
# this should be the same as the POST t=stream-manifest output
|
||||
self._check_streamed_manifest(out)
|
||||
@ -767,7 +770,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_cli_manifest_stream3(self):
|
||||
d = self.do_cli("manifest", "--storage-index", self.root_uri)
|
||||
def _check((rc,out,err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(err, "")
|
||||
self._check_manifest_storage_index(out)
|
||||
d.addCallback(_check)
|
||||
@ -775,7 +779,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_cli_manifest_stream4(self):
|
||||
d = self.do_cli("manifest", "--verify-cap", self.root_uri)
|
||||
def _check((rc,out,err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(err, "")
|
||||
lines = [l for l in out.split("\n") if l]
|
||||
self.failUnlessEqual(len(lines), 3)
|
||||
@ -787,7 +792,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_cli_manifest_stream5(self):
|
||||
d = self.do_cli("manifest", "--repair-cap", self.root_uri)
|
||||
def _check((rc,out,err)):
|
||||
def _check(args):
|
||||
(rc, out, err) = args
|
||||
self.failUnlessEqual(err, "")
|
||||
lines = [l for l in out.split("\n") if l]
|
||||
self.failUnlessEqual(len(lines), 3)
|
||||
@ -799,7 +805,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_cli_stats1(self):
|
||||
d = self.do_cli("stats", self.root_uri)
|
||||
def _check3((rc,out,err)):
|
||||
def _check3(args):
|
||||
(rc, out, err) = args
|
||||
lines = [l.strip() for l in out.split("\n") if l]
|
||||
self.failUnless("count-immutable-files: 1" in lines)
|
||||
self.failUnless("count-mutable-files: 1" in lines)
|
||||
@ -816,7 +823,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
|
||||
|
||||
def do_cli_stats2(self):
|
||||
d = self.do_cli("stats", "--raw", self.root_uri)
|
||||
def _check4((rc,out,err)):
|
||||
def _check4(args):
|
||||
(rc, out, err) = args
|
||||
data = json.loads(out)
|
||||
self.failUnlessEqual(data["count-immutable-files"], 1)
|
||||
self.failUnlessEqual(data["count-immutable-files"], 1)
|
||||
@ -1189,7 +1197,8 @@ class Large(DeepCheckBase, unittest.TestCase):
|
||||
def _start_deepcheck(ignored):
|
||||
return self.web(self.root, method="POST", t="stream-deep-check")
|
||||
d.addCallback(_start_deepcheck)
|
||||
def _check( (output, url) ):
|
||||
def _check(output_and_url):
|
||||
(output, url) = output_and_url
|
||||
units = list(self.parse_streamed_json(output))
|
||||
self.failUnlessEqual(len(units), 2+COUNT+1)
|
||||
d.addCallback(_check)
|
||||
|
@ -621,7 +621,8 @@ class DownloadTest(_Base, unittest.TestCase):
|
||||
n = self.c0.create_node_from_uri(immutable_uri)
|
||||
cn = n._cnode
|
||||
(d,c) = cn.get_segment(0)
|
||||
def _got_segment((offset,data,decodetime)):
|
||||
def _got_segment(offset_and_data_and_decodetime):
|
||||
(offset, data, decodetime) = offset_and_data_and_decodetime
|
||||
self.failUnlessEqual(offset, 0)
|
||||
self.failUnlessEqual(len(data), len(plaintext))
|
||||
d.addCallback(_got_segment)
|
||||
|
@ -1348,7 +1348,8 @@ class Handler(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, unittest.TestCas
|
||||
d.addCallback(lambda ign: self.handler.makeDirectory("newdir", {'ext_foo': 'bar', 'ctime': 42}))
|
||||
|
||||
d.addCallback(lambda ign: self.root.get_child_and_metadata(u"newdir"))
|
||||
def _got( (child, metadata) ):
|
||||
def _got(child_and_metadata):
|
||||
(child, metadata) = child_and_metadata
|
||||
self.failUnless(IDirectoryNode.providedBy(child))
|
||||
self.failUnless(child.is_mutable())
|
||||
# FIXME
|
||||
|
@ -1620,7 +1620,8 @@ class MDMFProxies(unittest.TestCase, ShouldFailMixin):
|
||||
mr = MDMFSlotReadProxy(self.rref, "si1", 0)
|
||||
# Check that every method equals what we expect it to.
|
||||
d = defer.succeed(None)
|
||||
def _check_block_and_salt((block, salt)):
|
||||
def _check_block_and_salt(block_and_salt):
|
||||
(block, salt) = block_and_salt
|
||||
self.failUnlessEqual(block, self.block)
|
||||
self.failUnlessEqual(salt, self.salt)
|
||||
|
||||
@ -1671,7 +1672,8 @@ class MDMFProxies(unittest.TestCase, ShouldFailMixin):
|
||||
|
||||
d.addCallback(lambda ignored:
|
||||
mr.get_encoding_parameters())
|
||||
def _check_encoding_parameters((k, n, segsize, datalen)):
|
||||
def _check_encoding_parameters(args):
|
||||
(k, n, segsize, datalen) = args
|
||||
self.failUnlessEqual(k, 3)
|
||||
self.failUnlessEqual(n, 10)
|
||||
self.failUnlessEqual(segsize, 6)
|
||||
@ -1712,7 +1714,8 @@ class MDMFProxies(unittest.TestCase, ShouldFailMixin):
|
||||
self.write_test_share_to_server("si1")
|
||||
mr = MDMFSlotReadProxy(self.rref, "si1", 0)
|
||||
d = mr.get_encoding_parameters()
|
||||
def _check_encoding_parameters((k, n, segment_size, datalen)):
|
||||
def _check_encoding_parameters(args):
|
||||
(k, n, segment_size, datalen) = args
|
||||
self.failUnlessEqual(k, 3)
|
||||
self.failUnlessEqual(n, 10)
|
||||
self.failUnlessEqual(segment_size, 6)
|
||||
@ -2260,7 +2263,8 @@ class MDMFProxies(unittest.TestCase, ShouldFailMixin):
|
||||
mw.finish_publishing())
|
||||
|
||||
mr = MDMFSlotReadProxy(self.rref, "si1", 0)
|
||||
def _check_block_and_salt((block, salt)):
|
||||
def _check_block_and_salt(block_and_salt):
|
||||
(block, salt) = block_and_salt
|
||||
self.failUnlessEqual(block, self.block)
|
||||
self.failUnlessEqual(salt, self.salt)
|
||||
|
||||
@ -2306,7 +2310,8 @@ class MDMFProxies(unittest.TestCase, ShouldFailMixin):
|
||||
|
||||
d.addCallback(lambda ignored:
|
||||
mr.get_encoding_parameters())
|
||||
def _check_encoding_parameters((k, n, segsize, datalen)):
|
||||
def _check_encoding_parameters(args):
|
||||
(k, n, segsize, datalen) = args
|
||||
self.failUnlessEqual(k, 3)
|
||||
self.failUnlessEqual(n, 10)
|
||||
self.failUnlessEqual(segsize, 6)
|
||||
@ -2473,7 +2478,8 @@ class MDMFProxies(unittest.TestCase, ShouldFailMixin):
|
||||
d.addCallback(_make_mr, 123)
|
||||
d.addCallback(lambda mr:
|
||||
mr.get_block_and_salt(0))
|
||||
def _check_block_and_salt((block, salt)):
|
||||
def _check_block_and_salt(block_and_salt):
|
||||
(block, salt) = block_and_salt
|
||||
self.failUnlessEqual(block, self.block)
|
||||
self.failUnlessEqual(salt, self.salt)
|
||||
self.failUnlessEqual(self.rref.read_count, 1)
|
||||
@ -2534,7 +2540,8 @@ class MDMFProxies(unittest.TestCase, ShouldFailMixin):
|
||||
d.addCallback(_make_mr, 123)
|
||||
d.addCallback(lambda mr:
|
||||
mr.get_block_and_salt(0))
|
||||
def _check_block_and_salt((block, salt)):
|
||||
def _check_block_and_salt(block_and_salt):
|
||||
(block, salt) = block_and_salt
|
||||
self.failUnlessEqual(block, self.block * 6)
|
||||
self.failUnlessEqual(salt, self.salt)
|
||||
# TODO: Fix the read routine so that it reads only the data
|
||||
|
@ -1258,7 +1258,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
return d1
|
||||
d.addCallback(_check_download_2)
|
||||
|
||||
def _check_download_3((res, newnode)):
|
||||
def _check_download_3(res_and_newnode):
|
||||
(res, newnode) = res_and_newnode
|
||||
self.failUnlessEqual(res, DATA)
|
||||
# replace the data
|
||||
log.msg("starting replace1")
|
||||
@ -2088,14 +2089,16 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
rc,out,err = yield run_cli(verb, *args, nodeargs=nodeargs, **kwargs)
|
||||
defer.returnValue((out,err))
|
||||
|
||||
def _check_ls((out,err), expected_children, unexpected_children=[]):
|
||||
def _check_ls(out_and_err, expected_children, unexpected_children=[]):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(err, "")
|
||||
for s in expected_children:
|
||||
self.failUnless(s in out, (s,out))
|
||||
for s in unexpected_children:
|
||||
self.failIf(s in out, (s,out))
|
||||
|
||||
def _check_ls_root((out,err)):
|
||||
def _check_ls_root(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnless("personal" in out)
|
||||
self.failUnless("s2-ro" in out)
|
||||
self.failUnless("s2-rw" in out)
|
||||
@ -2106,7 +2109,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
d.addCallback(_check_ls, ["personal", "s2-ro", "s2-rw"])
|
||||
|
||||
d.addCallback(run, "list-aliases")
|
||||
def _check_aliases_1((out,err)):
|
||||
def _check_aliases_1(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessEqual(out.strip(" \n"), "tahoe: %s" % private_uri)
|
||||
d.addCallback(_check_aliases_1)
|
||||
@ -2115,32 +2119,37 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
# new files
|
||||
d.addCallback(lambda res: os.unlink(root_file))
|
||||
d.addCallback(run, "list-aliases")
|
||||
def _check_aliases_2((out,err)):
|
||||
def _check_aliases_2(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessEqual(out, "")
|
||||
d.addCallback(_check_aliases_2)
|
||||
|
||||
d.addCallback(run, "mkdir")
|
||||
def _got_dir( (out,err) ):
|
||||
def _got_dir(out_and_err ):
|
||||
(out, err) = out_and_err
|
||||
self.failUnless(uri.from_string_dirnode(out.strip()))
|
||||
return out.strip()
|
||||
d.addCallback(_got_dir)
|
||||
d.addCallback(lambda newcap: run(None, "add-alias", "tahoe", newcap))
|
||||
|
||||
d.addCallback(run, "list-aliases")
|
||||
def _check_aliases_3((out,err)):
|
||||
def _check_aliases_3(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnless("tahoe: " in out)
|
||||
d.addCallback(_check_aliases_3)
|
||||
|
||||
def _check_empty_dir((out,err)):
|
||||
def _check_empty_dir(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(out, "")
|
||||
self.failUnlessEqual(err, "")
|
||||
d.addCallback(run, "ls")
|
||||
d.addCallback(_check_empty_dir)
|
||||
|
||||
def _check_missing_dir((out,err)):
|
||||
def _check_missing_dir(out_and_err):
|
||||
# TODO: check that rc==2
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(out, "")
|
||||
self.failUnlessEqual(err, "No such file or directory\n")
|
||||
d.addCallback(run, "ls", "bogus")
|
||||
@ -2155,7 +2164,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
datas.append(data)
|
||||
open(fn,"wb").write(data)
|
||||
|
||||
def _check_stdout_against((out,err), filenum=None, data=None):
|
||||
def _check_stdout_against(out_and_err, filenum=None, data=None):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(err, "")
|
||||
if filenum is not None:
|
||||
self.failUnlessEqual(out, datas[filenum])
|
||||
@ -2165,19 +2175,21 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
# test all both forms of put: from a file, and from stdin
|
||||
# tahoe put bar FOO
|
||||
d.addCallback(run, "put", files[0], "tahoe-file0")
|
||||
def _put_out((out,err)):
|
||||
def _put_out(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnless("URI:LIT:" in out, out)
|
||||
self.failUnless("201 Created" in err, err)
|
||||
uri0 = out.strip()
|
||||
return run(None, "get", uri0)
|
||||
d.addCallback(_put_out)
|
||||
d.addCallback(lambda (out,err): self.failUnlessEqual(out, datas[0]))
|
||||
d.addCallback(lambda out_err: self.failUnlessEqual(out_err[0], datas[0]))
|
||||
|
||||
d.addCallback(run, "put", files[1], "subdir/tahoe-file1")
|
||||
# tahoe put bar tahoe:FOO
|
||||
d.addCallback(run, "put", files[2], "tahoe:file2")
|
||||
d.addCallback(run, "put", "--format=SDMF", files[3], "tahoe:file3")
|
||||
def _check_put_mutable((out,err)):
|
||||
def _check_put_mutable(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self._mutable_file3_uri = out.strip()
|
||||
d.addCallback(_check_put_mutable)
|
||||
d.addCallback(run, "get", "tahoe:file3")
|
||||
@ -2209,13 +2221,15 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
d.addCallback(_check_stdout_against, 1)
|
||||
outfile0 = os.path.join(self.basedir, "outfile0")
|
||||
d.addCallback(run, "get", "file2", outfile0)
|
||||
def _check_outfile0((out,err)):
|
||||
def _check_outfile0(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
data = open(outfile0,"rb").read()
|
||||
self.failUnlessEqual(data, "data to be uploaded: file2\n")
|
||||
d.addCallback(_check_outfile0)
|
||||
outfile1 = os.path.join(self.basedir, "outfile0")
|
||||
d.addCallback(run, "get", "tahoe:subdir/tahoe-file1", outfile1)
|
||||
def _check_outfile1((out,err)):
|
||||
def _check_outfile1(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
data = open(outfile1,"rb").read()
|
||||
self.failUnlessEqual(data, "data to be uploaded: file1\n")
|
||||
d.addCallback(_check_outfile1)
|
||||
@ -2226,7 +2240,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
d.addCallback(_check_ls, [], ["tahoe-file0", "file2"])
|
||||
|
||||
d.addCallback(run, "ls", "-l")
|
||||
def _check_ls_l((out,err)):
|
||||
def _check_ls_l(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
lines = out.split("\n")
|
||||
for l in lines:
|
||||
if "tahoe-file-stdin" in l:
|
||||
@ -2237,7 +2252,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
d.addCallback(_check_ls_l)
|
||||
|
||||
d.addCallback(run, "ls", "--uri")
|
||||
def _check_ls_uri((out,err)):
|
||||
def _check_ls_uri(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
lines = out.split("\n")
|
||||
for l in lines:
|
||||
if "file3" in l:
|
||||
@ -2245,7 +2261,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
d.addCallback(_check_ls_uri)
|
||||
|
||||
d.addCallback(run, "ls", "--readonly-uri")
|
||||
def _check_ls_rouri((out,err)):
|
||||
def _check_ls_rouri(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
lines = out.split("\n")
|
||||
for l in lines:
|
||||
if "file3" in l:
|
||||
@ -2280,7 +2297,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
# copy from tahoe into disk
|
||||
target_filename = os.path.join(self.basedir, "file-out")
|
||||
d.addCallback(run, "cp", "tahoe:file4", target_filename)
|
||||
def _check_cp_out((out,err)):
|
||||
def _check_cp_out(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnless(os.path.exists(target_filename))
|
||||
got = open(target_filename,"rb").read()
|
||||
self.failUnlessEqual(got, datas[4])
|
||||
@ -2289,7 +2307,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
# copy from disk to disk (silly case)
|
||||
target2_filename = os.path.join(self.basedir, "file-out-copy")
|
||||
d.addCallback(run, "cp", target_filename, target2_filename)
|
||||
def _check_cp_out2((out,err)):
|
||||
def _check_cp_out2(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnless(os.path.exists(target2_filename))
|
||||
got = open(target2_filename,"rb").read()
|
||||
self.failUnlessEqual(got, datas[4])
|
||||
@ -2297,7 +2316,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
|
||||
# copy from tahoe into disk, overwriting an existing file
|
||||
d.addCallback(run, "cp", "tahoe:file3", target_filename)
|
||||
def _check_cp_out3((out,err)):
|
||||
def _check_cp_out3(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnless(os.path.exists(target_filename))
|
||||
got = open(target_filename,"rb").read()
|
||||
self.failUnlessEqual(got, datas[3])
|
||||
@ -2344,7 +2364,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
# and back out again
|
||||
dn_copy = os.path.join(self.basedir, "dir1-copy")
|
||||
d.addCallback(run, "cp", "--verbose", "-r", "tahoe:dir1", dn_copy)
|
||||
def _check_cp_r_out((out,err)):
|
||||
def _check_cp_r_out(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
def _cmp(name):
|
||||
old = open(os.path.join(dn, name), "rb").read()
|
||||
newfn = os.path.join(dn_copy, "dir1", name)
|
||||
@ -2364,8 +2385,9 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
# and again, only writing filecaps
|
||||
dn_copy2 = os.path.join(self.basedir, "dir1-copy-capsonly")
|
||||
d.addCallback(run, "cp", "-r", "--caps-only", "tahoe:dir1", dn_copy2)
|
||||
def _check_capsonly((out,err)):
|
||||
def _check_capsonly(out_and_err):
|
||||
# these should all be LITs
|
||||
(out, err) = out_and_err
|
||||
x = open(os.path.join(dn_copy2, "dir1", "subdir2", "rfile4")).read()
|
||||
y = uri.from_string_filenode(x)
|
||||
self.failUnlessEqual(y.data, "rfile4")
|
||||
|
@ -448,7 +448,9 @@ class ServerErrors(unittest.TestCase, ShouldFailMixin, SetDEPMixin):
|
||||
d = self.shouldFail(UploadUnhappinessError, "first_error_all",
|
||||
"server selection failed",
|
||||
upload_data, self.u, DATA)
|
||||
def _check((f,)):
|
||||
def _check(f):
|
||||
# for some reason this is passed as a 1-tuple
|
||||
(f,) = f
|
||||
self.failUnlessIn("placed 0 shares out of 100 total", str(f.value))
|
||||
# there should also be a 'last failure was' message
|
||||
self.failUnlessIn("ServerError", str(f.value))
|
||||
@ -460,7 +462,9 @@ class ServerErrors(unittest.TestCase, ShouldFailMixin, SetDEPMixin):
|
||||
d = self.shouldFail(UploadUnhappinessError, "second_error_all",
|
||||
"server selection failed",
|
||||
upload_data, self.u, DATA)
|
||||
def _check((f,)):
|
||||
def _check(f):
|
||||
# for some reason this is passed as a 1-tuple
|
||||
(f,) = f
|
||||
self.failUnlessIn("shares could be placed or found on only 10 server(s)", str(f.value))
|
||||
d.addCallback(_check)
|
||||
return d
|
||||
@ -482,7 +486,9 @@ class ServerErrors(unittest.TestCase, ShouldFailMixin, SetDEPMixin):
|
||||
d = self.shouldFail(UploadUnhappinessError, "second_error_some",
|
||||
"server selection failed",
|
||||
upload_data, self.u, DATA)
|
||||
def _check((f,)):
|
||||
def _check(f):
|
||||
# for some reason this is passed as a 1-tuple
|
||||
(f,) = f
|
||||
self.failUnlessIn("shares could be placed on only 5 server(s)", str(f.value))
|
||||
d.addCallback(_check)
|
||||
return d
|
||||
@ -509,7 +515,9 @@ class ServerErrors(unittest.TestCase, ShouldFailMixin, SetDEPMixin):
|
||||
d = self.shouldFail(UploadUnhappinessError, "second_error_some",
|
||||
"server selection failed",
|
||||
upload_data, self.u, DATA)
|
||||
def _check((f,)):
|
||||
def _check(f):
|
||||
# for some reason this is passed as a 1-tuple
|
||||
(f,) = f
|
||||
self.failUnlessIn("shares could be placed on only 6 server(s)", str(f.value))
|
||||
d.addCallback(_check)
|
||||
return d
|
||||
@ -536,7 +544,9 @@ class ServerErrors(unittest.TestCase, ShouldFailMixin, SetDEPMixin):
|
||||
d = self.shouldFail(UploadUnhappinessError, "good_servers_stay_writable",
|
||||
"server selection failed",
|
||||
upload_data, self.u, DATA)
|
||||
def _check((f,)):
|
||||
def _check(f):
|
||||
# for some reason this is passed as a 1-tuple
|
||||
(f,) = f
|
||||
self.failUnlessIn("shares could be placed on only 5 server(s)", str(f.value))
|
||||
d.addCallback(_check)
|
||||
return d
|
||||
@ -918,7 +928,8 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin,
|
||||
d = selector.get_shareholders(broker, sh, storage_index,
|
||||
share_size, block_size, num_segments,
|
||||
10, 3, 4)
|
||||
def _have_shareholders((upload_trackers, already_servers)):
|
||||
def _have_shareholders(upload_trackers_and_already_servers):
|
||||
(upload_trackers, already_servers) = upload_trackers_and_already_servers
|
||||
assert servers_to_break <= len(upload_trackers)
|
||||
for index in xrange(servers_to_break):
|
||||
tracker = list(upload_trackers)[index]
|
||||
|
@ -1693,7 +1693,8 @@ class SimpleSpans:
|
||||
s.add(i, 1)
|
||||
return s
|
||||
|
||||
def __contains__(self, (start,length)):
|
||||
def __contains__(self, start_and_length):
|
||||
(start, length) = start_and_length
|
||||
for i in range(start, start+length):
|
||||
if i not in self._have:
|
||||
return False
|
||||
|
@ -1161,7 +1161,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
headers = {"range": "bytes=1-10"}
|
||||
d = self.GET(self.public_url + "/foo/bar.txt", headers=headers,
|
||||
return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(int(status), 206)
|
||||
self.failUnless(headers.hasHeader("content-range"))
|
||||
self.failUnlessReallyEqual(headers.getRawHeaders("content-range")[0],
|
||||
@ -1175,7 +1176,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
length = len(self.BAR_CONTENTS)
|
||||
d = self.GET(self.public_url + "/foo/bar.txt", headers=headers,
|
||||
return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(int(status), 206)
|
||||
self.failUnless(headers.hasHeader("content-range"))
|
||||
self.failUnlessReallyEqual(headers.getRawHeaders("content-range")[0],
|
||||
@ -1189,7 +1191,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
length = len(self.BAR_CONTENTS)
|
||||
d = self.GET(self.public_url + "/foo/bar.txt", headers=headers,
|
||||
return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(int(status), 206)
|
||||
self.failUnless(headers.hasHeader("content-range"))
|
||||
self.failUnlessReallyEqual(headers.getRawHeaders("content-range")[0],
|
||||
@ -1211,7 +1214,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
headers = {"range": "bytes=1-10"}
|
||||
d = self.HEAD(self.public_url + "/foo/bar.txt", headers=headers,
|
||||
return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(res, "")
|
||||
self.failUnlessReallyEqual(int(status), 206)
|
||||
self.failUnless(headers.hasHeader("content-range"))
|
||||
@ -1225,7 +1229,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
length = len(self.BAR_CONTENTS)
|
||||
d = self.HEAD(self.public_url + "/foo/bar.txt", headers=headers,
|
||||
return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(int(status), 206)
|
||||
self.failUnless(headers.hasHeader("content-range"))
|
||||
self.failUnlessReallyEqual(headers.getRawHeaders("content-range")[0],
|
||||
@ -1238,7 +1243,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
length = len(self.BAR_CONTENTS)
|
||||
d = self.HEAD(self.public_url + "/foo/bar.txt", headers=headers,
|
||||
return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(int(status), 206)
|
||||
self.failUnless(headers.hasHeader("content-range"))
|
||||
self.failUnlessReallyEqual(headers.getRawHeaders("content-range")[0],
|
||||
@ -1259,7 +1265,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
headers = {"range": "BOGUS=fizbop-quarnak"}
|
||||
d = self.GET(self.public_url + "/foo/bar.txt", headers=headers,
|
||||
return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(int(status), 200)
|
||||
self.failUnless(not headers.hasHeader("content-range"))
|
||||
self.failUnlessReallyEqual(res, self.BAR_CONTENTS)
|
||||
@ -1268,7 +1275,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
|
||||
def test_HEAD_FILEURL(self):
|
||||
d = self.HEAD(self.public_url + "/foo/bar.txt", return_response=True)
|
||||
def _got((res, status, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(res, "")
|
||||
self.failUnlessReallyEqual(headers.getRawHeaders("content-length")[0],
|
||||
str(len(self.BAR_CONTENTS)))
|
||||
@ -1477,29 +1485,29 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
uri = "/uri/%s" % self._bar_txt_uri
|
||||
d = self.GET(uri, return_response=True)
|
||||
# extract the ETag
|
||||
d.addCallback(lambda (data, code, headers):
|
||||
headers.getRawHeaders('etag')[0])
|
||||
d.addCallback(lambda data_code_headers:
|
||||
data_code_headers[2].getRawHeaders('etag')[0])
|
||||
# do a GET that's supposed to match the ETag
|
||||
d.addCallback(lambda etag:
|
||||
self.GET(uri, return_response=True,
|
||||
headers={"If-None-Match": etag}))
|
||||
# make sure it short-circuited (304 instead of 200)
|
||||
d.addCallback(lambda (data, code, headers):
|
||||
self.failUnlessEqual(int(code), http.NOT_MODIFIED))
|
||||
d.addCallback(lambda data_code_headers:
|
||||
self.failUnlessEqual(int(data_code_headers[1]), http.NOT_MODIFIED))
|
||||
return d
|
||||
d.addCallback(_check_match)
|
||||
|
||||
def _no_etag(uri, t):
|
||||
target = "/uri/%s?t=%s" % (uri, t)
|
||||
d = self.GET(target, return_response=True, followRedirect=True)
|
||||
d.addCallback(lambda (data, code, headers):
|
||||
self.failIf(headers.hasHeader("etag"), target))
|
||||
d.addCallback(lambda data_code_headers:
|
||||
self.failIf(data_code_headers[2].hasHeader("etag"), target))
|
||||
return d
|
||||
def _yes_etag(uri, t):
|
||||
target = "/uri/%s?t=%s" % (uri, t)
|
||||
d = self.GET(target, return_response=True, followRedirect=True)
|
||||
d.addCallback(lambda (data, code, headers):
|
||||
self.failUnless(headers.hasHeader("etag"), target))
|
||||
d.addCallback(lambda data_code_headers:
|
||||
self.failUnless(data_code_headers[2].hasHeader("etag"), target))
|
||||
return d
|
||||
|
||||
d.addCallback(lambda ign: _yes_etag(self._bar_txt_uri, ""))
|
||||
@ -1521,7 +1529,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
def test_GET_FILEURL_save(self):
|
||||
d = self.GET(self.public_url + "/foo/bar.txt?filename=bar.txt&save=true",
|
||||
return_response=True)
|
||||
def _got((res, statuscode, headers)):
|
||||
def _got(res_and_status_and_headers):
|
||||
(res, statuscode, headers) = res_and_status_and_headers
|
||||
content_disposition = headers.getRawHeaders("content-disposition")[0]
|
||||
self.failUnless(content_disposition == 'attachment; filename="bar.txt"', content_disposition)
|
||||
self.failUnlessIsBarDotTxt(res)
|
||||
@ -2852,7 +2861,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||
d.addCallback(lambda res:
|
||||
self.HEAD(self.public_url + "/foo/new.txt",
|
||||
return_response=True))
|
||||
def _got_headers((res, status, headers)):
|
||||
def _got_headers(res_and_status_and_headers):
|
||||
(res, status, headers) = res_and_status_and_headers
|
||||
self.failUnlessReallyEqual(res, "")
|
||||
self.failUnlessReallyEqual(headers.getRawHeaders("content-length")[0],
|
||||
str(len(NEW2_CONTENTS)))
|
||||
|
@ -156,8 +156,7 @@ def servers_of_happiness(sharemap):
|
||||
# is the amount of unused capacity on that edge. Taking the
|
||||
# minimum of a list of those values for each edge in the
|
||||
# augmenting path gives us our delta.
|
||||
delta = min(map(lambda (u, v), rf=residual_function: rf[u][v],
|
||||
path))
|
||||
delta = min(residual_function[u][v] for (u, v) in path)
|
||||
for (u, v) in path:
|
||||
flow_function[u][v] += delta
|
||||
flow_function[v][u] -= delta
|
||||
|
@ -193,7 +193,8 @@ class Spans:
|
||||
not_other = bounds - other
|
||||
return self - not_other
|
||||
|
||||
def __contains__(self, (start,length)):
|
||||
def __contains__(self, start_and_length):
|
||||
(start, length) = start_and_length
|
||||
for span_start,span_length in self._spans:
|
||||
o = overlap(start, length, span_start, span_length)
|
||||
if o:
|
||||
|
Loading…
Reference in New Issue
Block a user