Logo Search packages:      
Sourcecode: jockey version File versions  Download package

def jockey::detection::LocalKernelModulesDriverDB::__init__ (   self  ) 

Initialize self.alias_cache.

This maps bus → vendor → modalias → [module].

Definition at line 151 of file detection.py.

00151                       :
        '''Initialize self.alias_cache.
        
        This maps bus → vendor → modalias → [module].
        '''
        # bus -> vendor -> alias -> [module]; vendor == None -> no vendor,
        # or vendor patterns, needs fnmatching
        self.alias_cache = {} 
        # patterns for which we can optimize lookup
        self.vendor_pattern_re = re.compile('(pci|usb):v([0-9A-F]{4,8})(?:d|p)')

        for alias_location in OSLib.inst.modaliases:
            if not os.path.exists(alias_location):
                continue
            if os.path.isdir(alias_location):
                alias_files = [os.path.join(alias_location, f) 
                    for f in sorted(os.listdir(alias_location))]
            else:
                alias_files = [alias_location]

            for alias_file in alias_files:
                logging.debug('reading modalias file ' + alias_file)
                for line in open(alias_file):
                    try:
                        (c, a, m) = line.split()
                    except ValueError:
                        try:
                            (c, m) = line.split()
                            a = None
                        except ValueError:
                            continue

                    if c == 'alias' and a:
                        vp = self.vendor_pattern_re.match(a)
                        if vp:
                            self.alias_cache.setdefault(vp.group(1), {}).setdefault(
                                vp.group(2), {}).setdefault(a, []).append(m)
                        else:
                            colon = a.find(':')
                            if colon > 0:
                                bus = a[:colon]
                            else:
                                bus = None
                            self.alias_cache.setdefault(bus, {}).setdefault(
                                None, {}).setdefault(a, []).append(m)
                    elif c == 'reset':
                        for map in self.alias_cache.itervalues():
                            for vmap in map.itervalues():
                                for k, mods in vmap.iteritems():
                                    try:
                                        mods.remove(m)
                                    except ValueError:
                                        pass

            #for bus, inf in self.alias_cache.iteritems():
            #    print '*********', bus, '*************'
            #    for vendor, alias in inf.iteritems():
            #        print '#', vendor, ':', alias

    def query(self, hwid):


Generated by  Doxygen 1.6.0   Back to index