summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2017-02-14 06:36:14 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-02-14 06:36:14 +0000
commit03d764791eeb708ade47b5e2196b18ce04552dd1 (patch)
tree14a6330d7c3d5e4ed2c945c435e9372141c88960
parent5c8396ba5bbeb12c70dae6ad3e777a28fefbcb4a (diff)
parentadb75cb5685579334c1deab0d17b40a47470249d (diff)
Merge "heat: convert open to context manager"
-rw-r--r--yardstick/benchmark/contexts/heat.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index 0346efcf4..4e31bdca6 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -94,9 +94,10 @@ class HeatContext(Context):
rsa_key = paramiko.RSAKey.generate(bits=2048, progress_func=None)
rsa_key.write_private_key_file(self.key_filename)
- open(self.key_filename + ".pub", "w").write("%s %s\n" %
- (rsa_key.get_name(),
- rsa_key.get_base64()))
+ print("Writing %s ..." % self.key_filename)
+ with open(self.key_filename + ".pub", "w") as pubkey_file:
+ pubkey_file.write(
+ "%s %s\n" % (rsa_key.get_name(), rsa_key.get_base64()))
del rsa_key
@property