Replace decode errors when reading device configs.

This commit is contained in:
grossmj committed 2014-05-29 12:59:13 -06:00
1 parent e817c13738
commit 61ef750da3
7 files changed
+11 -11

No files matched your search

+1 -1
View File
@@ -474,7 +474,7 @@ class Dynamips(IModule):
raise DynamipsError("Could not create configs directory: {}".format(e))
try:
with open(local_base_config, "r") as f:
with open(local_base_config, "r", errors="replace") as f:
config = f.read()
with open(config_path, "w") as f:
config = "!\n" + config.replace("\r", "")
+1 -1
View File
@@ -251,7 +251,7 @@ class Hypervisor(DynamipsHypervisor):
output = ""
if self._stdout_file and os.access(self._stdout_file, os.R_OK):
try:
with open(self._stdout_file) as file:
with open(self._stdout_file, errors="replace") as file:
output = file.read()
except OSError as e:
log.warn("could not read {}: {}".format(self._stdout_file, e))
+2 -2
View File
@@ -223,7 +223,7 @@ class Router(object):
startup_config_path = os.path.join(self.hypervisor.working_dir, "configs", "{}.cfg".format(self.name))
if os.path.isfile(startup_config_path):
try:
with open(startup_config_path, "r+") as f:
with open(startup_config_path, "r+", errors="replace") as f:
old_config = f.read()
new_config = old_config.replace(self.name, new_name)
f.seek(0)
@@ -239,7 +239,7 @@ class Router(object):
private_config_path = os.path.join(self.hypervisor.working_dir, "configs", "{}-private.cfg".format(self.name))
if os.path.isfile(private_config_path):
try:
with open(private_config_path, "r+") as f:
with open(private_config_path, "r+", errors="replace") as f:
old_config = f.read()
new_config = old_config.replace(self.name, new_name)
f.seek(0)