Rename all EnvironmentError to OSError.

Change version number to 1.0a2-dev1.
Check only on Python >= 3.3.
This commit is contained in:
grossmj committed 2014-04-02 16:10:59 -06:00
1 parent 20597e29df
commit f4dd096a8b
11 files changed
+40 -30

No files matched your search

+7 -1
View File
@@ -20,6 +20,7 @@ Base class (interface) for modules
"""
import sys
import traceback
import gns3server.jsonrpc as jsonrpc
import multiprocessing
import zmq
@@ -230,7 +231,12 @@ class IModule(multiprocessing.Process):
self.modules[self.name][destination](self, params)
except Exception as e:
log.error("uncaught exception {type}".format(type=type(e)), exc_info=1)
self.send_custom_error("uncaught exception {type}: {string}".format(type=type(e), string=str(e)))
exc_type, exc_value, exc_tb = sys.exc_info()
lines = traceback.format_exception(exc_type, exc_value, exc_tb)
tb = "\n" . join(lines)
self.send_custom_error("uncaught exception {type}: {string}\n{tb}".format(type=type(e),
string=str(e),
tb=tb))
def destinations(self):
"""
+3 -3
View File
@@ -208,7 +208,7 @@ class Dynamips(IModule):
if not os.path.exists(self._working_dir):
try:
os.makedirs(self._working_dir)
except EnvironmentError as e:
except OSError as e:
raise DynamipsError("Could not create working directory {}".format(e))
# check if the working directory is writable
@@ -410,14 +410,14 @@ class Dynamips(IModule):
if not os.path.exists(config_dir):
try:
os.makedirs(config_dir)
except EnvironmentError as e:
except OSError as e:
raise DynamipsError("Could not create configs directory: {}".format(e))
config_path = os.path.join(config_dir, config_filename)
try:
with open(config_path, "w") as f:
log.info("saving startup-config to {}".format(config_path))
f.write(config)
except EnvironmentError as e:
except OSError as e:
raise DynamipsError("Could not save the configuration {}: {}".format(config_path, e))
return "configs" + os.sep + os.path.basename(config_path)
+2 -2
View File
@@ -467,7 +467,7 @@ class VM(object):
with open(config_path, "w") as f:
log.info("saving startup-config to {}".format(router.startup_config))
f.write(config)
except EnvironmentError as e:
except OSError as e:
raise DynamipsError("Could not save the startup configuration {}: {}".format(config_path, e))
if private_config_base64:
@@ -478,7 +478,7 @@ class VM(object):
with open(config_path, "w") as f:
log.info("saving private-config to {}".format(router.private_config))
f.write(config)
except EnvironmentError as e:
except OSError as e:
raise DynamipsError("Could not save the private configuration {}: {}".format(config_path, e))
except DynamipsError as e:
+2 -2
View File
@@ -211,7 +211,7 @@ class Hypervisor(DynamipsHypervisor):
cwd=self._working_dir)
log.info("Dynamips started PID={}".format(self._process.pid))
self._started = True
except EnvironmentError as e:
except OSError as e:
log.error("could not start Dynamips: {}".format(e))
raise DynamipsError("could not start Dynamips: {}".format(e))
@@ -247,7 +247,7 @@ class Hypervisor(DynamipsHypervisor):
try:
with open(self._stdout_file) as file:
output = file.read()
except EnvironmentError as e:
except OSError as e:
log.warn("could not read {}: {}".format(self._stdout_file, e))
return output
@@ -456,7 +456,7 @@ class HypervisorManager(object):
# if not os.path.exists(working_dir):
# try:
# os.makedirs(working_dir)
# except EnvironmentError as e:
# except OSError as e:
# raise DynamipsError("{}".format(e))
hypervisor = Hypervisor(self._path,
+7 -7
View File
@@ -87,8 +87,8 @@ class IOU(IModule):
self._iourc = ""
# check every 5 seconds
self._iou_callback = self.add_periodic_callback(self._check_iou_is_alive, 5000)
self._iou_callback.start()
#self._iou_callback = self.add_periodic_callback(self._check_iou_is_alive, 5000)
#self._iou_callback.start()
def stop(self):
"""
@@ -154,7 +154,7 @@ class IOU(IModule):
try:
log.info("deleting iourc file {}".format(self._iourc))
os.remove(self._iourc)
except EnvironmentError as e:
except OSError as e:
log.warn("could not delete iourc file {}: {}".format(self._iourc, e))
log.info("IOU module has been reset")
@@ -189,7 +189,7 @@ class IOU(IModule):
log.info("saving iourc file content to {}".format(f.name))
f.write(base64iourc)
self._iourc = f.name
except EnvironmentError as e:
except OSError as e:
raise IOUError("Could not save iourc file to {}: {}".format(f.name, e))
if "iouyap" in request and request["iouyap"]:
@@ -244,7 +244,7 @@ class IOU(IModule):
if not os.path.exists(self._working_dir):
try:
os.makedirs(self._working_dir)
except EnvironmentError as e:
except OSError as e:
raise IOUError("Could not create working directory {}".format(e))
iou_instance = IOUDevice(iou_path, self._working_dir, host=self._default_host, name=name)
@@ -333,7 +333,7 @@ class IOU(IModule):
with open(config_path, "w") as f:
log.info("saving startup-config to {}".format(config_path))
f.write(config)
except EnvironmentError as e:
except OSError as e:
raise IOUError("Could not save the configuration {}: {}".format(config_path, e))
request["startup_config"] = os.path.basename(config_path)
if "startup_config" in request:
@@ -544,7 +544,7 @@ class IOU(IModule):
IFF_NO_PI = 0x1000
try:
tun = os.open("/dev/net/tun", os.O_RDWR)
except EnvironmentError as e:
except OSError as e:
raise IOUError("Could not open /dev/net/tun: {}".format(e))
ifr = struct.pack("16sH", tap_device.encode("utf-8"), IFF_TAP | IFF_NO_PI)
try:
+7 -7
View File
@@ -249,7 +249,7 @@ class IOUDevice(object):
if not os.path.exists(working_dir):
try:
os.makedirs(working_dir)
except EnvironmentError as e:
except OSError as e:
raise IOUError("Could not create working directory {}: {}".format(working_dir, e))
self._working_dir = working_dir
@@ -348,7 +348,7 @@ class IOUDevice(object):
config.write(config_file)
log.info("IOU {name} [id={id}]: iouyap.ini updated".format(name=self._name,
id=self._id))
except EnvironmentError as e:
except OSError as e:
raise IOUError("Could not create {}: {}".format(iouyap_ini, e))
def _create_netmap_config(self):
@@ -367,7 +367,7 @@ class IOUDevice(object):
iou_id=self._id))
log.info("IOU {name} [id={id}]: NETMAP file created".format(name=self._name,
id=self._id))
except EnvironmentError as e:
except OSError as e:
raise IOUError("Could not create {}: {}".format(netmap_path, e))
def _start_ioucon(self):
@@ -401,7 +401,7 @@ class IOUDevice(object):
cwd=self._working_dir)
log.info("iouyap started PID={}".format(self._iouyap_process.pid))
except EnvironmentError as e:
except OSError as e:
log.error("could not start iouyap: {}".format(e))
raise IOUError("Could not start iouyap: {}".format(e))
@@ -434,7 +434,7 @@ class IOUDevice(object):
env=env)
log.info("IOU instance {} started PID={}".format(self._id, self._process.pid))
self._started = True
except EnvironmentError as e:
except OSError as e:
log.error("could not start IOU: {}".format(e))
raise IOUError("could not start IOU: {}".format(e))
@@ -493,7 +493,7 @@ class IOUDevice(object):
try:
with open(self._iou_stdout_file) as file:
output = file.read()
except EnvironmentError as e:
except OSError as e:
log.warn("could not read {}: {}".format(self._iou_stdout_file, e))
return output
@@ -508,7 +508,7 @@ class IOUDevice(object):
try:
with open(self._iouyap_stdout_file) as file:
output = file.read()
except EnvironmentError as e:
except OSError as e:
log.warn("could not read {}: {}".format(self._iouyap_stdout_file, e))
return output