1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Catch OSError exception for subprocess calls.

This commit is contained in:
Jeremy 2014-12-11 12:15:24 -07:00
parent acb5103119
commit 7f37f649da
6 changed files with 13 additions and 13 deletions

View File

@ -212,7 +212,7 @@ class Hypervisor(DynamipsHypervisor):
cwd=self._working_dir)
log.info("Dynamips started PID={}".format(self._process.pid))
self._started = True
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
log.error("could not start Dynamips: {}".format(e))
raise DynamipsError("could not start Dynamips: {}".format(e))

View File

@ -509,7 +509,7 @@ class IOUDevice(object):
cwd=self._working_dir)
log.info("iouyap started PID={}".format(self._iouyap_process.pid))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
iouyap_stdout = self.read_iouyap_stdout()
log.error("could not start iouyap: {}\n{}".format(e, iouyap_stdout))
raise IOUError("Could not start iouyap: {}\n{}".format(e, iouyap_stdout))
@ -583,7 +583,7 @@ class IOUDevice(object):
self._started = True
except FileNotFoundError as e:
raise IOUError("could not start IOU: {}: 32-bit binary support is probably not installed".format(e))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
iou_stdout = self.read_iou_stdout()
log.error("could not start IOU {}: {}\n{}".format(self._path, e, iou_stdout))
raise IOUError("could not start IOU {}: {}\n{}".format(self._path, e, iou_stdout))
@ -761,7 +761,7 @@ class IOUDevice(object):
command.extend(["-l"])
else:
raise IOUError("layer 1 keepalive messages are not supported by {}".format(os.path.basename(self._path)))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
log.warn("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e))
def _build_command(self):

View File

@ -678,7 +678,7 @@ class QemuVM(object):
priority = 0
try:
subprocess.call(['renice', '-n', str(priority), '-p', str(self._process.pid)])
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
log.error("could not change process priority for QEMU VM {}: {}".format(self._name, e))
def _stop_cpulimit(self):
@ -710,7 +710,7 @@ class QemuVM(object):
log.info("CPU throttled to {}%".format(self._cpu_throttling))
except FileNotFoundError:
raise QemuError("cpulimit could not be found, please install it or deactivate CPU throttling")
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could not throttle CPU: {}".format(e))
def start(self):
@ -796,7 +796,7 @@ class QemuVM(object):
cwd=self._working_dir)
log.info("QEMU VM instance {} started PID={}".format(self._id, self._process.pid))
self._started = True
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
stdout = self.read_stdout()
log.error("could not start QEMU {}: {}\n{}".format(self._qemu_path, e, stdout))
raise QemuError("could not start QEMU {}: {}\n{}".format(self._qemu_path, e, stdout))
@ -971,7 +971,7 @@ class QemuVM(object):
retcode = subprocess.call([qemu_img_path, "create", "-f", "qcow2", hda_disk, "128M"])
log.info("{} returned with {}".format(qemu_img_path, retcode))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could not create disk image {}".format(e))
options.extend(["-hda", hda_disk])
@ -983,7 +983,7 @@ class QemuVM(object):
"backing_file={}".format(self._hdb_disk_image),
"-f", "qcow2", hdb_disk])
log.info("{} returned with {}".format(qemu_img_path, retcode))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could not create disk image {}".format(e))
options.extend(["-hdb", hdb_disk])

View File

@ -722,7 +722,7 @@ class VirtualBox(IModule):
try:
result = subprocess.check_output(command, stderr=subprocess.STDOUT, timeout=30)
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise VirtualBoxError("Could not execute VBoxManage {}".format(e))
return result.decode("utf-8")

View File

@ -558,7 +558,7 @@ class VirtualBoxVM(object):
raise VirtualBoxError("{}".format(virtualbox_error))
else:
raise VirtualBoxError("{}".format(e))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise VirtualBoxError("Could not execute VBoxManage: {}".format(e))
return result.decode("utf-8").splitlines()

View File

@ -346,7 +346,7 @@ class VPCSDevice(object):
raise VPCSError("VPCS executable version must be >= 0.5b1")
else:
raise VPCSError("Could not determine the VPCS version for {}".format(self._path))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise VPCSError("Error while looking for the VPCS version: {}".format(e))
def start(self):
@ -386,7 +386,7 @@ class VPCSDevice(object):
creationflags=flags)
log.info("VPCS instance {} started PID={}".format(self._id, self._process.pid))
self._started = True
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
vpcs_stdout = self.read_vpcs_stdout()
log.error("could not start VPCS {}: {}\n{}".format(self._path, e, vpcs_stdout))
raise VPCSError("could not start VPCS {}: {}\n{}".format(self._path, e, vpcs_stdout))