diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2017-01-08 00:17:32 -0800 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-01-17 23:28:19 -0800 |
commit | adb75cb5685579334c1deab0d17b40a47470249d (patch) | |
tree | 0c06db77e9c07e3cd94ab6492f1f8f76fb52791c | |
parent | 4b706011d16f3dfd4fe0a78c5d8706d69deecdeb (diff) |
heat: convert open to context manager
Change-Id: I5ce6c77839f4104d305d66238bb2c6cbdc39a28c
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
-rw-r--r-- | yardstick/benchmark/contexts/heat.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py index 0b2fbdcd6..79b7472ff 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 |