Beispiel #1
0
 def index(self, year=None):
     """
         Example Method with class attached routing (see above "/" )
     """
     print(" Calling IndexHandler.index from handlers/shorties.py: parameter index: " + str(year))
     conn = self.get_secure_cookie("redisui:current_connection", None)
     print(f"found existing connnection cookie: {str(conn)}")
     if conn:
         c=Connections()
         redis_conf=c.find(c.where("_uuid") == id)
         self.render("redisdash.tmpl", connected=True, connection_id=conn, connection=redis_conf)
     else:
         #self.set_secure_cookie("current_connection", "None")
         self.redirect("/connections_list")
Beispiel #2
0
 def serverinfo(self, id):
     """
         render the server info view for the connection 
         with the given uuid
     """
     r=Redisinfo()
     c=Connections()
     redis_conf=c.find(c.where("_uuid") == id)
     r.set_connection(redis_conf=redis_conf.to_dict())
     print(json.dumps(r.db.info()))
     try:
         self.render("serverinfo.tmpl", connected=True, connection_id=id, info=r.db.info())
     except:
         self.error(message="Could not connect to Redis DB", data=json.dumps(redis_conf))
    def welcome(self, message):
        """ 
            try to register the client
            and return the info message
        """
        try:
            connection_id = message["connection_id"]
            r = Tdbmodel()
            # get the connection from the DB
            print(f"connecting to: {connection_id}")
            c = Connections()
            db_conf = c.find(c.where("_uuid") == connection_id)
            r.set_connection(db_conf=db_conf.to_dict())
            try:
                result = r.db.tables()
                client_id = message["client_id"]
                if not client_id in self.dbclients:
                    self.dbclients[client_id] = r
                info = {}
                info["tables"] = result
                info["hostname"] = db_conf.host
                info["dbname"] = db_conf.dbname
                data = {"method": "welcome", "type": "info", "data": info}
            except Exception as e:
                print(str(e))
                data = {
                    "method": "welcome",
                    "type": "error",
                    "message": "Could not connect to host...",
                    "redirect": True,
                    "redirect_url": "/connections_list",
                    "data": "Nothing"
                }
            return json.dumps(data)

        except Exception as e:
            data = {"method": "welcome", "type": "error", "data": str(e)}
            return json.dumps(data)