From 5a40bf47f4b0a81cd695d99ce3523661ba7f44ca Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 11 Sep 2020 10:28:22 -0400 Subject: [PATCH 1/2] Convert print statements to print functions, even when commented. Fixes #3408. --- misc/build_helpers/gen-package-table.py | 4 +- .../provisioning/reliability.py | 34 +++++------ .../provisioning/test_provisioning.py | 3 +- misc/simulators/bench_spans.py | 2 +- misc/simulators/count_dirs.py | 6 +- misc/simulators/hashbasedsig.py | 6 +- misc/simulators/ringsim.py | 10 ++-- misc/simulators/simulate_load.py | 2 +- misc/simulators/sizes.py | 6 +- src/allmydata/immutable/downloader/fetcher.py | 3 +- src/allmydata/immutable/happiness_upload.py | 10 ++-- src/allmydata/scripts/debug.py | 2 +- src/allmydata/scripts/tahoe_cp.py | 2 +- src/allmydata/scripts/tahoe_manifest.py | 2 +- src/allmydata/test/check_memory.py | 14 ++--- src/allmydata/test/cli/test_check.py | 2 +- src/allmydata/test/cli/test_cp.py | 4 +- src/allmydata/test/mutable/test_update.py | 2 +- src/allmydata/test/test_backupdb.py | 6 +- src/allmydata/test/test_checker.py | 2 +- src/allmydata/test/test_deferredutil.py | 2 +- src/allmydata/test/test_happiness.py | 4 +- src/allmydata/test/test_hashtree.py | 2 +- src/allmydata/test/test_immutable.py | 6 +- src/allmydata/test/test_pipeline.py | 4 +- src/allmydata/test/test_repairer.py | 2 +- src/allmydata/test/test_spans.py | 40 ++++++------- src/allmydata/test/test_system.py | 8 +-- src/allmydata/test/test_upload.py | 2 +- src/allmydata/test/web/test_grid.py | 2 +- src/allmydata/test/web/test_web.py | 2 +- src/allmydata/util/spans.py | 56 +++++++++---------- 32 files changed, 129 insertions(+), 123 deletions(-) diff --git a/misc/build_helpers/gen-package-table.py b/misc/build_helpers/gen-package-table.py index a1190820d..ebcfd1ecd 100644 --- a/misc/build_helpers/gen-package-table.py +++ b/misc/build_helpers/gen-package-table.py @@ -156,6 +156,6 @@ for pkg in sorted(platform_independent_pkgs): print('') # The document does validate, but not when it is included at the bottom of a directory listing. -#print '
' -#print 'Valid HTML 4.01 Transitional' +#print('
') +#print('Valid HTML 4.01 Transitional') print('') diff --git a/misc/operations_helpers/provisioning/reliability.py b/misc/operations_helpers/provisioning/reliability.py index dc241b9d1..fe274c875 100644 --- a/misc/operations_helpers/provisioning/reliability.py +++ b/misc/operations_helpers/provisioning/reliability.py @@ -1,5 +1,7 @@ #! /usr/bin/python +from __future__ import print_function + import math from allmydata.util import statistics from numpy import array, matrix, dot @@ -72,11 +74,11 @@ class ReliabilityModel(object): repair = self.build_repair_matrix(k, N, R) - #print "DECAY:", decay - #print "OLD-POST-REPAIR:", old_post_repair - #print "NEW-POST-REPAIR:", decay * repair - #print "REPAIR:", repair - #print "DIFF:", (old_post_repair - decay * repair) + #print("DECAY:", decay) + #print("OLD-POST-REPAIR:", old_post_repair) + #print("NEW-POST-REPAIR:", decay * repair) + #print("REPAIR:", repair) + #print("DIFF:", (old_post_repair - decay * repair)) START = array([0]*N + [1]) DEAD = array([1]*k + [0]*(1+N-k)) @@ -85,9 +87,9 @@ class ReliabilityModel(object): [N-i for i in range(k, R)] + [0]*(1+N-R)) assert REPAIR_newshares.shape[0] == N+1 - #print "START", START - #print "REPAIRp", REPAIRp - #print "REPAIR_newshares", REPAIR_newshares + #print("START", START) + #print("REPAIRp", REPAIRp) + #print("REPAIR_newshares", REPAIR_newshares) unmaintained_state = START maintained_state = START @@ -141,15 +143,15 @@ class ReliabilityModel(object): # return "%dy.%dm" % (int(seconds/YEAR), int( (seconds%YEAR)/MONTH)) #needed_repairs_total = sum(needed_repairs) #needed_new_shares_total = sum(needed_new_shares) - #print "at 2y:" - #print " unmaintained", unmaintained_state - #print " maintained", maintained_state - #print " number of repairs", needed_repairs_total - #print " new shares generated", needed_new_shares_total + #print("at 2y:") + #print(" unmaintained", unmaintained_state) + #print(" maintained", maintained_state) + #print(" number of repairs", needed_repairs_total) + #print(" new shares generated", needed_new_shares_total) #repair_rate_inv = report_span / needed_repairs_total - #print " avg repair rate: once every %s" % yandm(repair_rate_inv) - #print " avg repair download: one share every %s" % yandm(repair_rate_inv/k) - #print " avg repair upload: one share every %s" % yandm(report_span / needed_new_shares_total) + #print(" avg repair rate: once every %s" % yandm(repair_rate_inv)) + #print(" avg repair download: one share every %s" % yandm(repair_rate_inv/k)) + #print(" avg repair upload: one share every %s" % yandm(report_span / needed_new_shares_total)) return report diff --git a/misc/operations_helpers/provisioning/test_provisioning.py b/misc/operations_helpers/provisioning/test_provisioning.py index 8835b79db..2b71c8566 100644 --- a/misc/operations_helpers/provisioning/test_provisioning.py +++ b/misc/operations_helpers/provisioning/test_provisioning.py @@ -1,3 +1,4 @@ +from __future__ import print_function import unittest from allmydata import provisioning @@ -99,7 +100,7 @@ class Reliability(unittest.TestCase): self.failUnlessEqual(len(r.samples), 20) last_row = r.samples[-1] - #print last_row + #print(last_row) (when, unmaintained_shareprobs, maintained_shareprobs, P_repaired_last_check_period, cumulative_number_of_repairs, diff --git a/misc/simulators/bench_spans.py b/misc/simulators/bench_spans.py index d6dc12d7a..c696dac1e 100644 --- a/misc/simulators/bench_spans.py +++ b/misc/simulators/bench_spans.py @@ -74,7 +74,7 @@ class B(object): count += 1 inline = self.inf.readline() - # print self.stats + # print(self.stats) benchutil.print_bench_footer(UNITS_PER_SECOND=1000000) print("(microseconds)") diff --git a/misc/simulators/count_dirs.py b/misc/simulators/count_dirs.py index 6b52ba96a..22eda8917 100644 --- a/misc/simulators/count_dirs.py +++ b/misc/simulators/count_dirs.py @@ -89,9 +89,9 @@ def scan(root): num_files = 0 num_dirs = 0 for absroot, dirs, files in os.walk(root): - #print absroot - #print " %d files" % len(files) - #print " %d subdirs" % len(dirs) + #print(absroot) + #print(" %d files" % len(files)) + #print(" %d subdirs" % len(dirs)) num_files += len(files) num_dirs += len(dirs) stringsize = len(''.join(files) + ''.join(dirs)) diff --git a/misc/simulators/hashbasedsig.py b/misc/simulators/hashbasedsig.py index 5c135adf6..dc141744f 100644 --- a/misc/simulators/hashbasedsig.py +++ b/misc/simulators/hashbasedsig.py @@ -146,8 +146,8 @@ def calculate(K, K1, K2, q_max, L_hash, trees): lg_q = lg(q_cand) lg_pforge = [lg_px[x] + (lg_q*x - lg_K2)*q_cand for x in xrange(1, j)] if max(lg_pforge) < -L_hash + lg(j) and lg_px[j-1] + 1.0 < -L_hash: - #print "K = %d, K1 = %d, K2 = %d, L_hash = %d, lg_K2 = %.3f, q = %d, lg_pforge_1 = %.3f, lg_pforge_2 = %.3f, lg_pforge_3 = %.3f" \ - # % (K, K1, K2, L_hash, lg_K2, q, lg_pforge_1, lg_pforge_2, lg_pforge_3) + #print("K = %d, K1 = %d, K2 = %d, L_hash = %d, lg_K2 = %.3f, q = %d, lg_pforge_1 = %.3f, lg_pforge_2 = %.3f, lg_pforge_3 = %.3f" + # % (K, K1, K2, L_hash, lg_K2, q, lg_pforge_1, lg_pforge_2, lg_pforge_3)) q = q_cand break @@ -268,7 +268,7 @@ def search(): trees[y] = (h, c_y, (dau, tri)) #for x in xrange(1, K_max+1): - # print x, trees[x] + # print(x, trees[x]) candidates = [] progress = 0 diff --git a/misc/simulators/ringsim.py b/misc/simulators/ringsim.py index 1eec7a466..e6616351c 100644 --- a/misc/simulators/ringsim.py +++ b/misc/simulators/ringsim.py @@ -130,8 +130,8 @@ class Ring(object): # used is actual per-server ciphertext usedpf = [1.0*u/numfiles for u in used] # usedpf is actual per-server-per-file ciphertext - #print "min/max usage: %s/%s" % (abbreviate_space(used[-1]), - # abbreviate_space(used[0])) + #print("min/max usage: %s/%s" % (abbreviate_space(used[-1]), + # abbreviate_space(used[0]))) avg_usage_per_file = avg_space_per_file/len(self.servers) # avg_usage_per_file is expected per-server-per-file ciphertext spreadpf = usedpf[0] - usedpf[-1] @@ -146,7 +146,7 @@ class Ring(object): abbreviate_space(avg_usage_per_file) ), end=' ') print("spread-pf: %s (%.2f%%)" % ( abbreviate_space(spreadpf), 100.0*spreadpf/avg_usage_per_file), end=' ') - #print "average_usage:", abbreviate_space(average_usagepf) + #print("average_usage:", abbreviate_space(average_usagepf)) print("stddev: %s (%.2f%%)" % (abbreviate_space(std_deviation), 100.0*sd_of_total)) if self.SHOW_MINMAX: @@ -176,14 +176,14 @@ def do_run(ring, opts): for filenum in count(0): #used = list(reversed(sorted([s.used for s in ring.servers]))) #used = [s.used for s in ring.servers] - #print used + #print(used) si = myhash(fileseed+str(filenum)).hexdigest() filesize = make_up_a_file_size(si) sharesize = filesize / opts["k"] if filenum%4000==0 and filenum > 1: ring.dump_usage(filenum, avg_space_per_file) servers = ring.servers_for_si(si) - #print ring.show_servers(servers[:opts["N"]]) + #print(ring.show_servers(servers[:opts["N"]])) remaining_shares = opts["N"] index = 0 server_was_full = False diff --git a/misc/simulators/simulate_load.py b/misc/simulators/simulate_load.py index f522a6d93..945d96990 100644 --- a/misc/simulators/simulate_load.py +++ b/misc/simulators/simulate_load.py @@ -59,7 +59,7 @@ def go(permutedpeerlist): server.full_at_tick = tick fullservers += 1 if fullservers == len(servers): - # print "Couldn't place share -- all servers full. Stopping." + # print("Couldn't place share -- all servers full. Stopping.") return (servers, doubled_up_shares) i += 1 diff --git a/misc/simulators/sizes.py b/misc/simulators/sizes.py index b55c664a5..1719700fa 100644 --- a/misc/simulators/sizes.py +++ b/misc/simulators/sizes.py @@ -96,9 +96,9 @@ class Sizes(object): # means storing (and eventually transmitting) more hashes. This # count includes all the low-level share hashes and the root. hash_nodes = (num_leaves*k - 1) / (k - 1) - #print "hash_depth", d - #print "num_leaves", num_leaves - #print "hash_nodes", hash_nodes + #print("hash_depth", d) + #print("num_leaves", num_leaves) + #print("hash_nodes", hash_nodes) # the storage overhead is this self.share_storage_overhead = 32 * (hash_nodes - 1) # the transmission overhead is smaller: if we actually transmit diff --git a/src/allmydata/immutable/downloader/fetcher.py b/src/allmydata/immutable/downloader/fetcher.py index a747fda6c..349c40e96 100644 --- a/src/allmydata/immutable/downloader/fetcher.py +++ b/src/allmydata/immutable/downloader/fetcher.py @@ -1,3 +1,4 @@ +from __future__ import print_function from twisted.python.failure import Failure from foolscap.api import eventually @@ -100,7 +101,7 @@ class SegmentFetcher(object): self._node.fetch_failed(self, f) return - #print "LOOP", self._blocks.keys(), "active:", self._active_share_map, "overdue:", self._overdue_share_map, "unused:", self._shares + #print("LOOP", self._blocks.keys(), "active:", self._active_share_map, "overdue:", self._overdue_share_map, "unused:", self._shares) # Should we sent out more requests? while len(set(self._blocks.keys()) | set(self._active_share_map.keys()) diff --git a/src/allmydata/immutable/happiness_upload.py b/src/allmydata/immutable/happiness_upload.py index 9716aaef2..3e3eedbc9 100644 --- a/src/allmydata/immutable/happiness_upload.py +++ b/src/allmydata/immutable/happiness_upload.py @@ -198,7 +198,7 @@ def _distribute_homeless_shares(mappings, homeless_shares, peers_to_shares): available peers. If possible a share will be placed on the server it was originally on, signifying the lease should be renewed instead. """ - #print "mappings, homeless_shares, peers_to_shares %s %s %s" % (mappings, homeless_shares, peers_to_shares) + #print("mappings, homeless_shares, peers_to_shares %s %s %s" % (mappings, homeless_shares, peers_to_shares)) servermap_peerids = set([key for key in peers_to_shares]) servermap_shareids = set() for key in sorted(peers_to_shares.keys()): @@ -272,8 +272,8 @@ def _servermap_flow_graph(peers, shares, servermap): indexedShares = [] sink_num = len(peers) + len(shares) + 1 graph.append([peer_to_index[peer] for peer in peers]) - #print "share_to_index %s" % share_to_index - #print "servermap %s" % servermap + #print("share_to_index %s" % share_to_index) + #print("servermap %s" % servermap) for peer in peers: if peer in servermap: for s in servermap[peer]: @@ -386,8 +386,8 @@ def share_placement(peers, readonly_peers, shares, peers_to_shares): new_shares = new_shares - existing_shares - used_shares new_mappings = _calculate_mappings(new_peers, new_shares) - #print "new_peers %s" % new_peers - #print "new_mappings %s" % new_mappings + #print("new_peers %s" % new_peers) + #print("new_mappings %s" % new_mappings) mappings = dict(list(readonly_mappings.items()) + list(existing_mappings.items()) + list(new_mappings.items())) homeless_shares = set() for share in mappings: diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py index 789218f8b..e6d332444 100644 --- a/src/allmydata/scripts/debug.py +++ b/src/allmydata/scripts/debug.py @@ -346,7 +346,7 @@ def dump_MDMF_share(m, length, options): print(" MDMF contents:", file=out) print(" seqnum: %d" % seqnum, file=out) print(" root_hash: %s" % base32.b2a(root_hash), file=out) - #print >>out, " IV: %s" % base32.b2a(IV) + #print(" IV: %s" % base32.b2a(IV), file=out) print(" required_shares: %d" % k, file=out) print(" total_shares: %d" % N, file=out) print(" segsize: %d" % segsize, file=out) diff --git a/src/allmydata/scripts/tahoe_cp.py b/src/allmydata/scripts/tahoe_cp.py index c90dca072..f7879f35c 100644 --- a/src/allmydata/scripts/tahoe_cp.py +++ b/src/allmydata/scripts/tahoe_cp.py @@ -858,7 +858,7 @@ class Copier(object): def progress(self, message): - #print message + #print(message) if self.progressfunc: self.progressfunc(message) diff --git a/src/allmydata/scripts/tahoe_manifest.py b/src/allmydata/scripts/tahoe_manifest.py index b1daa7717..032c65d51 100644 --- a/src/allmydata/scripts/tahoe_manifest.py +++ b/src/allmydata/scripts/tahoe_manifest.py @@ -44,7 +44,7 @@ class ManifestStreamer(LineOnlyReceiver, object): if resp.status not in (200, 302): print(format_http_error("ERROR", resp), file=stderr) return 1 - #print "RESP", dir(resp) + #print("RESP", dir(resp)) # use Twisted to split this into lines self.in_error = False while True: diff --git a/src/allmydata/test/check_memory.py b/src/allmydata/test/check_memory.py index e12ed3d54..ede112df1 100644 --- a/src/allmydata/test/check_memory.py +++ b/src/allmydata/test/check_memory.py @@ -115,21 +115,21 @@ class SystemFramework(pollmixin.PollMixin): self.failed.raiseException() def setUp(self): - #print "STARTING" + #print("STARTING") self.stats = {} self.statsfile = open(os.path.join(self.basedir, "stats.out"), "a") self.make_introducer() d = self.start_client() def _record_control_furl(control_furl): self.control_furl = control_furl - #print "OBTAINING '%s'" % (control_furl,) + #print("OBTAINING '%s'" % (control_furl,)) return self.tub.getReference(self.control_furl) d.addCallback(_record_control_furl) def _record_control(control_rref): self.control_rref = control_rref d.addCallback(_record_control) def _ready(res): - #print "CLIENT READY" + #print("CLIENT READY") pass d.addCallback(_ready) return d @@ -430,10 +430,10 @@ this file are ignored. return d def do_test(self): - #print "CLIENT STARTED" - #print "FURL", self.control_furl - #print "RREF", self.control_rref - #print + #print("CLIENT STARTED") + #print("FURL", self.control_furl) + #print("RREF", self.control_rref) + #print() kB = 1000; MB = 1000*1000 files = {} uris = {} diff --git a/src/allmydata/test/cli/test_check.py b/src/allmydata/test/cli/test_check.py index 85649e262..8cf963da6 100644 --- a/src/allmydata/test/cli/test_check.py +++ b/src/allmydata/test/cli/test_check.py @@ -362,7 +362,7 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase): # self.do_cli("deep-check", "--repair", self.rooturi)) #def _deep_check_repair_failed((rc, out, err)): # self.failIfEqual(rc, 0) - # print err + # print(err) # self.failUnlessIn("ERROR: UnrecoverableFileError", err) # self.failIf("done:" in out, out) #d.addCallback(_deep_check_repair_failed) diff --git a/src/allmydata/test/cli/test_cp.py b/src/allmydata/test/cli/test_cp.py index 59331029b..ba1894f1c 100644 --- a/src/allmydata/test/cli/test_cp.py +++ b/src/allmydata/test/cli/test_cp.py @@ -983,7 +983,7 @@ class CopyOut(GridTestMixin, CLITestMixin, unittest.TestCase): def do_one_test(self, case, orig_expected): expected = set(orig_expected) printable_expected = ",".join(sorted(expected)) - #print "---", case, ":", printable_expected + #print("---", case, ":", printable_expected) for f in orig_expected: # f is "dir/file" or "dir/sub/file" or "dir/" or "dir/sub/" @@ -1010,7 +1010,7 @@ class CopyOut(GridTestMixin, CLITestMixin, unittest.TestCase): # then we run various forms of "cp [-r] TAHOETHING to[/missing]" # and see what happens. d = defer.succeed(None) - #print + #print() for line in COPYOUT_TESTCASES.splitlines(): if "#" in line: diff --git a/src/allmydata/test/mutable/test_update.py b/src/allmydata/test/mutable/test_update.py index f03f7d226..971273a80 100644 --- a/src/allmydata/test/mutable/test_update.py +++ b/src/allmydata/test/mutable/test_update.py @@ -108,7 +108,7 @@ class Update(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin): for (start,end) in gotmods] expspans = ["%d:%d=%s" % (start,end,expected[start:end]) for (start,end) in expmods] - #print "expecting: %s" % expspans + #print("expecting: %s" % expspans) if got != expected: print("differences:") diff --git a/src/allmydata/test/test_backupdb.py b/src/allmydata/test/test_backupdb.py index 858640d62..04b264d39 100644 --- a/src/allmydata/test/test_backupdb.py +++ b/src/allmydata/test/test_backupdb.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import sys import os.path, time from six.moves import cStringIO as StringIO @@ -229,7 +231,7 @@ class BackupDB(unittest.TestCase): files = [fn for fn in listdir_unicode(unicode(basedir)) if fn.endswith(".txt")] self.failUnlessEqual(len(files), 1) foo_fn = os.path.join(basedir, files[0]) - #print foo_fn, type(foo_fn) + #print(foo_fn, type(foo_fn)) r = bdb.check_file(foo_fn) self.failUnlessEqual(r.was_uploaded(), False) @@ -240,7 +242,7 @@ class BackupDB(unittest.TestCase): self.failUnlessEqual(r.should_check(), False) bar_fn = self.writeto(u"b\u00e5r.txt", "bar.txt") - #print bar_fn, type(bar_fn) + #print(bar_fn, type(bar_fn)) r = bdb.check_file(bar_fn) self.failUnlessEqual(r.was_uploaded(), False) diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index 2296194f0..882356aeb 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -691,7 +691,7 @@ class BalancingAct(GridTestMixin, unittest.TestCase): def add_three(_, i): # Add a new server with just share 3 self.add_server_with_share(i, self.uri, 3) - #print self._pretty_shares_chart(self.uri) + #print(self._pretty_shares_chart(self.uri)) for i in range(1,5): d.addCallback(add_three, i) diff --git a/src/allmydata/test/test_deferredutil.py b/src/allmydata/test/test_deferredutil.py index d8f386e5f..6ebc93556 100644 --- a/src/allmydata/test/test_deferredutil.py +++ b/src/allmydata/test/test_deferredutil.py @@ -67,7 +67,7 @@ class DeferredUtilTests(unittest.TestCase, deferredutil.WaitForDelayedCallsMixin Trial would report an unclean reactor error for this test. """ def _trigger(): - #print "trigger" + #print("trigger") pass reactor.callLater(0.1, _trigger) diff --git a/src/allmydata/test/test_happiness.py b/src/allmydata/test/test_happiness.py index bf73ca2d8..021b75d33 100644 --- a/src/allmydata/test/test_happiness.py +++ b/src/allmydata/test/test_happiness.py @@ -182,9 +182,9 @@ class Happiness(unittest.TestCase): # we can achieve more happiness by moving "2" or "3" to server "d" places = happiness_upload.share_placement(peers, readonly_peers, shares, peers_to_shares) - #print "places %s" % places + #print("places %s" % places) #places = happiness_upload.slow_share_placement(peers, readonly_peers, shares, peers_to_shares) - #print "places %s" % places + #print("places %s" % places) happiness = happiness_upload.calculate_happiness(places) self.assertEqual(4, happiness) diff --git a/src/allmydata/test/test_hashtree.py b/src/allmydata/test/test_hashtree.py index d1d4cb252..5abe2095e 100644 --- a/src/allmydata/test/test_hashtree.py +++ b/src/allmydata/test/test_hashtree.py @@ -57,7 +57,7 @@ class Complete(unittest.TestCase): ] self.failUnlessEqual(list(ht.depth_first()), expected) d = "\n" + ht.dump() - #print d + #print(d) self.failUnless("\n 0:" in d) self.failUnless("\n 1:" in d) self.failUnless("\n 3:" in d) diff --git a/src/allmydata/test/test_immutable.py b/src/allmydata/test/test_immutable.py index 0c7a15199..867d3a725 100644 --- a/src/allmydata/test/test_immutable.py +++ b/src/allmydata/test/test_immutable.py @@ -224,7 +224,7 @@ class Test(GridTestMixin, unittest.TestCase, common.ShouldFailMixin): d.addCallback(self._download_and_check_plaintext) def _after_download(ign): num_reads = self._count_reads() - #print num_reads + #print(num_reads) self.failIf(num_reads > 41, num_reads) d.addCallback(_after_download) return d @@ -237,7 +237,7 @@ class Test(GridTestMixin, unittest.TestCase, common.ShouldFailMixin): self.delete_shares_numbered(self.uri, range(7))) d.addCallback(self._download_and_check_plaintext) def _after_download(num_reads): - #print num_reads + #print(num_reads) self.failIf(num_reads > 41, num_reads) d.addCallback(_after_download) return d @@ -284,7 +284,7 @@ class Test(GridTestMixin, unittest.TestCase, common.ShouldFailMixin): download_to_data, self.filenode) def _check_numreads(ign): num_reads = self._count_reads() - start_reads - #print num_reads + #print(num_reads) # To pass this test, you are required to give up before # reading all of the share data. Actually, we could give up diff --git a/src/allmydata/test/test_pipeline.py b/src/allmydata/test/test_pipeline.py index 1295be363..31d952836 100644 --- a/src/allmydata/test/test_pipeline.py +++ b/src/allmydata/test/test_pipeline.py @@ -29,8 +29,8 @@ class Pipeline(unittest.TestCase): return d def failUnlessCallsAre(self, expected): - #print self.calls - #print expected + #print(self.calls) + #print(expected) self.failUnlessEqual(len(self.calls), len(expected), self.calls) for i,c in enumerate(self.calls): self.failUnlessEqual(c[1:], expected[i], str(i)) diff --git a/src/allmydata/test/test_repairer.py b/src/allmydata/test/test_repairer.py index ec521fe96..4fdffe70e 100644 --- a/src/allmydata/test/test_repairer.py +++ b/src/allmydata/test/test_repairer.py @@ -335,7 +335,7 @@ class Verifier(GridTestMixin, unittest.TestCase, RepairTestMixin): self.corrupt_shares_numbered(self.uri, [0], _corruptor) results = {} def _did_check(vr, i): - #print "corrupt %d: healthy=%s" % (i, vr.is_healthy()) + #print("corrupt %d: healthy=%s" % (i, vr.is_healthy())) results[i] = vr.is_healthy() def _start(ign): d = defer.succeed(None) diff --git a/src/allmydata/test/test_spans.py b/src/allmydata/test/test_spans.py index 02d8292f3..281f916c4 100644 --- a/src/allmydata/test/test_spans.py +++ b/src/allmydata/test/test_spans.py @@ -246,14 +246,14 @@ class ByteSpans(unittest.TestCase): ns1.add(start, length); ns2.add(start, length) return ns1, ns2 - #print + #print() for i in range(1000): what = sha256(seed+bytes(i)) op = what[0:1] subop = what[1:2] start = int(what[2:4], 16) length = max(1,int(what[5:6], 16)) - #print what + #print(what) if op in b"0": if subop in b"01234": s1 = S1(); s2 = S2() @@ -261,34 +261,34 @@ class ByteSpans(unittest.TestCase): s1 = S1(start, length); s2 = S2(start, length) else: s1 = S1(s1); s2 = S2(s2) - #print "s2 = %s" % s2.dump() + #print("s2 = %s" % s2.dump()) elif op in b"123": - #print "s2.add(%d,%d)" % (start, length) + #print("s2.add(%d,%d)" % (start, length)) s1.add(start, length); s2.add(start, length) elif op in b"456": - #print "s2.remove(%d,%d)" % (start, length) + #print("s2.remove(%d,%d)" % (start, length)) s1.remove(start, length); s2.remove(start, length) elif op in b"78": ns1, ns2 = _create(what[7:11]) - #print "s2 + %s" % ns2.dump() + #print("s2 + %s" % ns2.dump()) s1 = s1 + ns1; s2 = s2 + ns2 elif op in b"9a": ns1, ns2 = _create(what[7:11]) - #print "%s - %s" % (s2.dump(), ns2.dump()) + #print("%s - %s" % (s2.dump(), ns2.dump())) s1 = s1 - ns1; s2 = s2 - ns2 elif op in b"bc": ns1, ns2 = _create(what[7:11]) - #print "s2 += %s" % ns2.dump() + #print("s2 += %s" % ns2.dump()) s1 += ns1; s2 += ns2 elif op in b"de": ns1, ns2 = _create(what[7:11]) - #print "%s -= %s" % (s2.dump(), ns2.dump()) + #print("%s -= %s" % (s2.dump(), ns2.dump())) s1 -= ns1; s2 -= ns2 else: ns1, ns2 = _create(what[7:11]) - #print "%s &= %s" % (s2.dump(), ns2.dump()) + #print("%s &= %s" % (s2.dump(), ns2.dump())) s1 = s1 & ns1; s2 = s2 & ns2 - #print "s2 now %s" % s2.dump() + #print("s2 now %s" % s2.dump()) self.failUnlessEqual(list(s1.each()), list(s2.each())) self.failUnlessEqual(s1.len(), s2.len()) self.failUnlessEqual(bool(s1), bool(s2)) @@ -324,7 +324,7 @@ class ByteSpans(unittest.TestCase): def _test_overlap(self, a, b, c, d): s1 = set(range(a,a+b)) s2 = set(range(c,c+d)) - #print "---" + #print("---") #self._show_overlap(s1, "1") #self._show_overlap(s2, "2") o = overlap(a,b,c,d) @@ -580,33 +580,33 @@ class StringSpans(unittest.TestCase): ns2.add(start, _randstr(length, what[7:9])) return ns1, ns2 - #print + #print() for i in range(1000): what = sha256(seed+bytes(i)) op = what[0:1] subop = what[1:2] start = int(what[2:4], 16) length = max(1,int(what[5:6], 16)) - #print what + #print(what) if op in b"0": if subop in b"0123456": s1 = S1(); s2 = S2() else: s1, s2 = _create(what[7:11]) - #print "s2 = %s" % list(s2._dump()) + #print("s2 = %s" % list(s2._dump())) elif op in b"123456": - #print "s2.add(%d,%d)" % (start, length) + #print("s2.add(%d,%d)" % (start, length)) s1.add(start, _randstr(length, what[7:9])); s2.add(start, _randstr(length, what[7:9])) elif op in b"789abc": - #print "s2.remove(%d,%d)" % (start, length) + #print("s2.remove(%d,%d)" % (start, length)) s1.remove(start, length); s2.remove(start, length) else: - #print "s2.pop(%d,%d)" % (start, length) + #print("s2.pop(%d,%d)" % (start, length)) d1 = s1.pop(start, length); d2 = s2.pop(start, length) self.failUnlessEqual(d1, d2) - #print "s1 now %s" % list(s1._dump()) - #print "s2 now %s" % list(s2._dump()) + #print("s1 now %s" % list(s1._dump())) + #print("s2 now %s" % list(s2._dump())) self.failUnlessEqual(s1.len(), s2.len()) self.failUnlessEqual(list(s1._dump()), list(s2._dump())) for j in range(100): diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 96fdfaba7..cc1ee21bb 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1308,7 +1308,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): d = self.clients[1].tub.getReference(sp_furl) d.addCallback(lambda sp_rref: sp_rref.callRemote("get_stats")) def _got_stats(stats): - #print "STATS" + #print("STATS") #from pprint import pprint #pprint(stats) s = stats["stats"] @@ -1748,7 +1748,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): return d def log(self, res, *args, **kwargs): - # print "MSG: %s RES: %s" % (msg, args) + # print("MSG: %s RES: %s" % (msg, args)) log.msg(*args, **kwargs) return res @@ -2647,8 +2647,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): ## return self._run_cli(argv) ## d.addCallback(_ls_missing) ## def _check_ls_missing((out,err)): -## print "OUT", out -## print "ERR", err +## print("OUT", out) +## print("ERR", err) ## self.failUnlessEqual(err, "") ## d.addCallback(_check_ls_missing) diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index 2ec426722..6f35d57d3 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -130,7 +130,7 @@ class FakeStorageServer(object): def allocate_buckets(self, storage_index, renew_secret, cancel_secret, sharenums, share_size, canary): - # print "FakeStorageServer.allocate_buckets(num=%d, size=%d, mode=%s, queries=%d)" % (len(sharenums), share_size, self.mode, self._alloc_queries) + # print("FakeStorageServer.allocate_buckets(num=%d, size=%d, mode=%s, queries=%d)" % (len(sharenums), share_size, self.mode, self._alloc_queries)) if self.mode == "timeout": return defer.Deferred() if self.mode == "first-fail": diff --git a/src/allmydata/test/web/test_grid.py b/src/allmydata/test/web/test_grid.py index 2a52d98e5..01eb93fa7 100644 --- a/src/allmydata/test/web/test_grid.py +++ b/src/allmydata/test/web/test_grid.py @@ -260,7 +260,7 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi # #d.addCallback(self.CHECK, "dead", "t=check&repair=true") #def _got_html_dead(res): - # print res + # print(res) # self.failUnlessIn("Healthy : healthy", res) # self.failIfIn("Not Healthy", res) # self.failUnlessIn("No repair necessary", res) diff --git a/src/allmydata/test/web/test_web.py b/src/allmydata/test/web/test_web.py index 0dc12a4c5..11c5a8c5c 100644 --- a/src/allmydata/test/web/test_web.py +++ b/src/allmydata/test/web/test_web.py @@ -4310,7 +4310,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi ) def log(self, res, msg): - #print "MSG: %s RES: %s" % (msg, res) + #print("MSG: %s RES: %s" % (msg, res)) log.msg(msg) return res diff --git a/src/allmydata/util/spans.py b/src/allmydata/util/spans.py index b224f0950..81e14c0fb 100644 --- a/src/allmydata/util/spans.py +++ b/src/allmydata/util/spans.py @@ -55,10 +55,10 @@ class Spans(object): def add(self, start, length): assert start >= 0 assert length > 0 - #print " ADD [%d+%d -%d) to %s" % (start, length, start+length, self.dump()) + #print(" ADD [%d+%d -%d) to %s" % (start, length, start+length, self.dump())) first_overlap = last_overlap = None for i,(s_start,s_length) in enumerate(self._spans): - #print " (%d+%d)-> overlap=%s adjacent=%s" % (s_start,s_length, overlap(s_start, s_length, start, length), adjacent(s_start, s_length, start, length)) + #print(" (%d+%d)-> overlap=%s adjacent=%s" % (s_start,s_length, overlap(s_start, s_length, start, length), adjacent(s_start, s_length, start, length))) if (overlap(s_start, s_length, start, length) or adjacent(s_start, s_length, start, length)): last_overlap = i @@ -68,7 +68,7 @@ class Spans(object): # no overlap if first_overlap is not None: break - #print " first_overlap", first_overlap, last_overlap + #print(" first_overlap", first_overlap, last_overlap) if first_overlap is None: # no overlap, so just insert the span and sort by starting # position. @@ -83,7 +83,7 @@ class Spans(object): newspan_length = newspan_end - newspan_start newspan = (newspan_start, newspan_length) self._spans[first_overlap:last_overlap+1] = [newspan] - #print " ADD done: %s" % self.dump() + #print(" ADD done: %s" % self.dump()) self._check() return self @@ -91,7 +91,7 @@ class Spans(object): def remove(self, start, length): assert start >= 0 assert length > 0 - #print " REMOVE [%d+%d -%d) from %s" % (start, length, start+length, self.dump()) + #print(" REMOVE [%d+%d -%d) from %s" % (start, length, start+length, self.dump())) first_complete_overlap = last_complete_overlap = None for i,(s_start,s_length) in enumerate(self._spans): s_end = s_start + s_length @@ -144,7 +144,7 @@ class Spans(object): break if first_complete_overlap is not None: del self._spans[first_complete_overlap:last_complete_overlap+1] - #print " REMOVE done: %s" % self.dump() + #print(" REMOVE done: %s" % self.dump()) self._check() return self @@ -282,26 +282,26 @@ class DataSpans(object): def get(self, start, length): # returns a string of LENGTH, or None - #print "get", start, length, self.spans + #print("get", start, length, self.spans) end = start+length for (s_start,s_data) in self.spans: s_end = s_start+len(s_data) - #print " ",s_start,s_end + #print(" ",s_start,s_end) if s_start <= start < s_end: # we want some data from this span. Because we maintain # strictly merged and non-overlapping spans, everything we # want must be in this span. offset = start - s_start if offset + length > len(s_data): - #print " None, span falls short" + #print(" None, span falls short") return None # span falls short - #print " some", s_data[offset:offset+length] + #print(" some", s_data[offset:offset+length]) return s_data[offset:offset+length] if s_start >= end: # we've gone too far: no further spans will overlap - #print " None, gone too far" + #print(" None, gone too far") return None - #print " None, ran out of spans" + #print(" None, ran out of spans") return None def add(self, start, data): @@ -310,13 +310,13 @@ class DataSpans(object): # add new spans # sort # merge adjacent spans - #print "add", start, data, self.spans + #print("add", start, data, self.spans) end = start + len(data) i = 0 while len(data): - #print " loop", start, data, i, len(self.spans), self.spans + #print(" loop", start, data, i, len(self.spans), self.spans) if i >= len(self.spans): - #print " append and done" + #print(" append and done") # append a last span self.spans.append( (start, data) ) break @@ -333,7 +333,7 @@ class DataSpans(object): # A). We handle E by replacing the middle and terminating. if start < s_start: # case A: insert a new span, then loop with the remainder - #print " insert new span" + #print(" insert new span") s_len = s_start-start self.spans.insert(i, (start, data[:s_len])) i += 1 @@ -343,12 +343,12 @@ class DataSpans(object): s_len = len(s_data) s_end = s_start+s_len if s_start <= start < s_end: - #print " modify this span", s_start, start, s_end + #print(" modify this span", s_start, start, s_end) # we want to modify some data in this span: a prefix, a # suffix, or the whole thing if s_start == start: if s_end <= end: - #print " replace whole segment" + #print(" replace whole segment") # case C: replace this segment self.spans[i] = (s_start, data[:s_len]) i += 1 @@ -357,36 +357,36 @@ class DataSpans(object): # C2 is where len(data)>0 continue # case B: modify the prefix, retain the suffix - #print " modify prefix" + #print(" modify prefix") self.spans[i] = (s_start, data + s_data[len(data):]) break if start > s_start and end < s_end: # case E: modify the middle - #print " modify middle" + #print(" modify middle") prefix_len = start - s_start # we retain this much suffix_len = s_end - end # and retain this much newdata = s_data[:prefix_len] + data + s_data[-suffix_len:] self.spans[i] = (s_start, newdata) break # case D: retain the prefix, modify the suffix - #print " modify suffix" + #print(" modify suffix") prefix_len = start - s_start # we retain this much suffix_len = s_len - prefix_len # we replace this much - #print " ", s_data, prefix_len, suffix_len, s_len, data + #print(" ", s_data, prefix_len, suffix_len, s_len, data) self.spans[i] = (s_start, s_data[:prefix_len] + data[:suffix_len]) i += 1 start += suffix_len data = data[suffix_len:] - #print " now", start, data + #print(" now", start, data) # D2 is where len(data)>0 continue # else we're not there yet - #print " still looking" + #print(" still looking") i += 1 continue # now merge adjacent spans - #print " merging", self.spans + #print(" merging", self.spans) newspans = [] for (s_start,s_data) in self.spans: if newspans and adjacent(newspans[-1][0], len(newspans[-1][1]), @@ -396,12 +396,12 @@ class DataSpans(object): newspans.append( (s_start, s_data) ) self.spans = newspans self.assert_invariants() - #print " done", self.spans + #print(" done", self.spans) def remove(self, start, length): i = 0 end = start + length - #print "remove", start, length, self.spans + #print("remove", start, length, self.spans) while i < len(self.spans): (s_start,s_data) = self.spans[i] if s_start >= end: @@ -441,7 +441,7 @@ class DataSpans(object): self.spans[i] = (s_start, left) self.spans.insert(i+1, (o_end, right)) break - #print " done", self.spans + #print(" done", self.spans) def pop(self, start, length): data = self.get(start, length) From a7034de8523e0001f51ba53abfa60a780773be28 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 11 Sep 2020 13:31:37 -0400 Subject: [PATCH 2/2] Add empty newsfragment. --- newsfragments/3408.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3408.minor diff --git a/newsfragments/3408.minor b/newsfragments/3408.minor new file mode 100644 index 000000000..e69de29bb