summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Gohad <tushar.gohad@intel.com>2014-03-19 14:50:09 -0700
committerTushar Gohad <tushar.gohad@intel.com>2014-03-19 14:50:09 -0700
commit961a0ba0379933e13b648afd5ba132c0a9b1e912 (patch)
treee404cae35fac8da37e2845555394d549fe83e9a6
parent128510e6af7f208c20b52deb344c41e387b5c29c (diff)
downloadpyeclib-961a0ba0379933e13b648afd5ba132c0a9b1e912.tar.gz
Make print()s simpler for 3.x compatibility
Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
-rw-r--r--c_eclib-0.2/xor_codes/tools/gen_failure_combs.py12
-rw-r--r--c_eclib-0.2/xor_codes/tools/gen_goldilocks_codes.py30
-rw-r--r--setup.py28
-rw-r--r--src/python/pyeclib/ec_iface.py4
-rw-r--r--src/python/test/pyeclib_test.py44
-rw-r--r--test/run_tests.py4
6 files changed, 61 insertions, 61 deletions
diff --git a/c_eclib-0.2/xor_codes/tools/gen_failure_combs.py b/c_eclib-0.2/xor_codes/tools/gen_failure_combs.py
index f937cf0..357d1d0 100644
--- a/c_eclib-0.2/xor_codes/tools/gen_failure_combs.py
+++ b/c_eclib-0.2/xor_codes/tools/gen_failure_combs.py
@@ -32,14 +32,14 @@ def get_combinations(list, k):
return itertools.combinations(list, k)
if len(sys.argv) != 3:
- print "Usage: %s <num_fragments> <num_combs>"
+ print("Usage: %s <num_fragments> <num_combs>")
sys.exit(1)
n = int(sys.argv[1])
k = int(sys.argv[2])
if n is None or k is None:
- print "Usage: %s <num_fragments> <num_combs>"
+ print("Usage: %s <num_fragments> <num_combs>")
sys.exit(1)
fragments = [i for i in range(n)]
@@ -59,7 +59,7 @@ failure_comb_format_str = \
fragment_combination_str = (
"%s" % fragment_combinations).replace("[", "{").replace("]", "}")
-print ("#define NUM_%d_%d_COMBS %d" %
- (n, k + 1, len(fragment_combinations)))
-print (failure_comb_format_str %
- (n, k + 1, n, k + 1, 4, fragment_combination_str))
+print("#define NUM_%d_%d_COMBS %d" %
+ (n, k + 1, len(fragment_combinations)))
+print(failure_comb_format_str %
+ (n, k + 1, n, k + 1, 4, fragment_combination_str))
diff --git a/c_eclib-0.2/xor_codes/tools/gen_goldilocks_codes.py b/c_eclib-0.2/xor_codes/tools/gen_goldilocks_codes.py
index 3233dbb..2afe47e 100644
--- a/c_eclib-0.2/xor_codes/tools/gen_goldilocks_codes.py
+++ b/c_eclib-0.2/xor_codes/tools/gen_goldilocks_codes.py
@@ -149,14 +149,14 @@ def get_parity_eqns(bm_parity_combinations):
return parity_bms
if len(sys.argv) != 3:
- print "Usage: %s <num_parities> <num_bits = 2|3>"
+ print("Usage: %s <num_parities> <num_bits = 2|3>")
sys.exit(1)
m = int(sys.argv[1])
num_bits = int(sys.argv[2])
if m is None or num_bits not in [2, 3]:
- print "Usage: %s <num_parities> <num_bits = 2|3>"
+ print("Usage: %s <num_parities> <num_bits = 2|3>")
sys.exit(1)
parity_list = [i for i in range(m)]
@@ -208,23 +208,23 @@ for parity_bm in used_parities:
parity_eqns = get_parity_eqns(bm_parity_combinations)
# print "(%d, %d) : %s : %s : %s" % (k, m, bm_parity_combinations,
# parity_eqns, num_data_in_parity)
- print (parity_bms_template %
- (k, m, num_bits + 1,
- ("%s" % parity_eqns).replace("[", "").replace("]", "")))
- print (data_bms_template %
- (k, m, num_bits + 1,
- ("%s" % bm_parity_combinations).replace("[", "").replace("]", "")))
+ print(parity_bms_template %
+ (k, m, num_bits + 1,
+ ("%s" % parity_eqns).replace("[", "").replace("]", "")))
+ print(data_bms_template %
+ (k, m, num_bits + 1,
+ ("%s" % bm_parity_combinations).replace("[", "").replace("]", "")))
bm_parity_combinations.append(parity_bm)
k += 1
num_data_in_parity = get_num_data_in_parity(bm_parity_combinations)
parity_eqns = get_parity_eqns(bm_parity_combinations)
-# print "(%d, %d) : %s : %s" % (k, m, bm_parity_combinations,
+# print"(%d, %d) : %s : %s" % (k, m, bm_parity_combinations,
# num_data_in_parity)
-print (parity_bms_template %
- (k, m, num_bits + 1,
- ("%s" % parity_eqns).replace("[", "").replace("]", "")))
-print (data_bms_template %
- (k, m, num_bits + 1,
- ("%s" % bm_parity_combinations).replace("[", "").replace("]", "")))
+print(parity_bms_template %
+ (k, m, num_bits + 1,
+ ("%s" % parity_eqns).replace("[", "").replace("]", "")))
+print(data_bms_template %
+ (k, m, num_bits + 1,
+ ("%s" % bm_parity_combinations).replace("[", "").replace("]", "")))
diff --git a/setup.py b/setup.py
index 92256e5..3d42bfa 100644
--- a/setup.py
+++ b/setup.py
@@ -121,7 +121,7 @@ class install(_install):
# ensure that the paths are absolute so we don't get lost
opts = {'exec_prefix': install_cmd.exec_prefix,
'root': install_cmd.root}
- for optname, value in opts.items():
+ for optname, value in list(opts.items()):
if value is not None:
opts[optname] = os.path.abspath(value)
@@ -155,19 +155,19 @@ class install(_install):
# updated.
#
if platform_str.find("Darwin") > -1:
- print "***************************************************"
- print "** "
- print "** You are running on a Mac! This means that "
- print "** any user using this library must update: "
- print "** DYLD_LIBRARY_PATH "
- print "** The best way to do this is to put this line:"
- print "** "
- print "** export DYLD_LIBRARY_PATH=%s" % ("%s/usr/local/lib"
- % installroot)
- print "** "
- print "** into .bashrc, .profile, or the appropriate"
- print "** shell start-up script!"
- print "***************************************************"
+ print("***************************************************")
+ print("** ")
+ print("** You are running on a Mac! This means that ")
+ print("** any user using this library must update: ")
+ print("** DYLD_LIBRARY_PATH ")
+ print("** The best way to do this is to put this line:")
+ print("** ")
+ print("** export DYLD_LIBRARY_PATH=%s" % ("%s/usr/local/lib"
+ % installroot))
+ print("** ")
+ print("** into .bashrc, .profile, or the appropriate")
+ print("** shell start-up script!")
+ print("***************************************************")
module = Extension('pyeclib_c',
diff --git a/src/python/pyeclib/ec_iface.py b/src/python/pyeclib/ec_iface.py
index a107149..d0ccd4c 100644
--- a/src/python/pyeclib/ec_iface.py
+++ b/src/python/pyeclib/ec_iface.py
@@ -81,7 +81,7 @@ class ECDriver(object):
self.m = -1
self.w = -1
self.library_import_str = -1
- for (key, value) in kwargs.iteritems():
+ for (key, value) in kwargs.items():
if key == "k":
self.k = int(value)
if key == "m":
@@ -131,7 +131,7 @@ class ECDriver(object):
required_methods[attr] = 1
not_implemented_str = ""
- for (method, is_implemented) in required_methods.iteritems():
+ for (method, is_implemented) in required_methods.items():
if is_implemented == 0:
not_implemented_str += method + " "
diff --git a/src/python/test/pyeclib_test.py b/src/python/test/pyeclib_test.py
index 39a13bb..e2ce8b5 100644
--- a/src/python/test/pyeclib_test.py
+++ b/src/python/test/pyeclib_test.py
@@ -139,7 +139,7 @@ def time_decode(num_data, num_parity, w, type, file_size, iterations, hd):
fd_orig.close()
fd_decoded.close()
- print "Fragment %d was not reconstructed!!!" % j
+ print(("Fragment %d was not reconstructed!!!" % j))
sys.exit(2)
decoded_fragments = None
@@ -194,7 +194,7 @@ def test_reconstruct(num_data, num_parity, w, type, file_size, iterations):
fd_decoded.write(reconstructed_fragment)
fd_orig.close()
fd_decoded.close()
- print "Fragment %d was not reconstructed!!!" % missing_idxs[0]
+ print(("Fragment %d was not reconstructed!!!" % missing_idxs[0]))
sys.exit(2)
return sum / iterations
@@ -227,8 +227,8 @@ def test_get_fragment_partition(
missing_idxs.sort()
if missing_fragment_idxs != missing_idxs:
- print ("Missing idx mismatch in test_get_fragment_partition: "
- "%s != %s\n" % (missing_fragment_idxs, missing_idxs))
+ print(("Missing idx mismatch in test_get_fragment_partition: "
+ "%s != %s\n" % (missing_fragment_idxs, missing_idxs)))
sys.exit()
decoded_fragments = pyeclib_c.decode(
@@ -248,9 +248,9 @@ def test_fragments_to_string(num_data, num_parity, w, type, file_size):
concat_str = pyeclib_c.fragments_to_string(handle, fragments[:num_data])
if concat_str != whole_file_str:
- print ("String does not equal the original string "
+ print(("String does not equal the original string "
"(len(orig) = %d, len(new) = %d\n" %
- (len(whole_file_str), len(concat_str)))
+ (len(whole_file_str), len(concat_str))))
def test_get_required_fragments(num_data, num_parity, w, type):
@@ -277,9 +277,9 @@ def test_get_required_fragments(num_data, num_parity, w, type):
missing_fragments)
if expected_fragments != required_fragments:
- print ("Unexpected required fragments list "
+ print(("Unexpected required fragments list "
"(exp != req): %s != %s" %
- (expected_fragments, required_fragments))
+ (expected_fragments, required_fragments)))
sys.exit(2)
@@ -306,27 +306,27 @@ sizes = ["101-K", "202-K", "303-K"]
setup(sizes)
for (type, k, m, hd) in xor_types:
- print("Running tests for %s k=%d, m=%d\n" % (type, k, m))
+ print(("\nRunning tests for %s k=%d, m=%d\n" % (type, k, m)))
type_str = "%s" % (type)
for size_str in sizes:
avg_time = time_encode(k, m, 32, type_str, size_str, iterations)
- print("Encode (%s): " %
- size_str, get_throughput(avg_time, size_str))
+ print(("Encode (%s): %.2f" %
+ (size_str, get_throughput(avg_time, size_str))))
for size_str in sizes:
avg_time = time_decode(k, m, 32, type_str, size_str, iterations, 3)
- print("Decode (%s): " %
- size_str, get_throughput(avg_time, size_str))
+ print(("Decode (%s): %.2f" %
+ (size_str, get_throughput(avg_time, size_str))))
for size_str in sizes:
avg_time = test_reconstruct(k, m, 32, type_str, size_str, iterations)
- print("Reconstruct (%s): " %
- size_str, get_throughput(avg_time, size_str))
+ print(("Reconstruct (%s): %.2f" %
+ (size_str, get_throughput(avg_time, size_str))))
for (type, w) in rs_types:
- print("Running tests for %s w=%d\n" % (type, w))
+ print(("\nRunning tests for %s w=%d\n" % (type, w)))
for i in range(len(num_datas)):
for size_str in sizes:
@@ -359,8 +359,8 @@ for (type, w) in rs_types:
type,
size_str,
iterations)
- print("Encode (%s): " %
- size_str, get_throughput(avg_time, size_str))
+ print(("Encode (%s): %.2f" %
+ (size_str, get_throughput(avg_time, size_str))))
for i in range(len(num_datas)):
for size_str in sizes:
@@ -373,8 +373,8 @@ for (type, w) in rs_types:
iterations,
num_parities[i] +
1)
- print("Decode (%s): " %
- size_str, get_throughput(avg_time, size_str))
+ print(("Decode (%s): %.2f" %
+ (size_str, get_throughput(avg_time, size_str))))
for i in range(len(num_datas)):
for size_str in sizes:
@@ -385,8 +385,8 @@ for (type, w) in rs_types:
type,
size_str,
iterations)
- print("Reconstruct (%s): " %
- size_str, get_throughput(avg_time, size_str))
+ print(("Reconstruct (%s): %.2f" %
+ (size_str, get_throughput(avg_time, size_str))))
cleanup(sizes)
diff --git a/test/run_tests.py b/test/run_tests.py
index a2de49f..b44e284 100644
--- a/test/run_tests.py
+++ b/test/run_tests.py
@@ -57,7 +57,7 @@ def pyeclib_core_test():
os.chdir(dir)
ret = os.system("python %s" % test)
if ret != 0:
- print ("Building %s failed!!!" % (dir))
+ print("Building %s failed!!!" % (dir))
sys.exit(1)
os.system("rm -f *.pyc")
os.chdir(cur_dir)
@@ -71,7 +71,7 @@ def pyeclib_core_valgrind():
"valgrind --leak-check=full python %s >%s/valgrind.%s.out 2>&1" %
(test, cur_dir, test))
if ret != 0:
- print ("Building %s failed!!!" % (dir))
+ print("Building %s failed!!!" % (dir))
sys.exit(1)
os.system("rm -f *.pyc")
os.chdir(cur_dir)