diff options
| -rw-r--r-- | .bzrignore | 1 | ||||
| -rw-r--r-- | cloudinit/distros/__init__.py | 2 | ||||
| -rw-r--r-- | cloudinit/util.py | 8 | ||||
| -rw-r--r-- | tests/unittests/test__init__.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_data.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_datasource/test_altcloud.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_datasource/test_azure.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_distros/test_netconfig.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_handler/test_handler_ca_certs.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_handler/test_handler_growpart.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_runs/test_simple_run.py | 2 | ||||
| -rw-r--r-- | tests/unittests/test_util.py | 6 | 
12 files changed, 17 insertions, 16 deletions
| @@ -1,3 +1,4 @@  .tox  dist  cloud_init.egg-info +__pycache__ diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 5eab780b..a913e15a 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -272,7 +272,7 @@ class Distro(object):              if header:                  contents.write("%s\n" % (header))              contents.write("%s\n" % (eh)) -            util.write_file(self.hosts_fn, contents.getvalue(), mode=0644) +            util.write_file(self.hosts_fn, contents.getvalue(), mode=0o644)      def _bring_up_interface(self, device_name):          cmd = ['ifup', device_name] diff --git a/cloudinit/util.py b/cloudinit/util.py index bf8e7d80..9efc704a 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1250,7 +1250,7 @@ def rename(src, dest):      os.rename(src, dest) -def ensure_dirs(dirlist, mode=0755): +def ensure_dirs(dirlist, mode=0o755):      for d in dirlist:          ensure_dir(d, mode) @@ -1264,7 +1264,7 @@ def read_write_cmdline_url(target_fn):              return          try:              if key and content: -                write_file(target_fn, content, mode=0600) +                write_file(target_fn, content, mode=0o600)                  LOG.debug(("Wrote to %s with contents of command line"                            " url %s (len=%s)"), target_fn, url, len(content))              elif key and not content: @@ -1489,7 +1489,7 @@ def append_file(path, content):      write_file(path, content, omode="ab", mode=None) -def ensure_file(path, mode=0644): +def ensure_file(path, mode=0o644):      write_file(path, content='', omode="ab", mode=mode) @@ -1507,7 +1507,7 @@ def chmod(path, mode):              os.chmod(path, real_mode) -def write_file(filename, content, mode=0644, omode="wb"): +def write_file(filename, content, mode=0o644, omode="wb"):      """      Writes a file with the given content and sets the file mode as specified.      Resotres the SELinux context if possible. diff --git a/tests/unittests/test__init__.py b/tests/unittests/test__init__.py index 17965488..48db1a5e 100644 --- a/tests/unittests/test__init__.py +++ b/tests/unittests/test__init__.py @@ -48,7 +48,7 @@ class TestWalkerHandleHandler(MockerTestCase):          # Mock the write_file function          write_file_mock = self.mocker.replace(util.write_file,                                                passthrough=False) -        write_file_mock(expected_file_fullname, self.payload, 0600) +        write_file_mock(expected_file_fullname, self.payload, 0o600)      def test_no_errors(self):          """Payload gets written to file and added to C{pdata}.""" diff --git a/tests/unittests/test_data.py b/tests/unittests/test_data.py index fd6bd8a1..5517f0b4 100644 --- a/tests/unittests/test_data.py +++ b/tests/unittests/test_data.py @@ -337,7 +337,7 @@ p: 1          mock_write = self.mocker.replace("cloudinit.util.write_file",                                           passthrough=False) -        mock_write(ci.paths.get_ipath("cloud_config"), "", 0600) +        mock_write(ci.paths.get_ipath("cloud_config"), "", 0o600)          self.mocker.replay()          log_file = self.capture_log(logging.WARNING) diff --git a/tests/unittests/test_datasource/test_altcloud.py b/tests/unittests/test_datasource/test_altcloud.py index eaaa90e6..9d8a4a20 100644 --- a/tests/unittests/test_datasource/test_altcloud.py +++ b/tests/unittests/test_datasource/test_altcloud.py @@ -45,7 +45,7 @@ def _write_cloud_info_file(value):      cifile = open(cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE, 'w')      cifile.write(value)      cifile.close() -    os.chmod(cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE, 0664) +    os.chmod(cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE, 0o664)  def _remove_cloud_info_file(): diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py index e992a006..6e007a95 100644 --- a/tests/unittests/test_datasource/test_azure.py +++ b/tests/unittests/test_datasource/test_azure.py @@ -153,7 +153,7 @@ class TestAzureDataSource(MockerTestCase):          ret = dsrc.get_data()          self.assertTrue(ret)          self.assertTrue(os.path.isdir(self.waagent_d)) -        self.assertEqual(stat.S_IMODE(os.stat(self.waagent_d).st_mode), 0700) +        self.assertEqual(stat.S_IMODE(os.stat(self.waagent_d).st_mode), 0o700)      def test_user_cfg_set_agent_command_plain(self):          # set dscfg in via plaintext diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py index 193338e8..47de034b 100644 --- a/tests/unittests/test_distros/test_netconfig.py +++ b/tests/unittests/test_distros/test_netconfig.py @@ -96,7 +96,7 @@ class TestNetCfgDistro(MockerTestCase):          write_bufs = {} -        def replace_write(filename, content, mode=0644, omode="wb"): +        def replace_write(filename, content, mode=0o644, omode="wb"):              buf = WriteBuffer()              buf.mode = mode              buf.omode = omode diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py index 0558023a..75df807e 100644 --- a/tests/unittests/test_handler/test_handler_ca_certs.py +++ b/tests/unittests/test_handler/test_handler_ca_certs.py @@ -150,7 +150,7 @@ class TestAddCaCerts(MockerTestCase):          mock_load = self.mocker.replace(util.load_file, passthrough=False)          mock_write("/usr/share/ca-certificates/cloud-init-ca-certs.crt", -                   cert, mode=0644) +                   cert, mode=0o644)          mock_load("/etc/ca-certificates.conf")          self.mocker.result(ca_certs_content) diff --git a/tests/unittests/test_handler/test_handler_growpart.py b/tests/unittests/test_handler/test_handler_growpart.py index 5d0636d1..3056320d 100644 --- a/tests/unittests/test_handler/test_handler_growpart.py +++ b/tests/unittests/test_handler/test_handler_growpart.py @@ -145,7 +145,7 @@ class TestResize(MockerTestCase):          # this patches out devent2dev, os.stat, and device_part_info          # so in the end, doesn't test a lot          devs = ["/dev/XXda1", "/dev/YYda2"] -        devstat_ret = Bunch(st_mode=25008, st_ino=6078, st_dev=5L, +        devstat_ret = Bunch(st_mode=25008, st_ino=6078, st_dev=5,                              st_nlink=1, st_uid=0, st_gid=6, st_size=0,                              st_atime=0, st_mtime=0, st_ctime=0)          enoent = ["/dev/NOENT"] diff --git a/tests/unittests/test_runs/test_simple_run.py b/tests/unittests/test_runs/test_simple_run.py index c9ba949e..2d51a337 100644 --- a/tests/unittests/test_runs/test_simple_run.py +++ b/tests/unittests/test_runs/test_simple_run.py @@ -41,7 +41,7 @@ class TestSimpleRun(helpers.FilesystemMockingTestCase):                  {                      'path': '/etc/blah.ini',                      'content': 'blah', -                    'permissions': 0755, +                    'permissions': 0o755,                  },              ],              'cloud_init_modules': ['write-files'], diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 35e92445..203445b7 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -79,7 +79,7 @@ class TestWriteFile(MockerTestCase):              create_contents = f.read()              self.assertEqual(contents, create_contents)          file_stat = os.stat(path) -        self.assertEqual(0644, stat.S_IMODE(file_stat.st_mode)) +        self.assertEqual(0o644, stat.S_IMODE(file_stat.st_mode))      def test_dir_is_created_if_required(self):          """Verifiy that directories are created is required.""" @@ -97,12 +97,12 @@ class TestWriteFile(MockerTestCase):          path = os.path.join(self.tmp, "NewFile.txt")          contents = "Hey there" -        util.write_file(path, contents, mode=0666) +        util.write_file(path, contents, mode=0o666)          self.assertTrue(os.path.exists(path))          self.assertTrue(os.path.isfile(path))          file_stat = os.stat(path) -        self.assertEqual(0666, stat.S_IMODE(file_stat.st_mode)) +        self.assertEqual(0o666, stat.S_IMODE(file_stat.st_mode))      def test_custom_omode(self):          """Verify custom omode works properly.""" | 
