summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/brickmux_libs.py
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-04-20 14:41:59 +0530
committerBala Konda Reddy M <bala12352@gmail.com>2020-04-20 10:10:13 +0000
commit5d9a0ab8e46475af390272a0916e9f075153ca4b (patch)
tree7f177334ee3c24d60983d27da0aeaf912a29d32c /glustolibs-gluster/glustolibs/gluster/brickmux_libs.py
parentedca79c9161256c2722a27d89f64bd2ac6103e9a (diff)
[py2py3] Fixing a bunch of python3 incompatibilities
Problem: There are two python2 to python3 incompatibilities present in test_add_brick_when_quorum_not_met.py and test_add_identical_brick_new_node.py. In test_add_brick_when_quorum_not_met.py the testcase fails with the below error: > for node in range(num_of_nodes_to_bring_down, num_of_servers): E TypeError: 'float' object cannot be interpreted as an integer This is because a = 10 / 5 returns a float in python3 but it returns a int in python2 as shown below: Python 2.7.15 (default, Oct 15 2018, 15:26:09) [GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 10/5 >>> type(a) <type 'int'> Python 3.7.3 (default, Mar 27 2019, 13:41:07) [GCC 8.3.1 20190223 (Red Hat 8.3.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a = 10/5 >>> type(a) <class 'float'> In test_add_identical_brick_new_node.py testcase fails with the below error: > add_bricks.append(string.replace(bricks_list[0], self.servers[0], self.servers[1])) E AttributeError: module 'string' has no attribute 'replace' This is because string is depriciated in python3 and is replaced with str. Solution: For the first issue we would need to change a = 10/5 to a = 10//5 as it is constant across both python versions. For the second issue adding try except block as shown below would be suffice: except AttributeError: add_bricks.append(str.replace(bricks_list[0], self.servers[0], self.servers[1])) Change-Id: I9ec325760b279032af3748101bd2bfc58589d57d Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/brickmux_libs.py')
0 files changed, 0 insertions, 0 deletions