1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

python: use // for integer division

This commit is contained in:
Zdenek Kabelac 2018-05-18 16:23:10 +02:00
parent 3bbdde808a
commit b2574c2f3a
3 changed files with 10 additions and 10 deletions

View File

@ -497,7 +497,7 @@ class Lv(LvCommon):
# it is a thin lv # it is a thin lv
if not dbo.IsThinVolume: if not dbo.IsThinVolume:
if optional_size == 0: if optional_size == 0:
space = dbo.SizeBytes / 80 space = dbo.SizeBytes // 80
remainder = space % 512 remainder = space % 512
optional_size = space + 512 - remainder optional_size = space + 512 - remainder

View File

@ -112,7 +112,7 @@ class TestLvm(unittest.TestCase):
for d in device_list: for d in device_list:
vg.extend(d) vg.extend(d)
vg.createLvLinear(name, vg.getSize() / 2) vg.createLvLinear(name, vg.getSize() // 2)
vg.close() vg.close()
vg = None vg = None
@ -124,14 +124,14 @@ class TestLvm(unittest.TestCase):
vg.extend(d) vg.extend(d)
vg.createLvThinpool( vg.createLvThinpool(
pool_name, vg.getSize() / 2, 0, 0, lvm.THIN_DISCARDS_PASSDOWN, 1) pool_name, vg.getSize() // 2, 0, 0, lvm.THIN_DISCARDS_PASSDOWN, 1)
return vg return vg
@staticmethod @staticmethod
def _create_thin_lv(pv_devices, name): def _create_thin_lv(pv_devices, name):
thin_pool_name = 'thin_vg_pool_' + rs(4) thin_pool_name = 'thin_vg_pool_' + rs(4)
vg = TestLvm._create_thin_pool(pv_devices, thin_pool_name) vg = TestLvm._create_thin_pool(pv_devices, thin_pool_name)
vg.createLvThin(thin_pool_name, name, vg.getSize() / 8) vg.createLvThin(thin_pool_name, name, vg.getSize() // 8)
vg.close() vg.close()
vg = None vg = None
@ -231,7 +231,7 @@ class TestLvm(unittest.TestCase):
curr_size = pv.getSize() curr_size = pv.getSize()
dev_size = pv.getDevSize() dev_size = pv.getDevSize()
self.assertTrue(curr_size == dev_size) self.assertTrue(curr_size == dev_size)
pv.resize(curr_size / 2) pv.resize(curr_size // 2)
with AllowedPVS() as pvs: with AllowedPVS() as pvs:
pv = pvs[0] pv = pvs[0]
resized_size = pv.getSize() resized_size = pv.getSize()
@ -718,7 +718,7 @@ class TestLvm(unittest.TestCase):
def test_percent_to_float(self): def test_percent_to_float(self):
self.assertEqual(lvm.percentToFloat(0), 0.0) self.assertEqual(lvm.percentToFloat(0), 0.0)
self.assertEqual(lvm.percentToFloat(1000000), 1.0) self.assertEqual(lvm.percentToFloat(1000000), 1.0)
self.assertEqual(lvm.percentToFloat(1000000 / 2), 0.5) self.assertEqual(lvm.percentToFloat(1000000 // 2), 0.5)
def test_scan(self): def test_scan(self):
self.assertEqual(lvm.scan(), None) self.assertEqual(lvm.scan(), None)

View File

@ -1027,7 +1027,7 @@ class TestDbusService(unittest.TestCase):
vg.Move( vg.Move(
dbus.ObjectPath(location), dbus.ObjectPath(location),
dbus.Struct((0, 0), signature='tt'), dbus.Struct((0, 0), signature='tt'),
dbus.Array([(dst, pv.PeCount / 2, 0), ], '(ott)'), dbus.Array([(dst, pv.PeCount // 2, 0), ], '(ott)'),
dbus.Int32(g_tmo), dbus.Int32(g_tmo),
EOD)) EOD))
self.assertEqual(job, '/') self.assertEqual(job, '/')
@ -1320,7 +1320,7 @@ class TestDbusService(unittest.TestCase):
original_size = pv.SizeBytes original_size = pv.SizeBytes
new_size = original_size / 2 new_size = original_size // 2
self.handle_return( self.handle_return(
pv.ReSize( pv.ReSize(
@ -1454,7 +1454,7 @@ class TestDbusService(unittest.TestCase):
@staticmethod @staticmethod
def _write_some_data(device_path, size): def _write_some_data(device_path, size):
blocks = int(size / 512) blocks = int(size // 512)
block = bytearray(512) block = bytearray(512)
for i in range(0, 512): for i in range(0, 512):
block[i] = i % 255 block[i] = i % 255
@ -1481,7 +1481,7 @@ class TestDbusService(unittest.TestCase):
interfaces=(LV_COMMON_INT, LV_INT, SNAPSHOT_INT, )) interfaces=(LV_COMMON_INT, LV_INT, SNAPSHOT_INT, ))
# Write some data to snapshot so merge takes some time # Write some data to snapshot so merge takes some time
TestDbusService._write_some_data(ss.LvCommon.Path, ss_size / 2) TestDbusService._write_some_data(ss.LvCommon.Path, ss_size // 2)
job_path = self.handle_return( job_path = self.handle_return(
ss.Snapshot.Merge( ss.Snapshot.Merge(