From: Daira Hopwood Date: Tue, 27 Oct 2015 01:20:28 +0000 (+0000) Subject: Avoid .format, since it is inconsistent between Python 2.6 and 2.7 (and the rest... X-Git-Url: https://git.rkrishnan.org/pf/content/%22news.html/FOOURL?a=commitdiff_plain;h=c8a59c9d30dacb4bea45c382c4ad3d46ace452af;p=tahoe-lafs%2Ftahoe-lafs.git Avoid .format, since it is inconsistent between Python 2.6 and 2.7 (and the rest of Tahoe-LAFS doesn't use it). Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 51750888..9225d17b 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -325,7 +325,7 @@ class Uploader(QueueMixin): elif self._db.is_new_file(pathinfo, relpath_u): new_version = current_version + 1 else: - self._log("Not uploading '{0}'".format(relpath_u)) + self._log("Not uploading %r" % (relpath_u,)) self._count('objects_not_uploaded') return @@ -373,7 +373,7 @@ class Uploader(QueueMixin): elif self._db.is_new_file(pathinfo, relpath_u): new_version = current_version + 1 else: - self._log("Not uploading '{0}'".format(relpath_u)) + self._log("Not uploading %r" % (relpath_u,)) self._count('objects_not_uploaded') return None @@ -628,7 +628,7 @@ class Downloader(QueueMixin, WriteFileMixin): if self._should_download(relpath_u, metadata['version']): extension += [(relpath_u, file_node, metadata)] else: - self._log("Excluding '{0}'".format(relpath_u)) + self._log("Excluding %r" % (relpath_u,)) self._count('objects_excluded') self._call_hook(None, 'processed') return extension diff --git a/src/allmydata/test/check_magicfolder_smoke.py b/src/allmydata/test/check_magicfolder_smoke.py index e3b2013d..b34eebdf 100644 --- a/src/allmydata/test/check_magicfolder_smoke.py +++ b/src/allmydata/test/check_magicfolder_smoke.py @@ -48,7 +48,7 @@ if not exists(data_base): mkdir(data_base) if not exists(tahoe_bin): - raise RuntimeError("Can't find 'tahoe' binary at '{}'".format(tahoe_bin)) + raise RuntimeError("Can't find 'tahoe' binary at %r" % (tahoe_bin,)) if 'kill' in sys.argv: print("Killing the grid") @@ -92,7 +92,7 @@ for x in range(5): subprocess.check_call( [ tahoe_bin, 'create-node', - '--nickname', 'node{}'.format(x), + '--nickname', 'node%d' % (x,), '--introducer', furl, data_dir, ] @@ -100,18 +100,18 @@ for x in range(5): with open(join(data_dir, 'tahoe.cfg'), 'w') as f: f.write(''' [node] -nickname = node{node_id} +nickname = node%(node_id)s web.port = web.static = public_html -tub.location = localhost:{tub_port} +tub.location = localhost:%(tub_port)d [client] # Which services should this client connect to? -introducer.furl = {furl} +introducer.furl = %(furl)s shares.needed = 2 shares.happy = 3 shares.total = 4 -'''.format(node_id=x, furl=furl, tub_port=(9900 + x))) +''' % {'node_id':x, 'furl':furl, 'tub_port':(9900 + x)}) subprocess.check_call( [ tahoe_bin, 'start', data_dir, @@ -125,7 +125,7 @@ do_invites = False node_id = 0 for name in ['alice', 'bob']: data_dir = join(data_base, name) - magic_dir = join(data_base, '{}-magic'.format(name)) + magic_dir = join(data_base, '%s-magic' % (name,)) mkdir(magic_dir) if not exists(data_dir): do_invites = True @@ -141,17 +141,17 @@ for name in ['alice', 'bob']: with open(join(data_dir, 'tahoe.cfg'), 'w') as f: f.write(''' [node] -nickname = {name} -web.port = tcp:998{node_id}:interface=localhost +nickname = %(name)s +web.port = tcp:998%(node_id)d:interface=localhost web.static = public_html [client] # Which services should this client connect to? -introducer.furl = {furl} +introducer.furl = %(furl)s shares.needed = 2 shares.happy = 3 shares.total = 4 -'''.format(name=name, node_id=node_id, furl=furl, magic_dir=magic_dir)) +''' % {'name':name, 'node_id':node_id, 'furl':furl}) subprocess.check_call( [ tahoe_bin, 'start', data_dir, @@ -206,7 +206,7 @@ if do_invites: if True: for name in ['alice', 'bob']: with open(join(data_base, name, 'private', 'magic_folder_dircap'), 'r') as f: - print("dircap {}: {}".format(name, f.read().strip())) + print("dircap %s: %s" % (name, f.read().strip())) # give storage nodes a chance to connect properly? I'm not entirely # sure what's up here, but I get "UnrecoverableFileError" on the @@ -354,7 +354,7 @@ if True: print(" file contents still mismatched: %d bytes:\n" % (len(content),)) print(content) else: - print(" {} not there yet".format(alice_foo)) + print(" %r not there yet" % (alice_foo,)) time.sleep(1) # XXX test .backup (delete a file) diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index 081e24cb..2d60a93e 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -270,7 +270,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual # ensure we still have a DB entry, and that the version is 1 node, metadata = yield self.magicfolder.downloader._get_collective_latest_file(u'foo') - self.assertTrue(node is not None, "Failed to find '{}' in DMD".format(path)) + self.assertTrue(node is not None, "Failed to find %r in DMD" % (path,)) self.failUnlessEqual(metadata['version'], 1) finally: @@ -305,7 +305,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual # ensure we still have a DB entry, and that the version is 1 node, metadata = yield self.magicfolder.downloader._get_collective_latest_file(u'foo') - self.assertTrue(node is not None, "Failed to find '{}' in DMD".format(path)) + self.assertTrue(node is not None, "Failed to find %r in DMD" % (path,)) self.failUnlessEqual(metadata['version'], 1) # restore the file, with different contents @@ -318,7 +318,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual # ensure we still have a DB entry, and that the version is 2 node, metadata = yield self.magicfolder.downloader._get_collective_latest_file(u'foo') - self.assertTrue(node is not None, "Failed to find '{}' in DMD".format(path)) + self.assertTrue(node is not None, "Failed to find %r in DMD" % (path,)) self.failUnlessEqual(metadata['version'], 2) finally: