mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Ignore Unicode errors when executing vboxmanage.
This commit is contained in:
parent
7f37f649da
commit
7785c03eac
@ -474,8 +474,8 @@ class DynamipsHypervisor(object):
|
|||||||
log.debug("sending {}".format(command))
|
log.debug("sending {}".format(command))
|
||||||
self.socket.sendall(command.encode('utf-8'))
|
self.socket.sendall(command.encode('utf-8'))
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise DynamipsError("Lost communication with {host}:{port} :{error}"
|
raise DynamipsError("Lost communication with {host}:{port} :{error}, Dynamips process running: {run}"
|
||||||
.format(host=self._host, port=self._port, error=e))
|
.format(host=self._host, port=self._port, error=e, run=self.is_running()))
|
||||||
|
|
||||||
# Now retrieve the result
|
# Now retrieve the result
|
||||||
data = []
|
data = []
|
||||||
@ -485,16 +485,16 @@ class DynamipsHypervisor(object):
|
|||||||
chunk = self.socket.recv(1024) # match to Dynamips' buffer size
|
chunk = self.socket.recv(1024) # match to Dynamips' buffer size
|
||||||
buf += chunk.decode("utf-8")
|
buf += chunk.decode("utf-8")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise DynamipsError("Communication timed out with {host}:{port} :{error}"
|
raise DynamipsError("Communication timed out with {host}:{port} :{error}, Dynamips process running: {run}"
|
||||||
.format(host=self._host, port=self._port, error=e))
|
.format(host=self._host, port=self._port, error=e, run=self.is_running()))
|
||||||
|
|
||||||
# If the buffer doesn't end in '\n' then we can't be done
|
# If the buffer doesn't end in '\n' then we can't be done
|
||||||
try:
|
try:
|
||||||
if buf[-1] != '\n':
|
if buf[-1] != '\n':
|
||||||
continue
|
continue
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise DynamipsError("Could not communicate with {host}:{port}"
|
raise DynamipsError("Could not communicate with {host}:{port}, Dynamips process running: {run}"
|
||||||
.format(host=self._host, port=self._port))
|
.format(host=self._host, port=self._port, run=self.is_running()))
|
||||||
|
|
||||||
data += buf.split('\r\n')
|
data += buf.split('\r\n')
|
||||||
if data[-1] == '':
|
if data[-1] == '':
|
||||||
@ -502,8 +502,8 @@ class DynamipsHypervisor(object):
|
|||||||
buf = ''
|
buf = ''
|
||||||
|
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
raise DynamipsError("no data returned from {host}:{port}"
|
raise DynamipsError("no data returned from {host}:{port}, Dynamips process running: {run}"
|
||||||
.format(host=self._host, port=self._port))
|
.format(host=self._host, port=self._port, run=self.is_running()))
|
||||||
|
|
||||||
# Does it contain an error code?
|
# Does it contain an error code?
|
||||||
if self.error_re.search(data[-1]):
|
if self.error_re.search(data[-1]):
|
||||||
|
@ -724,7 +724,7 @@ class VirtualBox(IModule):
|
|||||||
result = subprocess.check_output(command, stderr=subprocess.STDOUT, timeout=30)
|
result = subprocess.check_output(command, stderr=subprocess.STDOUT, timeout=30)
|
||||||
except (OSError, subprocess.SubprocessError) as e:
|
except (OSError, subprocess.SubprocessError) as e:
|
||||||
raise VirtualBoxError("Could not execute VBoxManage {}".format(e))
|
raise VirtualBoxError("Could not execute VBoxManage {}".format(e))
|
||||||
return result.decode("utf-8")
|
return result.decode("utf-8", errors="ignore")
|
||||||
|
|
||||||
@IModule.route("virtualbox.vm_list")
|
@IModule.route("virtualbox.vm_list")
|
||||||
def vm_list(self, request):
|
def vm_list(self, request):
|
||||||
|
@ -560,7 +560,7 @@ class VirtualBoxVM(object):
|
|||||||
raise VirtualBoxError("{}".format(e))
|
raise VirtualBoxError("{}".format(e))
|
||||||
except (OSError, subprocess.SubprocessError) as e:
|
except (OSError, subprocess.SubprocessError) as e:
|
||||||
raise VirtualBoxError("Could not execute VBoxManage: {}".format(e))
|
raise VirtualBoxError("Could not execute VBoxManage: {}".format(e))
|
||||||
return result.decode("utf-8").splitlines()
|
return result.decode("utf-8", errors="ignore").splitlines()
|
||||||
|
|
||||||
def _get_vm_info(self):
|
def _get_vm_info(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user