Make sure we don't try to read when opening a file in binary more. Fixes #1301.

This commit is contained in:
grossmj committed 2018-03-07 16:39:04 +07:00
1 parent 419797dd92
commit c93d0d8d12
8 files changed
+36 -26

No files matched your search

+1 -1
View File
@@ -549,7 +549,7 @@ class BaseManager:
# We store the file under his final name only when the upload is finished
tmp_path = path + ".tmp"
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(tmp_path, 'wb+') as f:
with open(tmp_path, 'wb') as f:
while True:
packet = yield from stream.read(4096)
if not packet:
+1 -1
View File
@@ -547,7 +547,7 @@ class Dynamips(BaseManager):
content = content.replace('%h', vm.name)
f.write(content.encode("utf-8"))
except OSError as e:
raise DynamipsError("Could not create config file {}: {}".format(path, e))
raise DynamipsError("Could not create config file '{}': {}".format(path, e))
return os.path.join("configs", os.path.basename(path))
+2 -2
View File
@@ -348,14 +348,14 @@ class IOUVM(BaseNode):
# reload
path = os.path.join(os.path.expanduser("~/"), ".iourc")
try:
with open(path, "wb+") as f:
with open(path, "wb") as f:
f.write(value.encode("utf-8"))
except OSError as e:
raise IOUError("Could not write the iourc file {}: {}".format(path, e))
path = os.path.join(self.temporary_directory, "iourc")
try:
with open(path, "wb+") as f:
with open(path, "wb") as f:
f.write(value.encode("utf-8"))
except OSError as e:
raise IOUError("Could not write the iourc file {}: {}".format(path, e))