diff options
-rwxr-xr-x | contrib/scripts/gnunet-chk.py.in | 14 | ||||
-rw-r--r-- | contrib/scripts/gnunet_pyexpect.py.in | 1 | ||||
-rw-r--r-- | contrib/scripts/pydiffer.py.in | 3 | ||||
-rw-r--r-- | contrib/scripts/terminate.py.in | 1 | ||||
-rw-r--r-- | src/consensus/consensus-simulation.py.in | 18 | ||||
-rwxr-xr-x | src/fs/test_gnunet_fs_psd.py.in | 1 | ||||
-rw-r--r-- | src/revocation/test_local_revocation.py.in | 1 | ||||
-rwxr-xr-x | src/util/gnunet-qr.py.in | 4 |
8 files changed, 30 insertions, 13 deletions
diff --git a/contrib/scripts/gnunet-chk.py.in b/contrib/scripts/gnunet-chk.py.in index c60211556..1f5a0726c 100755 --- a/contrib/scripts/gnunet-chk.py.in +++ b/contrib/scripts/gnunet-chk.py.in | |||
@@ -21,6 +21,12 @@ | |||
21 | # Brief: Computes GNUNET style Content Hash Key for a given file | 21 | # Brief: Computes GNUNET style Content Hash Key for a given file |
22 | # Author: Sree Harsha Totakura | 22 | # Author: Sree Harsha Totakura |
23 | 23 | ||
24 | from __future__ import print_function | ||
25 | from __future__ import division | ||
26 | from builtins import str | ||
27 | from builtins import range | ||
28 | from past.utils import old_div | ||
29 | from builtins import object | ||
24 | from hashlib import sha512 | 30 | from hashlib import sha512 |
25 | import logging | 31 | import logging |
26 | import os | 32 | import os |
@@ -90,7 +96,7 @@ def sha512_hash(data): | |||
90 | return hash_obj.digest() | 96 | return hash_obj.digest() |
91 | 97 | ||
92 | 98 | ||
93 | class AESKey: | 99 | class AESKey(object): |
94 | """Class for AES Keys. Contains the main key and the initialization | 100 | """Class for AES Keys. Contains the main key and the initialization |
95 | vector. """ | 101 | vector. """ |
96 | 102 | ||
@@ -177,7 +183,7 @@ def aes_decrypt(aes_key, data): | |||
177 | return ptext | 183 | return ptext |
178 | 184 | ||
179 | 185 | ||
180 | class Chk: | 186 | class Chk(object): |
181 | """Class for the content hash key.""" | 187 | """Class for the content hash key.""" |
182 | key = None | 188 | key = None |
183 | query = None | 189 | query = None |
@@ -248,7 +254,7 @@ def compute_chk_offset_(depth, end_offset): | |||
248 | bds = compute_tree_size_(depth) | 254 | bds = compute_tree_size_(depth) |
249 | if (depth > 0): | 255 | if (depth > 0): |
250 | end_offset -= 1 | 256 | end_offset -= 1 |
251 | ret = end_offset / bds | 257 | ret = old_div(end_offset, bds) |
252 | return ret % CHK_PER_INODE | 258 | return ret % CHK_PER_INODE |
253 | 259 | ||
254 | 260 | ||
@@ -272,7 +278,7 @@ def compute_iblock_size_(depth, offset): | |||
272 | ret = CHK_PER_INODE | 278 | ret = CHK_PER_INODE |
273 | else: | 279 | else: |
274 | bds /= CHK_PER_INODE | 280 | bds /= CHK_PER_INODE |
275 | ret = mod / bds | 281 | ret = old_div(mod, bds) |
276 | if (mod % bds) is not 0: | 282 | if (mod % bds) is not 0: |
277 | ret += 1 | 283 | ret += 1 |
278 | return ret | 284 | return ret |
diff --git a/contrib/scripts/gnunet_pyexpect.py.in b/contrib/scripts/gnunet_pyexpect.py.in index 810d5b321..4202da8d0 100644 --- a/contrib/scripts/gnunet_pyexpect.py.in +++ b/contrib/scripts/gnunet_pyexpect.py.in | |||
@@ -19,6 +19,7 @@ | |||
19 | # | 19 | # |
20 | # Testcase for gnunet-peerinfo | 20 | # Testcase for gnunet-peerinfo |
21 | from __future__ import print_function | 21 | from __future__ import print_function |
22 | from builtins import object | ||
22 | import os | 23 | import os |
23 | import re | 24 | import re |
24 | import subprocess | 25 | import subprocess |
diff --git a/contrib/scripts/pydiffer.py.in b/contrib/scripts/pydiffer.py.in index 10145371c..1dbe856db 100644 --- a/contrib/scripts/pydiffer.py.in +++ b/contrib/scripts/pydiffer.py.in | |||
@@ -1,4 +1,5 @@ | |||
1 | #!@PYTHON@ | 1 | #!@PYTHON@ |
2 | from __future__ import print_function | ||
2 | import os | 3 | import os |
3 | import sys | 4 | import sys |
4 | import difflib | 5 | import difflib |
@@ -23,7 +24,7 @@ def dc_getdiff(dc, old, new): | |||
23 | for f in dc.diff_files: | 24 | for f in dc.diff_files: |
24 | r = getdiff(os.path.join(old, f), os.path.join(new, f)) | 25 | r = getdiff(os.path.join(old, f), os.path.join(new, f)) |
25 | diff.extend(r) | 26 | diff.extend(r) |
26 | for dn, dc in dc.subdirs.items(): | 27 | for dn, dc in list(dc.subdirs.items()): |
27 | r = dc_getdiff(dc, os.path.join(old, dn), os.path.join(new, dn)) | 28 | r = dc_getdiff(dc, os.path.join(old, dn), os.path.join(new, dn)) |
28 | diff.extend(r) | 29 | diff.extend(r) |
29 | return diff | 30 | return diff |
diff --git a/contrib/scripts/terminate.py.in b/contrib/scripts/terminate.py.in index 161b4db61..9ed356502 100644 --- a/contrib/scripts/terminate.py.in +++ b/contrib/scripts/terminate.py.in | |||
@@ -21,6 +21,7 @@ | |||
21 | # For other platforms it's equivalent to Popen.kill () | 21 | # For other platforms it's equivalent to Popen.kill () |
22 | # Requires pywin32 on W32. | 22 | # Requires pywin32 on W32. |
23 | 23 | ||
24 | from builtins import object | ||
24 | import sys | 25 | import sys |
25 | import subprocess | 26 | import subprocess |
26 | import os | 27 | import os |
diff --git a/src/consensus/consensus-simulation.py.in b/src/consensus/consensus-simulation.py.in index 38e29230a..161015d00 100644 --- a/src/consensus/consensus-simulation.py.in +++ b/src/consensus/consensus-simulation.py.in | |||
@@ -19,6 +19,10 @@ | |||
19 | 19 | ||
20 | from __future__ import absolute_import | 20 | from __future__ import absolute_import |
21 | from __future__ import print_function | 21 | from __future__ import print_function |
22 | from __future__ import division | ||
23 | from builtins import str | ||
24 | from builtins import range | ||
25 | from past.utils import old_div | ||
22 | import argparse | 26 | import argparse |
23 | import random | 27 | import random |
24 | from math import ceil, log, floor | 28 | from math import ceil, log, floor |
@@ -39,18 +43,18 @@ def bsc(n): | |||
39 | 43 | ||
40 | def simulate(k, n, verbose): | 44 | def simulate(k, n, verbose): |
41 | assert k < n | 45 | assert k < n |
42 | largest_arc = int(2**ceil(log(n, 2))) / 2 | 46 | largest_arc = old_div(int(2**ceil(log(n, 2))), 2) |
43 | num_ghosts = (2 * largest_arc) - n | 47 | num_ghosts = (2 * largest_arc) - n |
44 | if verbose: | 48 | if verbose: |
45 | print("we have", num_ghosts, "ghost peers") | 49 | print("we have", num_ghosts, "ghost peers") |
46 | # n.b. all peers with idx<k are evil | 50 | # n.b. all peers with idx<k are evil |
47 | peers = range(n) | 51 | peers = list(range(n)) |
48 | # py2-3 compatible, backwards. | 52 | # py2-3 compatible, backwards. |
49 | # refer to http://python-future.org/compatible_idioms.html#xrange | 53 | # refer to http://python-future.org/compatible_idioms.html#xrange |
50 | info = [1 << x for x in xrange(n)] | 54 | info = [1 << x for x in range(n)] |
51 | 55 | ||
52 | def done_p(): | 56 | def done_p(): |
53 | for x in xrange(k, n): | 57 | for x in range(k, n): |
54 | if bsc(info[x]) < n-k: | 58 | if bsc(info[x]) < n-k: |
55 | return False | 59 | return False |
56 | return True | 60 | return True |
@@ -63,7 +67,7 @@ def simulate(k, n, verbose): | |||
63 | if verbose: | 67 | if verbose: |
64 | print("-- subround --") | 68 | print("-- subround --") |
65 | new_info = [x for x in info] | 69 | new_info = [x for x in info] |
66 | for peer_physical in xrange(n): | 70 | for peer_physical in range(n): |
67 | peer_logical = peers[peer_physical] | 71 | peer_logical = peers[peer_physical] |
68 | peer_type = None | 72 | peer_type = None |
69 | partner_logical = (peer_logical + arc) % n | 73 | partner_logical = (peer_logical + arc) % n |
@@ -105,6 +109,6 @@ if __name__ == "__main__": | |||
105 | 109 | ||
106 | args = parser.parse_args() | 110 | args = parser.parse_args() |
107 | sum = 0.0 | 111 | sum = 0.0 |
108 | for n in xrange(0, args.r): | 112 | for n in range(0, args.r): |
109 | sum += simulate(args.k, args.n, args.verbose) | 113 | sum += simulate(args.k, args.n, args.verbose) |
110 | print(sum / args.r) | 114 | print(old_div(sum, args.r)) |
diff --git a/src/fs/test_gnunet_fs_psd.py.in b/src/fs/test_gnunet_fs_psd.py.in index 416ab5db3..d5a036c28 100755 --- a/src/fs/test_gnunet_fs_psd.py.in +++ b/src/fs/test_gnunet_fs_psd.py.in | |||
@@ -18,6 +18,7 @@ | |||
18 | # SPDX-License-Identifier: AGPL3.0-or-later | 18 | # SPDX-License-Identifier: AGPL3.0-or-later |
19 | # | 19 | # |
20 | # Testcase for file-sharing command-line tools (publish, search, download) | 20 | # Testcase for file-sharing command-line tools (publish, search, download) |
21 | from __future__ import print_function | ||
21 | import sys | 22 | import sys |
22 | import os | 23 | import os |
23 | import subprocess | 24 | import subprocess |
diff --git a/src/revocation/test_local_revocation.py.in b/src/revocation/test_local_revocation.py.in index 212e8e777..5caa616ca 100644 --- a/src/revocation/test_local_revocation.py.in +++ b/src/revocation/test_local_revocation.py.in | |||
@@ -19,6 +19,7 @@ | |||
19 | # | 19 | # |
20 | # Testcase for ego revocation | 20 | # Testcase for ego revocation |
21 | from __future__ import print_function | 21 | from __future__ import print_function |
22 | from builtins import str | ||
22 | import sys | 23 | import sys |
23 | import os | 24 | import os |
24 | import subprocess | 25 | import subprocess |
diff --git a/src/util/gnunet-qr.py.in b/src/util/gnunet-qr.py.in index a5918fdf8..6c9d208f7 100755 --- a/src/util/gnunet-qr.py.in +++ b/src/util/gnunet-qr.py.in | |||
@@ -1,4 +1,6 @@ | |||
1 | #!@PYTHON@ | 1 | #!@PYTHON@ |
2 | from __future__ import print_function | ||
3 | from builtins import str | ||
2 | import sys | 4 | import sys |
3 | import getopt | 5 | import getopt |
4 | import subprocess | 6 | import subprocess |
@@ -100,7 +102,7 @@ if __name__ == '__main__': | |||
100 | cmd += " " + str(a) | 102 | cmd += " " + str(a) |
101 | if (verbose): | 103 | if (verbose): |
102 | print('Running `' + cmd +'`') | 104 | print('Running `' + cmd +'`') |
103 | res=subprocess.call(args) | 105 | res = subprocess.call(args) |
104 | if (0 != res): | 106 | if (0 != res): |
105 | print('Failed to add URI ' + str(symbol.data)) | 107 | print('Failed to add URI ' + str(symbol.data)) |
106 | else: | 108 | else: |