From bc58e5fa70c3de71b215326c18828d874ad60e9a Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 13 Jun 2013 09:24:08 +0200 Subject: [PATCH] Use Python 3.x compatible octal literals Python 3.x deprecated octal literals in the form 0755. Use 0o755 instead which works at least with Python 2.6 and newer Change-Id: I70dc33cb674499548732408924aa2ae728e17ea3 --- heat_cfntools/cfntools/cfn_helper.py | 4 ++-- heat_cfntools/tests/test_cfn_helper.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/heat_cfntools/cfntools/cfn_helper.py b/heat_cfntools/cfntools/cfn_helper.py index 5fa7b5a..99908bd 100644 --- a/heat_cfntools/cfntools/cfn_helper.py +++ b/heat_cfntools/cfntools/cfn_helper.py @@ -1107,7 +1107,7 @@ class Metadata(object): cache_dir = os.path.dirname(last_path) if not os.path.isdir(cache_dir): try: - os.makedirs(cache_dir, mode=0700) + os.makedirs(cache_dir, mode=0o700) except IOError as e: LOG.warn('could not create metadata cache dir %s [%s]' % (cache_dir, e)) @@ -1117,7 +1117,7 @@ class Metadata(object): with tempfile.NamedTemporaryFile(dir=tmp_dir, mode='wb', delete=False) as cf: - os.chmod(cf.name, 0600) + os.chmod(cf.name, 0o600) cf.write(json.dumps(self._metadata)) os.rename(cf.name, last_path) diff --git a/heat_cfntools/tests/test_cfn_helper.py b/heat_cfntools/tests/test_cfn_helper.py index 843f9e4..22b6b31 100644 --- a/heat_cfntools/tests/test_cfn_helper.py +++ b/heat_cfntools/tests/test_cfn_helper.py @@ -605,9 +605,9 @@ class TestMetadataRetrieve(testtools.TestCase): self.assertTrue(os.path.exists(last_path), "last_metadata file should exist") # Ensure created dirs and file have right perms - self.assertTrue(os.stat(last_path).st_mode & 0600 == 0600) + self.assertTrue(os.stat(last_path).st_mode & 0o600 == 0o600) self.assertTrue( - os.stat(os.path.dirname(last_path)).st_mode & 0700 == 0700) + os.stat(os.path.dirname(last_path)).st_mode & 0o700 == 0o700) def test_is_valid_metadata(self): md_data = {"AWS::CloudFormation::Init": {"config": {"files": {