From 9a944e37498da28bcefdd73936a5190ab73c0da2 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Fri, 20 Apr 2012 15:35:13 +0400 Subject: [PATCH] Optimize get information from image (available vidoe and netconf) --- install/variables/X11.py | 23 ++++++++++++++++------- install/variables/net.py | 34 ++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/install/variables/X11.py b/install/variables/X11.py index 4fc04f2..cc05ca9 100644 --- a/install/variables/X11.py +++ b/install/variables/X11.py @@ -98,6 +98,21 @@ class VariableOsInstallX11Resolution(ResolutionVariable): else: return self.choice()[-1] +class VariableOsInstallX11VideoAvailable(VideoVariable): + """ + Get available (already installed or installable drivers + """ + type = "list" + + def get(self): + image = self.Get('cl_image') + if image: + with image as distr: + distrPath = image.getDirectory() + if isPkgInstalled('xorg-server',prefix=distrPath): + return getAvailableVideo(prefix=distrPath)+['other'] + return [] + class VariableOsInstallX11VideoDrv(VideoVariable): """ Video driver used by xorg @@ -112,13 +127,7 @@ class VariableOsInstallX11VideoDrv(VideoVariable): def choice(self): """Get available (already installed or installable drivers""" - image = self.Get('cl_image') - if image: - with image as distr: - distrPath = image.getDirectory() - if isPkgInstalled('xorg-server',prefix=distrPath): - return getAvailableVideo(prefix=distrPath)+['other'] - return [] + return self.Get('os_install_x11_video_available') def get(self): # get available videodriver list from install or configure distributive diff --git a/install/variables/net.py b/install/variables/net.py index 6649071..b928fd7 100644 --- a/install/variables/net.py +++ b/install/variables/net.py @@ -520,6 +520,26 @@ class VariableOsInstallNetNmroute(VariableOsInstallNetRoute): x[NET]!="default",routeMatrix)))) return self.performRouteData(getRouteForInterfaceNM) +class VariableOsInstallNetConfAvailable(NetVariable): + """ + Available net configuration + """ + type = "list" + + def get(self): + mapNetConf = (('networkmanager','net-misc/networkmanager', + _("NetworkManager")), + ('openrc','',_('OpenRC'))) + image = self.Get('cl_image') + if image: + with image as distr: + distrPath = image.getDirectory() + return map(itemgetter(0,2), + filter(lambda x:not x[1] or isPkgInstalled(x[1], + prefix=distrPath), + mapNetConf)) + return map(itemgetter(0,2),mapNetConf[-1:]) + class VariableOsInstallNetConf(NetVariable): """ Net setup (networkmanager or openrc) @@ -541,24 +561,14 @@ class VariableOsInstallNetConf(NetVariable): nm = "networkmanager" else: nm = "" - for val,comment in self.choice(): + for val,comment in self.Get('os_install_net_conf_available'): if nm == val: return nm else: return "openrc" def choice(self): - mapNetConf = (('networkmanager','net-misc/networkmanager',_("NetworkManager")), - ('openrc','',_('OpenRC'))) - image = self.Get('cl_image') - if image: - with image as distr: - distrPath = image.getDirectory() - return map(itemgetter(0,2), - filter(lambda x:not x[1] or isPkgInstalled(x[1], - prefix=distrPath), - mapNetConf)) - return map(itemgetter(0,2),mapNetConf[-1:]) + return self.Get('os_install_net_conf_available') class VariableOsInstallNetDnsSearch(NetVariable): """