From 6630986bdf3706ed98768841f7f9cc1df98f29ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Mon, 6 Jun 2016 16:48:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B7=D0=B2=D1=83=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/install/variables/audio.py | 51 +++++++++++++++++++++++++++++++++- pym/install/wsdl_install.py | 30 +++++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/pym/install/variables/audio.py b/pym/install/variables/audio.py index f3fe78e..53305d1 100644 --- a/pym/install/variables/audio.py +++ b/pym/install/variables/audio.py @@ -19,13 +19,61 @@ import re from calculate.lib.datavars import (Variable, ReadonlyVariable, ReadonlyTableVariable, FieldValue, HumanReadable) +from calculate.lib.utils.portage import isPkgInstalled from calculate.lib.utils.files import readFile +from calculate.install.distr import DistributiveError from calculate.lib.cl_lang import setLocalTranslate, _ setLocalTranslate('cl_install3', sys.modules[__name__]) +class VariableOsAudio(Variable): + """ + Выбранная аудиосистема + """ + type = "choice" + opt = ['--audio'] + metavalue = "AUDIO" + + def init(self): + self.label = _("Audio system") + self.help = _("set the audio system") + + def get(self): + return self.choice()[0][0] + + def set(self, value): + return {'none': ''}.get(value, value) + + def choice(self): + return self.Get('os_audio_available') or [('',_('None'))] + + +class VariableOsAudioAvailable(Variable): + """ + Доступные звуковые системы + """ + type = "list" + + def get(self): + mapAudioConf = (('pulseaudio', 'media-sound/pulseaudio', + _("PulseAudio")), + ('alsa', 'media-sound/alsa-utils', _('ALSA'))) + image = self.Get('cl_image') + if image: + with image as distr: + try: + distrPath = image.getDirectory() + return map(lambda x:x[0::2], + filter(lambda x: not x[1] or isPkgInstalled(x[1], + prefix=distrPath), + mapAudioConf)) + except DistributiveError as e: + pass + return sorted(map(lambda x:x[0::2], mapNetConf[-1:]), key=lambda x:x[1]) + + class VariableOsAudioData(ReadonlyTableVariable): """ Information about audio cards @@ -99,7 +147,8 @@ class VariableOsAudioDefault(Variable): Current default audio card """ type = "choice" - opt = ['--audio'] + opt = ['--audio-card'] + metavalue = "CARD" def init(self): self.label = _("Default audio card") diff --git a/pym/install/wsdl_install.py b/pym/install/wsdl_install.py index 94f7b39..08905fe 100644 --- a/pym/install/wsdl_install.py +++ b/pym/install/wsdl_install.py @@ -29,7 +29,7 @@ from calculate.core.server.func import WsdlBase from calculate.install.utils.cl_install import ClInstallAction from calculate.install.utils.cl_setup import ( ClSetupLocaleAction, ClSetupVideoAction, ClSetupSystemAction, - ClSetupBootAction, ClSetupNetworkAction, + ClSetupBootAction, ClSetupNetworkAction, ClSetupAudioAction, ClSetupSessionAction) @@ -112,6 +112,9 @@ class Wsdl(WsdlBase): expert=('cl_install_home_crypt_set',), hide=('cl_migrate_data',), brief=('cl_migrate_data_brief',)), + lambda group: group(_("Audio"), + normal=('os_audio',), + expert=('os_audio_default',)), lambda group: group(_("Video"), normal=('os_install_x11_video_drv', 'os_install_x11_composite', @@ -288,6 +291,31 @@ class Wsdl(WsdlBase): 'cl_dispatch_conf', 'cl_verbose_set'), next_label=_("Save"))]}, + { + # настройка звука + 'method_name': "setup_audio", + 'category': __("Configuration"), + 'title': __("Audio"), + 'image': 'audio-card', + 'command': 'cl-setup-audio', + 'gui': True, + 'rights': ['setupaudio'], + 'logic': {'Install': install.Install}, + 'action': ClSetupAudioAction, + 'datavars': "install", + 'native_error': ( + VariableError, DataVarsError, install.InstallError), + 'setvars': {'cl_action!': 'merge', 'cl_merge_pkg!': [None], + 'cl_merge_set!': "on", 'cl_setup': 'audio'}, + 'groups': [ + lambda group: group(_("Audio"), + normal=('os_audio',), + expert=( + 'os_audio_default', + 'cl_templates_locate', + 'cl_dispatch_conf', + 'cl_verbose_set'), + next_label=_("Save"))]}, { # настройка локали 'method_name': "setup_locale",