mirror of
https://github.com/gryf/boxpy.git
synced 2025-12-20 05:57:59 +01:00
Fixed minor linting issues
This commit is contained in:
26
box.py
26
box.py
@@ -516,6 +516,7 @@ class VBoxManage:
|
|||||||
def __init__(self, name_or_uuid=None):
|
def __init__(self, name_or_uuid=None):
|
||||||
self.name_or_uuid = name_or_uuid
|
self.name_or_uuid = name_or_uuid
|
||||||
self.vm_info = {}
|
self.vm_info = {}
|
||||||
|
self.uuid = None
|
||||||
|
|
||||||
def get_vm_base_path(self):
|
def get_vm_base_path(self):
|
||||||
path = self._get_vm_config()
|
path = self._get_vm_config()
|
||||||
@@ -582,14 +583,14 @@ class VBoxManage:
|
|||||||
self.vm_info[key] = val
|
self.vm_info[key] = val
|
||||||
|
|
||||||
images = []
|
images = []
|
||||||
for sc in gebtn('StorageController'):
|
for storage in gebtn('StorageController'):
|
||||||
for ad in sc.getElementsByTagName('AttachedDevice'):
|
for adev in storage.getElementsByTagName('AttachedDevice'):
|
||||||
if not ad.getElementsByTagName('Image'):
|
if not adev.getElementsByTagName('Image'):
|
||||||
continue
|
continue
|
||||||
image = ad.getElementsByTagName('Image')[0]
|
image = adev.getElementsByTagName('Image')[0]
|
||||||
type_ = ad.getAttribute('type')
|
type_ = adev.getAttribute('type')
|
||||||
uuid = image.getAttribute('uuid')[1:-1]
|
uuid_ = image.getAttribute('uuid')[1:-1]
|
||||||
images.append({'type': type_, 'uuid': uuid})
|
images.append({'type': type_, 'uuid': uuid_})
|
||||||
|
|
||||||
self.vm_info['media'] = images
|
self.vm_info['media'] = images
|
||||||
|
|
||||||
@@ -637,7 +638,6 @@ class VBoxManage:
|
|||||||
return 7
|
return 7
|
||||||
|
|
||||||
def create(self, conf):
|
def create(self, conf):
|
||||||
self.uuid = None
|
|
||||||
memory = convert_to_mega(conf.memory)
|
memory = convert_to_mega(conf.memory)
|
||||||
|
|
||||||
out = Run(['vboxmanage', 'createvm', '--name', self.name_or_uuid,
|
out = Run(['vboxmanage', 'createvm', '--name', self.name_or_uuid,
|
||||||
@@ -782,14 +782,14 @@ class VBoxManage:
|
|||||||
if info.returncode != 0:
|
if info.returncode != 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for line in info.stdout.split('\n'):
|
for info_line in info.stdout.split('\n'):
|
||||||
if line.startswith('Config file:'):
|
if info_line.startswith('Config file:'):
|
||||||
config = line.split('Config ' 'file:')[1].strip()
|
config = info_line.split('Config ' 'file:')[1].strip()
|
||||||
|
|
||||||
dom = xml.dom.minidom.parse(config)
|
dom = xml.dom.minidom.parse(config)
|
||||||
gebtn = dom.getElementsByTagName
|
gebtn = dom.getElementsByTagName
|
||||||
|
|
||||||
if len(gebtn('Forwarding')):
|
if gebtn('Forwarding'):
|
||||||
for rule in gebtn('Forwarding'):
|
for rule in gebtn('Forwarding'):
|
||||||
used_ports[vm_name] = rule.getAttribute('hostport')
|
used_ports[vm_name] = rule.getAttribute('hostport')
|
||||||
return used_ports
|
return used_ports
|
||||||
@@ -799,8 +799,6 @@ class VBoxManage:
|
|||||||
return self.vm_info['config_file']
|
return self.vm_info['config_file']
|
||||||
|
|
||||||
self.get_vm_info()
|
self.get_vm_info()
|
||||||
|
|
||||||
if self.vm_info.get('config_file'):
|
|
||||||
return self.vm_info['config_file']
|
return self.vm_info['config_file']
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user