def setup_locale(self): """ Setup UTF8 system wide locale """ if 'locale' in self.preferences: if 'POSIX' in self.preferences['locale'].split(','): locale = 'POSIX' else: locale = '{0}.UTF-8'.format( self.preferences['locale'].split(',')[0]) log.info('Setting up locale: %s', self.preferences['locale']) if CommandCapabilities.has_option_in_help('systemd-firstboot', '--locale', root=self.root_dir, raise_on_error=False): Path.wipe(self.root_dir + '/etc/locale.conf') Command.run([ 'chroot', self.root_dir, 'systemd-firstboot', '--locale=' + locale ]) if os.path.exists(self.root_dir + '/etc/sysconfig/language'): Shell.run_common_function('baseUpdateSysConfig', [ self.root_dir + '/etc/sysconfig/language', 'RC_LANG', locale ])
def setup_keyboard_map(self): """ Setup console keyboard """ if 'keytable' in self.preferences: log.info('Setting up keytable: {0}'.format( self.preferences['keytable'])) if CommandCapabilities.has_option_in_help('systemd-firstboot', '--keymap', root=self.root_dir, raise_on_error=False): Path.wipe(self.root_dir + '/etc/vconsole.conf') Command.run([ 'chroot', self.root_dir, 'systemd-firstboot', '--keymap=' + self.preferences['keytable'] ]) elif os.path.exists(self.root_dir + '/etc/sysconfig/keyboard'): Shell.run_common_function('baseUpdateSysConfig', [ self.root_dir + '/etc/sysconfig/keyboard', 'KEYTABLE', '"' + self.preferences['keytable'] + '"' ]) else: log.warning( 'keyboard setup skipped no capable ' 'systemd-firstboot or etc/sysconfig/keyboard found')
def setup_locale(self): """ Setup UTF8 system wide locale """ if 'locale' in self.preferences: if 'POSIX' in self.preferences['locale'].split(','): locale = 'POSIX' else: locale = '{0}.UTF-8'.format( self.preferences['locale'].split(',')[0] ) log.info('Setting up locale: %s', self.preferences['locale']) if CommandCapabilities.has_option_in_help( 'systemd-firstboot', '--locale', root=self.root_dir, raise_on_error=False ): Path.wipe(self.root_dir + '/etc/locale.conf') Command.run([ 'chroot', self.root_dir, 'systemd-firstboot', '--locale=' + locale ]) elif os.path.exists(self.root_dir + '/etc/sysconfig/language'): Shell.run_common_function( 'baseUpdateSysConfig', [ self.root_dir + '/etc/sysconfig/language', 'RC_LANG', locale ] ) else: log.warning( 'locale setup skipped no capable ' 'systemd-firstboot or etc/sysconfig/language not found' )
def setup_keyboard_map(self): """ Setup console keyboard """ if 'keytable' in self.preferences: log.info( 'Setting up keytable: %s', self.preferences['keytable'] ) if CommandCapabilities.has_option_in_help( 'systemd-firstboot', '--keymap', root=self.root_dir, raise_on_error=False ): Path.wipe(self.root_dir + '/etc/vconsole.conf') Command.run([ 'chroot', self.root_dir, 'systemd-firstboot', '--keymap=' + self.preferences['keytable'] ]) elif os.path.exists(self.root_dir + '/etc/sysconfig/keyboard'): Shell.run_common_function( 'baseUpdateSysConfig', [ self.root_dir + '/etc/sysconfig/keyboard', 'KEYTABLE', '"' + self.preferences['keytable'] + '"' ] ) else: log.warning( 'keyboard setup skipped no capable ' 'systemd-firstboot or etc/sysconfig/keyboard found' )
def test_run_common_function(self, mock_command): Shell.run_common_function('foo', ['"param1"', '"param2"']) command_string = ' '.join([ 'source', Defaults.project_file('config/functions.sh') + ';', 'foo', '"param1"', '"param2"' ]) mock_command.assert_called_once_with(['bash', '-c', command_string])
def test_run_common_function(self, mock_command): Shell.run_common_function('foo', ['"param1"', '"param2"']) command_string = ' '.join( [ 'source', Defaults.project_file('config/functions.sh') + ';', 'foo', '"param1"', '"param2"' ] ) mock_command.assert_called_once_with( ['bash', '-c', command_string] )
def setup_locale(self): """ Setup etc/sysconfig/language UTF8 locale """ if 'locale' in self.preferences: lang_config = self.root_dir + '/etc/sysconfig/language' if os.path.exists(lang_config): log.info('Setting up locale: %s', self.preferences['locale']) Shell.run_common_function('baseUpdateSysConfig', [ lang_config, 'RC_LANG', self.preferences['locale'].split(',')[0] + '.UTF-8' ]) else: log.warning( 'locale setup skipped etc/sysconfig/language not found')
def setup_keyboard_map(self): """ Setup etc/sysconfig/keyboard console keyboard """ if 'keytable' in self.preferences: keyboard_config = self.root_dir + '/etc/sysconfig/keyboard' if os.path.exists(keyboard_config): log.info('Setting up keytable: %s', self.preferences['keytable']) Shell.run_common_function('baseUpdateSysConfig', [ keyboard_config, 'KEYTABLE', '"' + self.preferences['keytable'] + '"' ]) else: log.warning( 'keyboard setup skipped etc/sysconfig/keyboard not found')
def test_run_common_function(self, mock_command): Shell.run_common_function("foo", ['"param1"', '"param2"']) command_string = " ".join( ["source", Defaults.project_file("config/functions.sh") + ";", "foo", '"param1"', '"param2"'] ) mock_command.assert_called_once_with(["bash", "-c", command_string])