def create_definitions(self): for sensor in ORDER: for chip in sensors.ChipIterator(): chip_name = sensors.chip_snprintf_name(chip) if self.chips and not any([chip_name.startswith(ex) for ex in self.chips]): continue for feature in sensors.FeatureIterator(chip): sfi = sensors.SubFeatureIterator(chip, feature) vals = list() for sf in sfi: try: vals.append(sensors.get_value(chip, sf.number)) except sensors.SensorsError as error: self.error('{0}: {1}'.format(sf.name, error)) continue if not vals or (vals[0] == 0 and feature.type != 1): continue if TYPE_MAP[feature.type] == sensor: # create chart name = chip_name + '_' + TYPE_MAP[feature.type] if name not in self.order: self.order.append(name) chart_def = list(CHARTS[sensor]['options']) chart_def[1] = chip_name + chart_def[1] self.definitions[name] = {'options': chart_def} self.definitions[name]['lines'] = [] line = list(CHARTS[sensor]['lines'][0]) line[0] = chip_name + '_' + str(feature.name.decode()) line[1] = sensors.get_label(chip, feature) self.definitions[name]['lines'].append(line)
def create_definitions(self): for sensor in ORDER: for chip in sensors.ChipIterator(): chip_name = sensors.chip_snprintf_name(chip) if self.chips and not any( [chip_name.startswith(ex) for ex in self.chips]): continue for feature in sensors.FeatureIterator(chip): sfi = sensors.SubFeatureIterator(chip, feature) vals = list() for sf in sfi: try: vals.append(sensors.get_value(chip, sf.number)) except sensors.SensorsError as error: self.error('{0}: {1}'.format(sf.name, error)) continue if not vals or vals[0] == 0: continue if TYPE_MAP[feature.type] == sensor: # create chart name = chip_name + '_' + TYPE_MAP[feature.type] if name not in self.order: self.order.append(name) chart_def = list(CHARTS[sensor]['options']) chart_def[1] = chip_name + chart_def[1] self.definitions[name] = {'options': chart_def} self.definitions[name]['lines'] = [] line = list(CHARTS[sensor]['lines'][0]) line[0] = chip_name + '_' + str(feature.name.decode()) line[1] = sensors.get_label(chip, feature) self.definitions[name]['lines'].append(line)
def get_data(self): seen, data = dict(), dict() try: for chip in sensors.ChipIterator(): chip_name = sensors.chip_snprintf_name(chip) seen[chip_name] = defaultdict(list) for feat in sensors.FeatureIterator(chip): if feat.type not in TYPE_MAP: continue feat_type = TYPE_MAP[feat.type] feat_name = str(feat.name.decode()) feat_label = sensors.get_label(chip, feat) feat_limits = LIMITS.get(feat_type) sub_feat = next(sensors.SubFeatureIterator( chip, feat)) # current value if not sub_feat: continue try: v = sensors.get_value(chip, sub_feat.number) except sensors.SensorsError: continue if v is None: continue seen[chip_name][feat_type].append((feat_name, feat_label)) if feat_limits and (v < feat_limits[0] or v > feat_limits[1]): continue data[chip_name + '_' + feat_name] = int(v * 1000) except sensors.SensorsError as error: self.error(error) return None self.update_sensors_charts(seen) return data or None
def create_definitions(self): for sensor in ORDER: for chip in sensors.ChipIterator(): chip_name = sensors.chip_snprintf_name(chip) if self.chips and not any([chip_name.startswith(ex) for ex in self.chips]): continue for feature in sensors.FeatureIterator(chip): sfi = sensors.SubFeatureIterator(chip, feature) vals = [sensors.get_value(chip, sf.number) for sf in sfi] if vals[0] == 0: continue if TYPE_MAP[feature.type] == sensor: # create chart name = chip_name + "_" + TYPE_MAP[feature.type] if name not in self.order: self.order.append(name) chart_def = list(CHARTS[sensor]['options']) chart_def[1] = chip_name + chart_def[1] self.definitions[name] = {'options': chart_def} self.definitions[name]['lines'] = [] line = list(CHARTS[sensor]['lines'][0]) line[0] = chip_name + "_" + str(feature.name.decode()) line[1] = sensors.get_label(chip, feature) self.definitions[name]['lines'].append(line)