def get_cl_assemble_profile(self): """Get available profiles""" lines = [] for profileDesc in ['/usr/portage/profiles/profiles.desc', '/var/lib/layman/calculate/profiles/profiles.desc']: lines += map(lambda x:x, readLinesFile(profileDesc)) profiles = map(lambda x:filter(lambda x:x,x.split()), filter(lambda x:x.strip() and not x.startswith("#"), lines)) gentooarch = self.Get('os_assemble_gentoo_arch') if gentooarch == "amd64": addonArch = map(lambda x:x[1],filter(lambda x:x[0] == "ia64", profiles)) else: addonArch = [] return sorted(map(lambda x:x[1], filter(lambda x:x[0] == gentooarch,profiles))) \ + addonArch
def get_os_x11_video_drv(self): """Get video driver used by xorg""" xorg_conf = '/etc/X11/xorg.conf' # Try analize Xorg.{DISPLAY}.log display = os.environ.get('DISPLAY') list_available_drivers = \ getAvailableVideo(prefix=self.Get('cl_chroot_path')) if display and list_available_drivers: reDriver = re.compile('|'.join(map(lambda x: "%s_drv.so"%x, list_available_drivers))) display_number = re.search(r':(\d+)(\..*)?', display) reDriverName = re.compile(r'([^/]+)_drv.so') if display_number: xorg_log_file = '/var/log/Xorg.%s.log' % \ display_number.group(1) if path.exists(xorg_log_file): matchStrs = \ map(lambda x:x.group(1), filter(lambda x:x, map(reDriverName.search, filter(lambda x:"drv" in x and reDriver.search(x), readLinesFile(xorg_log_file))))) if matchStrs: return matchStrs[-1] # analize /etc/X11/xorg.conf if path.exists(xorg_conf): matchSect = re.search(r'Section "Device".*?EndSection', open('/etc/X11/xorg.conf').read(),re.S) if matchSect: resDriver = re.search(r'^\s*Driver\s*"([^"]+)"', matchSect.group(0),re.M) if resDriver and resDriver.group(1) in list_available_drivers: return resDriver.group(1) videoVal = self.getValueFromCmdLine("calculate","video") videoVal = {'i915':'intel'}.get(videoVal,videoVal) if not isPkgInstalled('xorg-server') or \ videoVal in list_available_drivers: return videoVal return self.getVideoByDefault(list_available_drivers)