Esempio n. 1
0
 def _cleanup_dir_stack(self):
     for location in reversed(self.dir_stack):
         try:
             Path.remove_hierarchy(self.root_dir + location)
         except Exception as e:
             log.warning('Failed to remove directory %s: %s', location,
                         format(e))
     del self.dir_stack[:]
Esempio n. 2
0
 def _cleanup_dir_stack(self):
     for location in reversed(self.dir_stack):
         try:
             Path.remove_hierarchy(self.root_dir + location)
         except Exception as e:
             log.warning(
                 'Failed to remove directory %s: %s', location, format(e)
             )
     del self.dir_stack[:]
Esempio n. 3
0
 def test_remove_hierarchy(self, mock_log_warn, mock_command):
     Path.remove_hierarchy('/my_root/tmp/foo/bar')
     assert mock_command.call_args_list == [
         call(['rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo/bar']),
         call(['rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo'])
     ]
     mock_log_warn.assert_called_once_with(
         'remove_hierarchy: path /my_root/tmp is protected'
     )
Esempio n. 4
0
 def _cleanup_dir_stack(self):
     for location in reversed(self.dir_stack):
         try:
             Path.remove_hierarchy(root=self.root_dir, path=location)
         except Exception as e:
             log.warning(
                 'Failed to remove directory hierarchy {0}: {1}'.format(
                     self.root_dir + location, e))
     del self.dir_stack[:]
Esempio n. 5
0
 def test_remove_hierarchy(self, mock_log_warn, mock_command):
     Path.remove_hierarchy('/my_root/tmp/foo/bar')
     assert mock_command.call_args_list == [
         call(['rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo/bar']),
         call(['rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo'])
     ]
     mock_log_warn.assert_called_once_with(
         'remove_hierarchy: path /my_root/tmp is protected'
     )
Esempio n. 6
0
 def test_remove_hierarchy(self, mock_command):
     Path.remove_hierarchy('/my_root/tmp/foo/bar')
     with self._caplog.at_level(logging.WARNING):
         assert mock_command.call_args_list == [
             call([
                 'rmdir', '--ignore-fail-on-non-empty',
                 '/my_root/tmp/foo/bar'
             ]),
             call([
                 'rmdir', '--ignore-fail-on-non-empty', '/my_root/tmp/foo'
             ])
         ]
         assert 'remove_hierarchy: path /my_root/tmp is protected' in \
             self._caplog.text
Esempio n. 7
0
 def test_remove_hierarchy(self, mock_command):
     Path.remove_hierarchy('foo')
     mock_command.assert_called_once_with(
         ['rmdir', '-p', '--ignore-fail-on-non-empty', 'foo'])
Esempio n. 8
0
 def test_remove_hierarchy(self, mock_command):
     Path.remove_hierarchy('foo')
     mock_command.assert_called_once_with(
         ['rmdir', '-p', '--ignore-fail-on-non-empty', 'foo']
     )