From c10083a0166969ec5474fd8a92cfd35cf0536ffe Mon Sep 17 00:00:00 2001 From: Vitalii Koriakov Date: Fri, 26 Oct 2018 13:18:28 +0300 Subject: Using a raw strings for fixing flake warnings Change-Id: Ie134790ea05919a4b396657c11cbc3fc7a7fc529 Signed-off-by: Vitalii Koriakov --- glustolibs-gluster/glustolibs/gluster/bitrot_ops.py | 2 +- .../glustolibs/gluster/glusterfile.py | 2 +- glustolibs-gluster/glustolibs/gluster/heal_libs.py | 2 +- glustolibs-gluster/glustolibs/gluster/heal_ops.py | 2 +- glustolibs-gluster/glustolibs/gluster/lib_utils.py | 4 ++-- glustolibs-gluster/glustolibs/gluster/mount_ops.py | 21 +++++++++------------ .../glustolibs/gluster/nfs_ganesha_libs.py | 2 +- glustolibs-gluster/glustolibs/gluster/quota_libs.py | 2 +- glustolibs-io/glustolibs/io/utils.py | 4 ++-- .../nfs_ganesha/test_nfs_ganesha_volume_exports.py | 4 ++-- 10 files changed, 21 insertions(+), 24 deletions(-) mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/bitrot_ops.py mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/glusterfile.py mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/heal_libs.py mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/lib_utils.py mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/mount_ops.py mode change 100644 => 100755 glustolibs-gluster/glustolibs/gluster/quota_libs.py mode change 100644 => 100755 glustolibs-io/glustolibs/io/utils.py mode change 100644 => 100755 tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py diff --git a/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py b/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py old mode 100644 new mode 100755 index cab205cbb..bbfcd93a4 --- a/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/bitrot_ops.py @@ -566,7 +566,7 @@ def get_scrub_status(mnode, volname): temp_list = re.findall(regex, info, re.S) corrupt_list = [] for node in temp_list: - tmp_reg = ('Node: (\S+)\n.*Error count.*' + tmp_reg = (r'Node: (\S+)\n.*Error count.*' 'Corrupted object.*?:(.*)\n=.*') m = re.search(tmp_reg, node, re.S) if m is None: diff --git a/glustolibs-gluster/glustolibs/gluster/glusterfile.py b/glustolibs-gluster/glustolibs/gluster/glusterfile.py old mode 100644 new mode 100755 index 9b9b57f0c..2f1c45e7b --- a/glustolibs-gluster/glustolibs/gluster/glusterfile.py +++ b/glustolibs-gluster/glustolibs/gluster/glusterfile.py @@ -366,7 +366,7 @@ def get_pathinfo(host, fqpath): """ pathinfo = {} pathinfo['raw'] = get_fattr(host, fqpath, 'trusted.glusterfs.pathinfo') - pathinfo['brickdir_paths'] = re.findall(".*?POSIX.*?:(\S+)\>", + pathinfo['brickdir_paths'] = re.findall(r".*?POSIX.*?:(\S+)\>", pathinfo['raw']) return pathinfo diff --git a/glustolibs-gluster/glustolibs/gluster/heal_libs.py b/glustolibs-gluster/glustolibs/gluster/heal_libs.py old mode 100644 new mode 100755 index e71835d78..e4f2b2fdf --- a/glustolibs-gluster/glustolibs/gluster/heal_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/heal_libs.py @@ -343,7 +343,7 @@ def get_self_heal_daemon_pid(nodes): _rc = True if isinstance(nodes, str): nodes = [nodes] - cmd = "pgrep -f glustershd | grep -v ^$$\$" + cmd = r"pgrep -f glustershd | grep -v ^$$\$" g.log.info("Executing cmd: %s on node %s" % (cmd, nodes)) results = g.run_parallel(nodes, cmd) for node in results: diff --git a/glustolibs-gluster/glustolibs/gluster/heal_ops.py b/glustolibs-gluster/glustolibs/gluster/heal_ops.py index daae9a37d..c200f5c11 100644 --- a/glustolibs-gluster/glustolibs/gluster/heal_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/heal_ops.py @@ -184,7 +184,7 @@ def heal_info_summary(mnode, volname): The third element 'err' is of type 'str' and is the stderr value of the command execution. """ - cmd = ("gluster volume heal %s info | grep 'entries\|Brick\|Status'" % + cmd = (r"gluster volume heal %s info | grep 'entries\|Brick\|Status'" % volname) return g.run(mnode, cmd) diff --git a/glustolibs-gluster/glustolibs/gluster/lib_utils.py b/glustolibs-gluster/glustolibs/gluster/lib_utils.py old mode 100644 new mode 100755 index 682152f5f..44ac6e3f3 --- a/glustolibs-gluster/glustolibs/gluster/lib_utils.py +++ b/glustolibs-gluster/glustolibs/gluster/lib_utils.py @@ -247,7 +247,7 @@ def get_pathinfo(mnode, filename, volname): umount_volume(mnode, mount_point) g.run(mnode, "rm -rf " + mount_point) - return re.findall(".*?POSIX.*?:(\S+)\>", pathinfo) + return re.findall(r".*?POSIX.*?:(\S+)\>", pathinfo) def list_files(mnode, dir_path, parse_str="", user="root"): @@ -815,7 +815,7 @@ def is_core_file_created(nodes, testrun_timestamp, g.log.info("checking core file created or not") for file1 in dir_list: if (re.search(r'\bcore\.[\S]+\b', file1)): - file_path_list = re.split('[\s]+', cmd) + file_path_list = re.split(r'[\s]+', cmd) file_path = file_path_list[1] + '/' + file1 time_cmd = 'stat ' + '-c ' + '%X ' + file_path ret, file_timestamp, _ = g.run(node, time_cmd) diff --git a/glustolibs-gluster/glustolibs/gluster/mount_ops.py b/glustolibs-gluster/glustolibs/gluster/mount_ops.py old mode 100644 new mode 100755 index 637af24b1..cc63d0588 --- a/glustolibs-gluster/glustolibs/gluster/mount_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/mount_ops.py @@ -251,18 +251,15 @@ def is_mounted(volname, mpoint, mserver, mclient, mtype, user='root'): if mtype == "smb": if mpoint == "*": return False - else: - cmd = powershell("net use %s" % mpoint) - ret, out, err = g.run(mclient, cmd, user) - if ret != 0: - return False - else: - expected_output = ("Remote name \\\%s\gluster-%s" % - (mserver, volname)) - if expected_output in out: - return True - else: - return False + cmd = powershell("net use %s" % mpoint) + ret, out, err = g.run(mclient, cmd, user) + if ret != 0: + return False + expected_output = (r"\\\%s\gluster-%s" % + (mserver, volname)) + if "Remote name" in out and expected_output in out: + return True + return False else: ret, _, _ = g.run(mclient, "mount | grep %s | grep %s | grep \"%s\"" % (volname, mpoint, mserver), user) diff --git a/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py b/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py index 390a6b916..fd7d8f4a5 100644 --- a/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/nfs_ganesha_libs.py @@ -105,7 +105,7 @@ class NfsGaneshaClusterSetupClass(GlusterBaseClass): ganesha_ha_contents = fh.read() g.rpyc_close_connection( host=cls.servers_in_nfs_ganesha_cluster[0], user="root") - servers_in_existing_cluster = re.findall('VIP_(.*)\=.*', + servers_in_existing_cluster = re.findall(r'VIP_(.*)\=.*', ganesha_ha_contents) ret = teardown_nfs_ganesha_cluster( diff --git a/glustolibs-gluster/glustolibs/gluster/quota_libs.py b/glustolibs-gluster/glustolibs/gluster/quota_libs.py old mode 100644 new mode 100755 index 6cb770167..5da4d8698 --- a/glustolibs-gluster/glustolibs/gluster/quota_libs.py +++ b/glustolibs-gluster/glustolibs/gluster/quota_libs.py @@ -99,7 +99,7 @@ def quota_fetch_daemon_pid(nodes): _rc = True if isinstance(nodes, str): nodes = [nodes] - cmd = "pgrep -f quotad | grep -v ^$$\$" + cmd = r"pgrep -f quotad | grep -v ^$$\$" g.log.info("Executing cmd: %s on node %s" % (cmd, nodes)) results = g.run_parallel(nodes, cmd) for node in results: diff --git a/glustolibs-io/glustolibs/io/utils.py b/glustolibs-io/glustolibs/io/utils.py old mode 100644 new mode 100755 index 8b9a9e196..8584e2aac --- a/glustolibs-io/glustolibs/io/utils.py +++ b/glustolibs-io/glustolibs/io/utils.py @@ -149,7 +149,7 @@ def list_all_files_and_dirs_mounts(mounts): mounts = [mounts] ignore_dirs_list = [".trashcan"] - ignore_dirs = "\|".join(ignore_dirs_list) + ignore_dirs = r"\|".join(ignore_dirs_list) g.log.info("Start Listing mounts files and dirs") all_mounts_procs = [] @@ -349,7 +349,7 @@ def cleanup_mounts(mounts): # Check if mount points are empty ignore_dirs_list = [".trashcan"] - ignore_dirs = "\|".join(ignore_dirs_list) + ignore_dirs = r"\|".join(ignore_dirs_list) all_mounts_procs = [] for mount_obj in mounts: cmd = ("find %s -mindepth 1 | grep -ve '%s'" % diff --git a/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py b/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py old mode 100644 new mode 100755 index ead84dbc5..65d7bc6ab --- a/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py +++ b/tests/functional/nfs_ganesha/test_nfs_ganesha_volume_exports.py @@ -463,7 +463,7 @@ class TestNfsGaneshaSubDirExportsWithIO(NfsGaneshaIOBaseClass): export_file = ("/var/run/gluster/shared_storage/nfs-ganesha/exports/" "export.%s.conf" % self.volname) - cmd = ("sed -i s/'Path = .*'/'Path = \"\/%s\";'/g %s" + cmd = (r"sed -i s/'Path = .*'/'Path = \"\/%s\";'/g %s" % (re.escape(self.mounts[0].volname), export_file)) ret, _, _ = g.run(self.mnode, cmd) self.assertEqual(ret, 0, ("Unable to change Path info to %s in %s" @@ -477,7 +477,7 @@ class TestNfsGaneshaSubDirExportsWithIO(NfsGaneshaIOBaseClass): % ("/" + self.mounts[0].volname, export_file))) - cmd = ("sed -i s/'Pseudo=.*'/'Pseudo=\"\/%s\";'/g %s" + cmd = (r"sed -i s/'Pseudo=.*'/'Pseudo=\"\/%s\";'/g %s" % (re.escape(self.mounts[0].volname), export_file)) ret, _, _ = g.run(self.mnode, cmd) self.assertEqual(ret, 0, ("Unable to change pseudo Path info to " -- cgit