Exemplo n.º 1
0
def getGroups(prefix="/"):
    """
    Get groups from etc/group
    """
    return filter(None,
           map(lambda x:x.split(':')[0],
           readLinesFile(path.join(prefix,'etc/group'))))
Exemplo n.º 2
0
def getCompositeFromXorgconf(prefix="/"):
    """Get composite value from xorg.conf"""
    xorgConfig = path.join(prefix,
                              "etc/X11/xorg.conf")
    confLines = readLinesFile(xorgConfig)

    flagStartExtensions = False
    lineCompositeTmp = ""
    lineComposite = ""
    for line in confLines:
        line = line.strip()
        if flagStartExtensions:
            if line.startswith('EndSection'):
                lineComposite = lineCompositeTmp
                break
            elif line.startswith('Section'):
                break
            if line.startswith('Option') and '"Composite"' in line:
                lineCompositeTmp = line
        else:
            if line.startswith('Section') and '"Extensions"' in line:
                flagStartExtensions = True
    if lineComposite:
        listOpt = filter(lambda x: x.strip(), lineComposite.split('"'))
        if len(listOpt) == 3:
            ret = listOpt[2].lower()
            if ret in ("on","true","yes","1"):
                return "on"
            elif ret in ("off","false","no","0"):
                return "off"
    return None
Exemplo n.º 3
0
def getUserGroups(userName,prefix="/"):
    """
    Get user groups from /etc/groups
    """
    return map(lambda x:x[0],
           filter(lambda x:len(x)>1 and userName in x[1].split(','),
           map(lambda x:x.split(':')[0::3],
           readLinesFile(path.join(prefix,'etc/group')))))
Exemplo n.º 4
0
def getSupportArch():
    """Get supported architectures by processor.

    Is support processor x86_64 else only i686.
    """
    if filter(lambda x:x.startswith('flags') and " lm " in x,
        readLinesFile('/proc/cpuinfo')):
        return ['i686','x86_64']
    else:
        return ['i686']
Exemplo n.º 5
0
def getVideoFromModules():
    workedModules = map(lambda x:x[0],
                    filter(lambda x:x[1].isdigit() and int(x[1])>0,
                    map(lambda x:x.split()[:3:2],
                    readLinesFile('/proc/modules'))))
    mapModules = {'nouveau':'nouveau',
                  'radeon':'radeon',
                  'i915':'intel',
                  'fglrx':'fglrx',
                  'nvidia':'nvidia',
                  'via':'via',
                  'vmware':'vmware'}
    for module,videodrv in mapModules.items():
        if module in workedModules:
            return videodrv
    else:
        return ""
Exemplo n.º 6
0
def getVideoFromXorgLog(prefix="/",available_drivers=[]):
    """Get video driver from Xorg log"""
    # Try analize Xorg.{DISPLAY}.log
    display = os.environ.get('DISPLAY','0')
    if display and available_drivers:
        reDriver = re.compile('|'.join(map(lambda x: "%s_drv.so"%x,
                                           available_drivers)))
        display_number = re.search(r':(\d+)(\..*)?', display)
        reDriverName = re.compile(r'([^/]+)_drv.so')
        if display_number:
            xorg_log_file = path.join(prefix,'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]
    return ""