Beispiel #1
0
    def run(self):

        client = mongodatabase('db.conf')
        client.connect("raspberry")
        self.db = client.get_db()
        print"%s连接数据库成功~"%self.__class__

        while True:
            try:
                data = self.update()
            except Exception,X:
                #print X
		        pass
            else:
                print data
                #print self.db
                self.db.dht11.insert(data)
                pass
            finally:
Beispiel #2
0
    def run(self):

        client = mongodatabase('db.conf')
        client.connect("raspberry")
        self.db = client.get_db()
        print"%s连接数据库成功~"%self.__class__

        while True:
            try:
                data = self.update()
            except Exception,X:
                #print X
		        pass
            else:
                #print data
                #print self.db
                print "光线变化:%s,%s"%(data['光线'],datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
                self.db.light.insert(data)
                pass
            finally:
Beispiel #3
0
    def run(self):

        client = mongodatabase('db.conf')
        client.connect("raspberry")
        self.db = client.get_db()
        print"%s连接数据库成功~"%self.__class__

        while True:
            try:
                data = self.update()
            except Exception,X:
                #print X
		        pass
            else:
                #print data
                #print self.db
                if data["声音"]:
                    print "有声音:%s"%datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
                    self.db.voice.insert(data)
                pass
            finally: