コード例 #1
0
def handle_payload(ev):
    msg = ev.msg
    print "\ttopic : " + msg.topic
    
    parser = SafeConfigParser()
    parser.read('data.ini')
    
    if msg.payload is not None:
        data = msg.payload
        data = str(data)
     
        print "payload = ", data
        try:
            data2 = json.loads(data)
        except ValueError:
            return

        value = data2['value']
        datastream = data2['id']
#        transmit data to cosm
        api = parser.get('API', 'cosm')
        feed = parser.get('API', 'cosm_feed')
        packet = PachubePacket(api, feed, [(datastream, value)])
        print "Cosm status = ", packet.push()
        print datastream
        print value
コード例 #2
0
ファイル: api.py プロジェクト: Pepe74/panstamp
    def push_pachube(endp, sharing_key, feed_id, datastream_id):
        """
        Push data to pachube

        @param endp: endpoint identification string
        format 1: process.location.name
        format 2: process.id        
        @param sharing_key: Pachube sharing key
        @param feed_id: Pachube feed ID
        @param datastream_id: Pachube datastream ID
        
        @return HTTP response from Pachube
        """
        try:
            endpoint = NetworkAPI.get_endpoint(endp)
            if endpoint is not None:
                packet = PachubePacket(sharing_key, feed_id, [(datastream_id, endpoint.value)])
                return packet.push()
            return None
        except LagartoException as ex:
            ex.log()
コード例 #3
0
ファイル: api.py プロジェクト: ntruchsess/panstamp
    def push_pachube(endp, sharing_key, feed_id, datastream_id):
        """
        Push data to pachube

        @param endp: endpoint identification string
        format 1: process.location.name
        format 2: process.id        
        @param sharing_key: Pachube sharing key
        @param feed_id: Pachube feed ID
        @param datastream_id: Pachube datastream ID
        
        @return HTTP response from Pachube
        """
        try:
            endpoint = NetworkAPI.get_endpoint(endp)
            if endpoint is not None:
                packet = PachubePacket(sharing_key, feed_id,
                                       [(datastream_id, endpoint.value)])
                return packet.push()
            return None
        except LagartoException as ex:
            ex.log()