import fcntl
from functools import wraps
import json
-from log import LOG
+from .log import LOG
class TimeoutError(Exception):
def byteify(data, ignore_dicts=False):
# if this is a unicode string, return its string representation
- if isinstance(data, unicode):
+ if isinstance(data, str):
return data.encode('utf-8')
# if this is a list of values, return list of byteified values
if isinstance(data, list):
# but only if we haven't already byteified it
if isinstance(data, dict) and not ignore_dicts:
return {byteify(key, ignore_dicts=ignore_dicts): byteify(value, ignore_dicts=ignore_dicts)
- for key, value in data.iteritems()}
+ for key, value in list(data.items())}
# if it's anything else, return it in its original form
return data
if nic_slot and nic_ports:
dmidecode = subprocess.check_output(['dmidecode', '-t', 'slot'])
- regex = r"(?<=SlotID:%s).*?(....:..:..\..)" % nic_slot
- match = re.search(regex, dmidecode, flags=re.DOTALL)
+ regex = r"(?<=SlotID:{}).*?(....:..:..\..)".format(nic_slot)
+ match = re.search(regex, dmidecode.decode('utf-8'), flags=re.DOTALL)
if not match:
return None