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
This commit is contained in:
Dirk Mueller 2013-06-13 09:24:08 +02:00
parent 2d00ede1e6
commit bc58e5fa70
2 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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": {