def _get_data(self):
        data = {}
        try:
            for chip in sensors.ChipIterator():
                prefix = sensors.chip_snprintf_name(chip)
                for feature in sensors.FeatureIterator(chip):
                    sfi = sensors.SubFeatureIterator(chip, feature)
                    for sf in sfi:
                        val = sensors.get_value(chip, sf.number)
                        break
                    typeName = TYPE_MAP[feature.type]
                    if typeName in LIMITS:
                        limit = LIMITS[typeName];
                        if val < limit[0] or val > limit[1]:
                            continue
                    if 'temp' in str(feature.name.decode()):
                        data[prefix + "_" + str(feature.name.decode())] = int(self.calc(val) * 1000)
                    else:
                        data[prefix + "_" + str(feature.name.decode())] = int(val * 1000)
        except Exception as e:
            self.error(e)
            return None

        if len(data) == 0:
            return None
        return data
 def _create_definitions(self):
     for type in ORDER:
         for chip in sensors.ChipIterator():
             chip_name = sensors.chip_snprintf_name(chip)
             if len(self.chips) != 0 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] == type:
                     # create chart
                     name = chip_name + "_" + TYPE_MAP[feature.type]
                     if name not in self.order:
                         self.order.append(name)
                         chart_def = list(CHARTS[type]['options'])
                         chart_def[1] = chip_name + chart_def[1]
                         if chart_def[2] == 'Celsius':
                             chart_def[2] = self.choice[0]
                         self.definitions[name] = {'options': chart_def}
                         self.definitions[name]['lines'] = []
                     line = list(CHARTS[type]['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):
        data = {}
        try:
            for chip in sensors.ChipIterator():
                prefix = sensors.chip_snprintf_name(chip)
                for feature in sensors.FeatureIterator(chip):
                    sfi = sensors.SubFeatureIterator(chip, feature)
                    for sf in sfi:
                        val = sensors.get_value(chip, sf.number)
                        break
                    data[prefix + "_" + str(feature.name.decode())] = int(val * 1000)
        except Exception as e:
            self.error(e)
            return None

        if len(data) == 0:
            return None
        return data
Exemple #4
0
    def _get_data(self):
        data = {}
        try:
            for chip in sensors.ChipIterator():
                prefix = sensors.chip_snprintf_name(chip)
                for feature in sensors.FeatureIterator(chip):
                    sfi = sensors.SubFeatureIterator(chip, feature)
                    for sf in sfi:
                        val = sensors.get_value(chip, sf.number)
                        break
                    data[prefix + "_" + str(feature.name.decode())] = int(val *
                                                                          1000)
        except Exception as e:
            self.error(e)
            return None

        if len(data) == 0:
            return None
        return data