From f0a250600a4c0768a724313caa3db99f0272c66d Mon Sep 17 00:00:00 2001 From: Max Illfelder Date: Tue, 21 May 2019 13:21:54 -0700 Subject: Update script retrieval for Python 3 support. (#773) Pull request #729 made #723 obsolete. --- .../google_compute_engine/metadata_scripts/script_retriever.py | 2 +- .../metadata_scripts/tests/script_retriever_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/python-google-compute-engine/google_compute_engine') diff --git a/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py b/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py index 5f92de2..c880f49 100644 --- a/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py +++ b/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/script_retriever.py @@ -117,7 +117,7 @@ class ScriptRetriever(object): self.logger.warning('Could not download %s. %s.', url, str(e)) return None - with open(dest, 'wb') as f: + with open(dest, 'w') as f: f.write(content) return dest diff --git a/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/tests/script_retriever_test.py b/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/tests/script_retriever_test.py index 6048f68..b9d9d1b 100644 --- a/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/tests/script_retriever_test.py +++ b/packages/python-google-compute-engine/google_compute_engine/metadata_scripts/tests/script_retriever_test.py @@ -62,7 +62,7 @@ class ScriptRetrieverTest(unittest.TestCase): urlopen_read = mock_urlopen().read(return_value=b'foo').decode() self.mock_logger.warning.assert_not_called() - mock_open.assert_called_once_with(self.dest, 'wb') + mock_open.assert_called_once_with(self.dest, 'w') handle = mock_open() handle.write.assert_called_once_with(urlopen_read) -- cgit v1.2.1