1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-01 04:38:12 +00:00

Fix crash when virtualbox list of VMS return an empty line

Fix #206
This commit is contained in:
Julien Duponchelle 2015-06-03 11:59:53 +02:00
parent a1bc815f63
commit b344def887
2 changed files with 3 additions and 3 deletions

View File

@ -168,7 +168,7 @@ class VirtualBox(BaseManager):
vms = [] vms = []
result = yield from self.execute("list", ["vms"]) result = yield from self.execute("list", ["vms"])
for line in result: for line in result:
if line[0] != '"' or line[-1:] != "}": if len(line) == 0 or line[0] != '"' or line[-1:] != "}":
continue # Broken output (perhaps a carriage return in VM name continue # Broken output (perhaps a carriage return in VM name
vmname, _ = line.rsplit(' ', 1) vmname, _ = line.rsplit(' ', 1)
vmname = vmname.strip('"') vmname = vmname.strip('"')

View File

@ -75,9 +75,9 @@ def test_get_list(manager, loop):
vm_list = ['"Windows 8.1" {27b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}', vm_list = ['"Windows 8.1" {27b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}',
'"Carriage', '"Carriage',
'Return" {27b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}', 'Return" {27b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}',
'',
'"<inaccessible>" {42b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}', '"<inaccessible>" {42b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}',
'"Linux Microcore 4.7.1" {ccd8c50b-c172-457d-99fa-dd69371ede0e}' '"Linux Microcore 4.7.1" {ccd8c50b-c172-457d-99fa-dd69371ede0e}']
]
@asyncio.coroutine @asyncio.coroutine
def execute_mock(cmd, args): def execute_mock(cmd, args):