summaryrefslogtreecommitdiffstats
path: root/glustolibs-io
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2019-11-20 15:05:27 +0530
committerBala Konda Reddy M <bmekala@redhat.com>2019-11-22 16:30:46 +0000
commit948e4b088a14315e229faab3015a97806cae990e (patch)
tree759cc2c5a2789f6928a343906faae48a9e2e3e53 /glustolibs-io
parent915af4c84124ea4ac8c713404c672ff2087ae979 (diff)
[py2to3] Replace "print" statement with "print()" function
"print" statement is not supported in py3. So, start using "print()" function everywhere in the code. Signed-off-by: Valerii Ponomarov <kiparis.kh@gmail.com> Change-Id: I5b3e39ce5d4973959d7cedd0aac6fc744e2fe7ef
Diffstat (limited to 'glustolibs-io')
-rwxr-xr-xglustolibs-io/shared_files/scripts/fd_writes.py35
-rwxr-xr-xglustolibs-io/shared_files/scripts/file_dir_ops.py40
-rwxr-xr-xglustolibs-io/shared_files/scripts/generate_io.py23
3 files changed, 50 insertions, 48 deletions
diff --git a/glustolibs-io/shared_files/scripts/fd_writes.py b/glustolibs-io/shared_files/scripts/fd_writes.py
index 87358f45a..c9093044f 100755
--- a/glustolibs-io/shared_files/scripts/fd_writes.py
+++ b/glustolibs-io/shared_files/scripts/fd_writes.py
@@ -15,6 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+from __future__ import print_function
import argparse
import random
import os
@@ -35,9 +36,9 @@ def is_root(path):
True if path is '/' , False otherwise
"""
if os.path.realpath(os.path.abspath(path)) == '/':
- print ("Directory '%s' is the root of filesystem. "
- "Not performing any operations on the root of filesystem" %
- os.path.abspath(path))
+ print("Directory '%s' is the root of filesystem. "
+ "Not performing any operations on the root of filesystem" % (
+ os.path.abspath(path)))
return True
else:
return False
@@ -72,7 +73,7 @@ def create_dir(dir_path):
try:
os.makedirs(dir_abs_path)
except (OSError, IOError):
- print "Unable to create dir: %s" % dir_abs_path
+ print("Unable to create dir: %s" % dir_abs_path)
return 1
return 0
@@ -90,8 +91,8 @@ def fd_write_file(filename, file_size, chunk_sizes_list, write_time,
fd.write("0")
fd.flush()
except IOError as e:
- print ("Unable to open file %s for writing : %s" % (filename,
- e.strerror))
+ print("Unable to open file %s for writing : %s" % (
+ filename, e.strerror))
return 1
while time_counter < write_time:
@@ -102,18 +103,18 @@ def fd_write_file(filename, file_size, chunk_sizes_list, write_time,
range(current_chunk_size)))
offset = random.randint(0, (actual_file_size - current_chunk_size))
if log_level.upper() == 'DEBUG':
- print ("\tFileName: %s, File Size: %s, "
- "Writing to offset: %s, "
- "Data Length: %d, Time Counter: %d" %
- (filename, actual_file_size, offset, len(write_data),
- time_counter))
+ print("\tFileName: %s, File Size: %s, "
+ "Writing to offset: %s, "
+ "Data Length: %d, Time Counter: %d" % (
+ filename, actual_file_size, offset, len(write_data),
+ time_counter))
fd.seek(offset)
fd.write(write_data)
fd.seek(0)
fd.flush()
except IOError as e:
- print ("Unable to write to file '%s' : %s at time count: %dS" %
- (filename, e.strerror, time_counter))
+ print("Unable to write to file '%s' : %s at time count: %dS" % (
+ filename, e.strerror, time_counter))
rc = 1
time.sleep(delay_between_writes)
@@ -240,15 +241,15 @@ if __name__ == "__main__":
parser.set_defaults(func=fd_writes)
- print "Starting Script: %s" % ' '.join(sys.argv)
- print "StarTime :'%s' " % (datetime.datetime.now())
+ print("Starting Script: %s" % ' '.join(sys.argv))
+ print("StarTime :'%s' " % datetime.datetime.now())
test_start_time = datetime.datetime.now().replace(microsecond=0)
args = parser.parse_args()
rc = args.func(args)
test_end_time = datetime.datetime.now().replace(microsecond=0)
- print "Execution time: %s" % (test_end_time - test_start_time)
- print "EndTime :'%s' " % (datetime.datetime.now())
+ print("Execution time: %s" % (test_end_time - test_start_time))
+ print("EndTime :'%s' " % datetime.datetime.now())
sys.exit(rc)
diff --git a/glustolibs-io/shared_files/scripts/file_dir_ops.py b/glustolibs-io/shared_files/scripts/file_dir_ops.py
index 05bc7b877..d4074ec42 100755
--- a/glustolibs-io/shared_files/scripts/file_dir_ops.py
+++ b/glustolibs-io/shared_files/scripts/file_dir_ops.py
@@ -51,9 +51,9 @@ def is_root(path):
True if path is '/' , False otherwise
"""
if os.path.realpath(os.path.abspath(path)) == '/':
- print ("Directory '%s' is the root of filesystem. "
- "Not performing any operations on the root of filesystem" %
- os.path.abspath(path))
+ print("Directory '%s' is the root of filesystem. "
+ "Not performing any operations on the root of filesystem" % (
+ os.path.abspath(path)))
return True
else:
return False
@@ -108,7 +108,7 @@ def create_dir(dir_path):
try:
os.makedirs(dir_abs_path)
except (OSError, IOError):
- print ("Unable to create dir: %s" % dir_abs_path)
+ print("Unable to create dir: %s" % dir_abs_path)
return 1
return 0
@@ -140,16 +140,16 @@ def create_dirs(dir_path, depth, num_of_dirs, num_of_files=0,
base_file_name, file_types)
except (OSError, IOError) as e:
if 'File exists' not in e.strerror:
- print ("Unable to create dir '%s' : %s"
- % (dir_path, e.strerror))
+ print("Unable to create dir '%s' : %s" % (
+ dir_path, e.strerror))
with open("/tmp/file_dir_ops_create_dirs_rc", "w") as fd:
try:
fd.write("1")
fd.flush()
fd.close()
except IOError as e:
- print ("Unable to write the rc to the "
- "/tmp/file_dir_ops_create_dirs_rc file")
+ print("Unable to write the rc to the "
+ "/tmp/file_dir_ops_create_dirs_rc file")
if depth == 0:
return 0
for i in range(num_of_dirs):
@@ -387,7 +387,7 @@ def rename(args):
# Check if dir_path exists
if not path_exists(dir_path):
- print ("Directory '%s' does not exist" % dir_path)
+ print("Directory '%s' does not exist" % dir_path)
return 1
rc = 0
@@ -401,7 +401,7 @@ def rename(args):
os.rename(old, new)
except OSError:
rc = 1
- print ("Unable to rename %s -> %s" % (old, new))
+ print("Unable to rename %s -> %s" % (old, new))
# rename dirs
if dirName != dir_path:
@@ -411,7 +411,7 @@ def rename(args):
os.rename(old, new)
except OSError:
rc = 1
- print ("Unable to rename %s -> %s" % (old, new))
+ print("Unable to rename %s -> %s" % (old, new))
return rc
@@ -423,7 +423,7 @@ def ls(args):
# Check if dir_path exists
if not path_exists(dir_path):
- print ("Directory '%s' does not exist" % dir_path)
+ print("Directory '%s' does not exist" % dir_path)
return 1
with open_file_to_write(log_file_name) as file_handle:
@@ -493,7 +493,7 @@ def get_path_stats(args):
# Check if dir_path exists
if not path_exists(path):
- print ("PATH '%s' does not exist" % path)
+ print("PATH '%s' does not exist" % path)
return 1
file_stats = {}
@@ -551,7 +551,7 @@ def compress(args):
# Check if dir_path exists
if not path_exists(dir_path):
- print ("Directory '%s' does not exist" % dir_path)
+ print("Directory '%s' does not exist" % dir_path)
return 1
# Create dir_path
@@ -653,7 +653,7 @@ def create_hard_links(args):
# Check if src_dir exists
if not path_exists(src_dir):
- print ("Directory '%s' does not exist" % src_dir)
+ print("Directory '%s' does not exist" % src_dir)
return 1
# Create dir_path
@@ -734,7 +734,7 @@ def copy(args):
# Check if src_dir exists
if not path_exists(src_dir):
- print ("Directory '%s' does not exist" % src_dir)
+ print("Directory '%s' does not exist" % src_dir)
return 1
# Create dest_dir
@@ -775,7 +775,7 @@ def delete(args):
# Check if dir_path exists
if not path_exists(dir_path):
- print ("Directory '%s' does not exist" % dir_path)
+ print("Directory '%s' does not exist" % dir_path)
return 1
rc = 0
@@ -795,7 +795,7 @@ def delete(args):
if __name__ == "__main__":
- print ("Starting File/Dir Ops: %s" % _get_current_time())
+ print("Starting File/Dir Ops: %s" % _get_current_time())
test_start_time = datetime.datetime.now().replace(microsecond=0)
parser = argparse.ArgumentParser(
@@ -1067,6 +1067,6 @@ if __name__ == "__main__":
rc = args.func(args)
test_end_time = datetime.datetime.now().replace(microsecond=0)
- print ("Execution time: %s" % (test_end_time - test_start_time))
- print ("Ending File/Dir Ops %s" % _get_current_time())
+ print("Execution time: %s" % (test_end_time - test_start_time))
+ print("Ending File/Dir Ops %s" % _get_current_time())
sys.exit(rc)
diff --git a/glustolibs-io/shared_files/scripts/generate_io.py b/glustolibs-io/shared_files/scripts/generate_io.py
index 0f2f2a3ea..ee9745df5 100755
--- a/glustolibs-io/shared_files/scripts/generate_io.py
+++ b/glustolibs-io/shared_files/scripts/generate_io.py
@@ -15,6 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+from __future__ import print_function
import subprocess
import re
import time
@@ -350,7 +351,7 @@ def call_get_disk_usage(args):
disk_usage = get_disk_usage(args.dir)
if disk_usage is None:
return 1
- print disk_usage
+ print(disk_usage)
return 0
@@ -424,18 +425,18 @@ def call_start_populate_data(args):
time_str = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S')
log_file = filename + "_" + time_str + file_ext
- print "GENERATE IO Log file: %s" % log_file
+ print("GENERATE IO Log file: %s" % log_file)
if('io' in config_data and 'tools' in config_data['io']):
config_data_io = dict(config_data['io']['tools'])
else:
- print "io tools info is not given in config file"
+ print("io tools info is not given in config file")
return 1
if('io' in config_data and 'scripts' in config_data['io']):
config_data_io.update(config_data['io']['scripts'])
else:
- print "io scripts info is not given in config file"
+ print("io scripts info is not given in config file")
return 1
io_details = {}
@@ -447,18 +448,18 @@ def call_start_populate_data(args):
config_data_io[io]['workload_type'] = workload_type
io_details[io] = config_data_io[io]
else:
- print ("The IO tool/script - '%s' details not present in config "
- "file. Skipping the IO - '%s'" % (io, io))
+ print("The IO tool/script - '%s' details not present in config "
+ "file. Skipping the IO - '%s'" % (io, io))
if not io_details:
- print "Config file doesn't have IO details for %s" % ','.join(io_list)
+ print("Config file doesn't have IO details for %s" % ','.join(io_list))
return 1
# Starts generating IO
# If -t and -p bot are passed as options, runs all the io's as specified
# until '-t' or '-p' is reached. i.e which ever reaches first.
ret = start_populate_data(dirname, io_details, percent, timeout)
- print "Disk Usage Details of %s: %s" % (dirname, get_disk_usage(dirname))
+ print("Disk Usage Details of %s: %s" % (dirname, get_disk_usage(dirname)))
fd_list = []
for io in io_details.keys():
@@ -482,7 +483,7 @@ def call_start_populate_data(args):
if __name__ == "__main__":
- print "Starting IO Generation..."
+ print("Starting IO Generation...")
test_start_time = datetime.datetime.now().replace(microsecond=0)
write_data_parser = argparse.ArgumentParser(prog="generate_io.py",
@@ -515,6 +516,6 @@ if __name__ == "__main__":
args = write_data_parser.parse_args()
rc = args.func(args)
test_end_time = datetime.datetime.now().replace(microsecond=0)
- print "Execution time: %s" % (test_end_time - test_start_time)
- print "Ending IO Generation"
+ print("Execution time: %s" % (test_end_time - test_start_time))
+ print("Ending IO Generation")
sys.exit(rc)