From 0101e2e932564c2534f0c2eb0e1601453eb6a77e Mon Sep 17 00:00:00 2001 From: Vu Cong Tuan Date: Thu, 5 Jul 2018 10:43:25 +0700 Subject: [PATCH] Replace file() with open() for Python 3 compatibility The built-in named 'file' has been removed since Python 3.0 [1] This patch replaces it by 'open' which is the same under Python 2 and 3. [1] https://docs.python.org/release/3.0/whatsnew/3.0.html#builtins Change-Id: Id39efad099358a76743693cc6e32bddca57e8e45 --- os_xenapi/dom0/etc/xapi.d/plugins/xenhost.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os_xenapi/dom0/etc/xapi.d/plugins/xenhost.py b/os_xenapi/dom0/etc/xapi.d/plugins/xenhost.py index 0290d3e..71e6f37 100644 --- a/os_xenapi/dom0/etc/xapi.d/plugins/xenhost.py +++ b/os_xenapi/dom0/etc/xapi.d/plugins/xenhost.py @@ -132,7 +132,7 @@ def set_host_enabled(self, arg_dict): def _write_config_dict(dct): - conf_file = file(config_file_path, "w") + conf_file = open(config_file_path, 'w') json.dump(dct, conf_file) conf_file.close() @@ -144,7 +144,7 @@ def _get_config_dict(): is returned. """ try: - conf_file = file(config_file_path) + conf_file = open(config_file_path, 'r') config_dct = json.load(conf_file) conf_file.close() except IOError: