mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
fix isinstance method call
This commit is contained in:
parent
22cb8f702a
commit
e911db8124
2 changed files with 5 additions and 7 deletions
|
@ -18,7 +18,7 @@ class wvmHostDetails(wvmConnect):
|
|||
"""
|
||||
all_mem = self.wvm.getInfo()[1] * 1048576
|
||||
freemem = self.wvm.getMemoryStats(-1, 0)
|
||||
if isinstance(dict, freemem):
|
||||
if isinstance(freemem, dict):
|
||||
free = (freemem['buffers'] +
|
||||
freemem['free'] +
|
||||
freemem['cached']) * 1024
|
||||
|
@ -36,7 +36,7 @@ class wvmHostDetails(wvmConnect):
|
|||
prev_idle = 0
|
||||
prev_total = 0
|
||||
cpu = self.wvm.getCPUStats(-1, 0)
|
||||
if isinstance(dict, cpu):
|
||||
if isinstance(cpu, dict):
|
||||
for num in range(2):
|
||||
idle = self.wvm.getCPUStats(-1, 0)['idle']
|
||||
total = sum(self.wvm.getCPUStats(-1, 0).values())
|
||||
|
|
|
@ -26,7 +26,6 @@ def randomMAC():
|
|||
|
||||
def randomUUID():
|
||||
"""Generate a random UUID."""
|
||||
|
||||
u = [random.randint(0, 255) for ignore in range(0, 16)]
|
||||
u[6] = (u[6] & 0x0F) | (4 << 4)
|
||||
u[8] = (u[8] & 0x3F) | (2 << 6)
|
||||
|
@ -108,7 +107,7 @@ def get_xpath(doc, path):
|
|||
|
||||
ret = doc.xpath(path)
|
||||
if ret is not None:
|
||||
if isinstance(list, ret):
|
||||
if isinstance(ret, list):
|
||||
if len(ret) >= 1:
|
||||
if hasattr(ret[0], 'text'):
|
||||
result = ret[0].text
|
||||
|
@ -137,11 +136,10 @@ def pretty_bytes(val):
|
|||
|
||||
|
||||
def validate_uuid(val):
|
||||
if not isinstance(str, val):
|
||||
if not isinstance(val, str):
|
||||
raise ValueError("UUID must be a string.")
|
||||
|
||||
form = re.match("[a-fA-F0-9]{8}[-]([a-fA-F0-9]{4}[-]){3}[a-fA-F0-9]{12}$",
|
||||
val)
|
||||
form = re.match("[a-fA-F0-9]{8}[-]([a-fA-F0-9]{4}[-]){3}[a-fA-F0-9]{12}$", val)
|
||||
if form is None:
|
||||
form = re.match("[a-fA-F0-9]{32}$", val)
|
||||
if form is None:
|
||||
|
|
Loading…
Reference in a new issue