Change in vdsm[master]: prepare for python 3's range
nsoffer at redhat.com
nsoffer at redhat.com
Wed Apr 22 11:10:32 UTC 2015
Nir Soffer has posted comments on this change.
Change subject: prepare for python 3's range
......................................................................
Patch Set 2:
(9 comments)
Can we use python3 on rhel in the near future? Why are we wasting time on this now?
https://gerrit.ovirt.org/#/c/40079/2/lib/vdsm/tool/configfile.py
File lib/vdsm/tool/configfile.py:
Line 30: (
Line 31: BEFORE,
Line 32: WITHIN,
Line 33: AFTER
Line 34: ) = list(range(3))
Use tuple(range(3))
Or better use:
BEFORE = 0
WITHIN = 1
AFTER = 2
Line 35:
Line 36:
Line 37: def context(func):
Line 38: @functools.wraps(func)
https://gerrit.ovirt.org/#/c/40079/2/lib/vdsm/tool/configurators/__init__.py
File lib/vdsm/tool/configurators/__init__.py:
Line 39: # MAYBE = Module configured before,
Line 40: # configuration validity could not be determined.
Line 41: #
Line 42: # See also --force at configurators.py.
Line 43: YES, NO, MAYBE = list(range(3))
Use tuple
https://gerrit.ovirt.org/#/c/40079/2/tests/miscTests.py
File tests/miscTests.py:
Line 195: return arg
Line 196: # here we launch the maximum threads we can initiate in every
Line 197: # outOfProcess operation + 1. it let us know that oop and itmap operate
Line 198: # properly with their limitations
Line 199: data = frozenset(list(range(oop.HELPERS_PER_DOMAIN + 1)))
Not needed:
>>> frozenset(xrange(10))
frozenset([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Line 200: ret = frozenset(misc.itmap(dummy, data, misc.UNLIMITED_THREADS))
Line 201: self.assertEquals(ret, data)
Line 202:
Line 203: def testMoreThreadsThanArgs(self):
https://gerrit.ovirt.org/#/c/40079/2/tests/samplingTests.py
File tests/samplingTests.py:
Line 245: self.assertEqual(stat.getStats(), (None, None, None))
Line 246: self.assertEqual(stat.getLastSample(), value)
Line 247:
Line 248: def testGetStats(self):
Line 249: values = list(range(42))
tuple
Line 250: stat = sampling.AdvancedStatsFunction(
Line 251: lambda x: x, interval=1, window=2)
Line 252: for val in values:
Line 253: stat(val)
Line 264: bgn, end, diff = stat.getStats()
Line 265: self.assertTrue(diff > 0) # assertGreater requires py >= 2.7
Line 266:
Line 267: def testLastSample(self):
Line 268: values = list(range(42))
tuple
Line 269: stat = sampling.AdvancedStatsFunction(
Line 270: lambda x: x, interval=1, window=2)
Line 271: for val in values:
Line 272: stat(val)
https://gerrit.ovirt.org/#/c/40079/2/vdsm/storage/threadPool.py
File vdsm/storage/threadPool.py:
Line 233: # then sort them
Line 234:
Line 235: def sortTask(data):
Line 236: print("SortTask starting for ", data)
Line 237: numbers = list(range(data[0], data[1]))
tuple
Line 238: for a in numbers:
Line 239: rnd = randrange(0, len(numbers) - 1)
Line 240: a, numbers[rnd] = numbers[rnd], a
Line 241: print("SortTask sorting for ", data)
https://gerrit.ovirt.org/#/c/40079/2/vdsm/virt/guestagent.py
File vdsm/virt/guestagent.py:
Line 42: list(range(8 + 1)) +
Line 43: list(range(0xB, 0xC + 1)) +
Line 44: list(range(0xE, 0x1F + 1)) +
Line 45: list(range(0x7F, 0x84 + 1)) +
Line 46: list(range(0x86, 0x9F + 1)) +
tuple
Line 47: [0xFFFE, 0xFFFF])
Line 48:
Line 49:
Line 50: def _filterXmlChars(u):
https://gerrit.ovirt.org/#/c/40079/2/vdsm_hooks/fakevmstats/after_get_all_vm_stats.py
File vdsm_hooks/fakevmstats/after_get_all_vm_stats.py:
Line 157: # Each vm between 1 to 3 ifaces, not dynamic:
Line 158: netIfaces = []
Line 159: for i in range(1 + (vmDigest.next() % 3)):
Line 160: netif = {}
Line 161: hw = map(lambda x: vmDigest.next(), list(range(6)))
tuple
Line 162: netif['hw'] = ETH_HW_ADDR_FORMAT % (hw[0], hw[1], hw[2], hw[3], hw[4],
Line 163: hw[5])
Line 164: inet = map(lambda x: vmDigest.next(), list(range(4)))
Line 165: netif['inet'] = ['%d.%d.%d.%d' % (inet[0], inet[1], inet[2], inet[3])]
Line 160: netif = {}
Line 161: hw = map(lambda x: vmDigest.next(), list(range(6)))
Line 162: netif['hw'] = ETH_HW_ADDR_FORMAT % (hw[0], hw[1], hw[2], hw[3], hw[4],
Line 163: hw[5])
Line 164: inet = map(lambda x: vmDigest.next(), list(range(4)))
tuple
Line 165: netif['inet'] = ['%d.%d.%d.%d' % (inet[0], inet[1], inet[2], inet[3])]
Line 166: # For simplicty purposes, the ipv6 addresses are transition from ipv4
Line 167: netif['inet6'] = ['0:0:0:0:0:ffff:%x%02x:%x%02x' % (inet[0], inet[1],
Line 168: inet[2], inet[3])]
--
To view, visit https://gerrit.ovirt.org/40079
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I5adaec5e6829dd1d357ae2ef4ec646f625e0ebd4
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Ido Barkan <ibarkan at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list