コード例 #1
0
ファイル: handlers.py プロジェクト: 24vishnu/Python
    def __call__(self, packet):

        device = Device.get_or_create(packet.data['packet_type'],
                                      packet.data['sub_type'],
                                      packet.data['id'])

        for series_name, value_name in self.mapping.items():

            series = Series.get_or_create(name=series_name)
            db.session.commit()
            try:
                val = packet.data[value_name]
            except KeyError:
                self.log.error("Failed to find %s in packet. Key list: %r" %
                               (value_name, sorted(packet.data.keys())))
                return

            id_ = packet.data.get('id')
            self.log.info("ID=%s, %s=%s, Device ID=%s, Series ID=%s" %
                          (id_, series_name, val, device.id, series.id))
            DataPoint.record(series, device, val)

        db.session.commit()
コード例 #2
0
ファイル: handlers.py プロジェクト: d0ugal-archive/home
    def __call__(self, packet):

        device = Device.get_or_create(packet.data['packet_type'],
                                      packet.data['sub_type'],
                                      packet.data['id'])

        for series_name, value_name in self.mapping.items():

            series = Series.get_or_create(name=series_name)
            db.session.commit()
            try:
                val = packet.data[value_name]
            except KeyError:
                self.log.error("Failed to find %s in packet. Key list: %r" % (
                    value_name, sorted(packet.data.keys())))
                return

            id_ = packet.data.get('id')
            self.log.info("ID=%s, %s=%s, Device ID=%s, Series ID=%s" % (
                id_, series_name, val, device.id, series.id))
            DataPoint.record(series, device, val)

        db.session.commit()
コード例 #3
0
ファイル: test_redis.py プロジェクト: d0ugal-archive/home
    def test_record(self):

        DataPoint.record(self.series, self.device, 100)