From 1acc9398d5e2146198a8099cb0d0575cea6cbbcc Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Fri, 3 Apr 2015 12:13:07 +0200 Subject: [PATCH] Fix encoding error when saving dynamips configuration Fix #134 --- gns3server/modules/dynamips/nodes/router.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gns3server/modules/dynamips/nodes/router.py b/gns3server/modules/dynamips/nodes/router.py index a6a54312..568a11f6 100644 --- a/gns3server/modules/dynamips/nodes/router.py +++ b/gns3server/modules/dynamips/nodes/router.py @@ -1500,9 +1500,9 @@ class Router(BaseVM): config = base64.b64decode(startup_config_base64).decode(errors='replace') config = "!\n" + config.replace("\r", "") config_path = os.path.join(module_workdir, self.startup_config) - with open(config_path, "w") as f: + with open(config_path, "wb") as f: log.info("saving startup-config to {}".format(self.startup_config)) - f.write(config) + f.write(config.encode("utf-8")) except (binascii.Error, OSError) as e: raise DynamipsError("Could not save the startup configuration {}: {}".format(config_path, e)) @@ -1511,9 +1511,9 @@ class Router(BaseVM): config = base64.b64decode(private_config_base64).decode(errors='replace') config = "!\n" + config.replace("\r", "") config_path = os.path.join(module_workdir, self.private_config) - with open(config_path, "w") as f: + with open(config_path, "wb") as f: log.info("saving private-config to {}".format(self.private_config)) - f.write(config) + f.write(config.encode("utf-8")) except (binascii.Error, OSError) as e: raise DynamipsError("Could not save the private configuration {}: {}".format(config_path, e))