(self, cid, rdb)
Get a monitor object by looking it up
Get a monitor object by looking it up
Get a monitor object by looking it up
def get(self, cid, rdb):
        ''' Get a monitor object by looking it up '''
        results = r.table('monitors').get(cid).run(rdb)
        if results:
            self.cid = cid
            self.name = results['name']
            self.ctype = results['ctype']
            self.uid = results['uid']
            self.url = results['url']
            self.failcount = results['failcount']
            self.data = results['data']
            self.status = results['status']
            if "encrypted" in results:
                self.encrypted = results['encrypted']
            if self.encrypted:
                crypto = Fernet(self.config['CRYPTO_KEY'])
                self.data = json.loads(crypto.decrypt(bytes(self.data)))
            return self
        else:
            return False
def get ( self , cid , rdb ) : results = r . table ( 'monitors' ) . get ( cid ) . run ( rdb ) if results : self . cid = cid self . name = results [ 'name' ] self . ctype = results [ 'ctype' ] self . uid = results [ 'uid' ] self . url = results [ 'url' ] self . failcount = results [ 'failcount' ] self . data = results [ 'data' ] self . status = results [ 'status' ] if "encrypted" in results : self . encrypted = results [ 'encrypted' ] if self . encrypted : crypto = Fernet ( self . config [ 'CRYPTO_KEY' ] ) self . data = json . loads ( crypto . decrypt ( bytes ( self . data ) ) ) return self else : return False