Пример #1
0
    def get_ionice(self,
                   section=constants.SECTION_CONFIGURATION_GLOBAL) -> IONice:
        if section not in self.configuration:
            return None

        configuration = self.configuration[section]
        if constants.PARAMETER_IONICE not in configuration:
            return None

        ionice = self.validate_global_configuration_option(
            constants.PARAMETER_IONICE,
            configuration[constants.PARAMETER_IONICE])
        option = None
        if ionice and ionice.value:
            io_class = None
            io_level = None
            if constants.PARAMETER_IONICE_CLASS in configuration:
                io_class = self.validate_global_configuration_option(
                    constants.PARAMETER_IONICE_CLASS,
                    configuration[constants.PARAMETER_IONICE_CLASS])
            if constants.PARAMETER_IONICE_LEVEL in configuration:
                io_level = self.validate_global_configuration_option(
                    constants.PARAMETER_IONICE_LEVEL,
                    configuration[constants.PARAMETER_IONICE_LEVEL])

            if io_class and io_level:
                option = IONice(io_class.value, io_level.value)
            elif io_class:
                option = IONice(io_class=io_class.value)
            elif io_level:
                option = IONice(io_level=io_level.value)
            else:
                option = IONice()

        return option
Пример #2
0
 def test_can_get_command_with_default_value(self):
     ionice = IONice()
     command = ionice.get_command('Linux')
     self.assertEqual(command, "ionice -c 2 -n 4")
Пример #3
0
 def test_can_get_command_will_not_throw_exception_and_return_empty_string(self):
     ionice = IONice(ignore_failure=True)
     command = ionice.get_command('Windows')
     self.assertEqual(command, "")
Пример #4
0
 def test_can_get_command_with_ignore_failure(self):
     ionice = IONice(io_class=3, ignore_failure=True)
     command = ionice.get_command('Linux')
     self.assertEqual(command, "ionice -c 3 -t")
Пример #5
0
 def test_can_get_command_for_idle_class(self):
     ionice = IONice(3)
     command = ionice.get_command('Linux')
     self.assertEqual(command, "ionice -c 3")
Пример #6
0
 def test_can_get_command_for_besteffort_class(self):
     ionice = IONice(2)
     command = ionice.get_command('Linux')
     self.assertEqual(command, "ionice -c 2 -n 4")
Пример #7
0
 def test_can_get_command_for_realtime_class(self):
     ionice = IONice(1)
     command = ionice.get_command('Linux')
     self.assertEqual(command, "ionice -c 1 -n 4")