Exemplo n.º 1
0
    def load_tunnels(self):
        # Clear the tunnels list form the collection
        self.tunnels.clear_tunnels()

        # Create the DBConnection
        database = DBConnection()

        # Create the SQL
        sql = "SELECT * FROM tunnels WHERE id_connection = {}"

        # Bind the value
        sql = sql.format(self.id)

        # Execute the query
        rows = database.select_query(sql)

        # Set the attrs
        for row in rows:
            tunnel = Tunnel()
            tunnel.id = row['id_tunnel']
            tunnel.id_connection = self.id
            tunnel.local_port = row['local_port']
            tunnel.address = row['address']
            tunnel.remote_port = row['remote_port']

            # Add on Tunnels
            self.tunnels.add_tunnel(tunnel)
    def on_btn_add_clicked(self, btn):
        # Get the entries
        txt_local_port = self.builder.get_object("txt_local_port")
        txt_address = self.builder.get_object("txt_host")
        txt_remote_port = self.builder.get_object("txt_remote_port")

        # Validate the form
        if self.validate_form(txt_local_port, txt_address, txt_remote_port):
            # Create a new Tunnel
            tunnel = Tunnel()
            tunnel.local_port = txt_local_port.get_text()
            tunnel.address = txt_address.get_text()
            tunnel.remote_port = txt_remote_port.get_text()

            # Call the callback
            self.add_tunnel_callback(tunnel)

            # Destroy the Window
            self.window.destroy()
    def on_btn_add_clicked(self, btn):
        # Get the entries
        txt_local_port = self.builder.get_object("txt_local_port")
        txt_address = self.builder.get_object("txt_host")
        txt_remote_port = self.builder.get_object("txt_remote_port")

        # Validate the form
        if self.validate_form(txt_local_port, txt_address, txt_remote_port):
            # Create a new Tunnel
            tunnel = Tunnel()
            tunnel.local_port = txt_local_port.get_text()
            tunnel.address = txt_address.get_text()
            tunnel.remote_port = txt_remote_port.get_text()

            # Call the callback
            self.add_tunnel_callback(tunnel)

            # Destroy the Window
            self.window.destroy()
Exemplo n.º 4
0
    def load_tunnels(self):
        # Clear the tunnels list form the collection
        self.tunnels.clear_tunnels()

        # Create the DBConnection
        database = DBConnection()

        # Create the SQL
        sql = "SELECT * FROM tunnels WHERE id_connection = {}"

        # Bind the value
        sql = sql.format(self.id)

        # Execute the query
        rows = database.select_query(sql)

        # Set the attrs
        for row in rows:
            tunnel = Tunnel()
            tunnel.id = row['id_tunnel']
            tunnel.id_connection = self.id
            tunnel.local_port = row['local_port']
            tunnel.address = row['address']
            tunnel.remote_port = row['remote_port']

            # Add on Tunnels
            self.tunnels.add_tunnel(tunnel)
Exemplo n.º 5
0
    def load_tunnels(self, id_connection):
        # Reset the List
        self.tunnels = []

        # Create the SQL
        sql = "select * from tunnels where id_connection = {}"
        sql = sql.format(id_connection)

        # Execute the sql
        results = self.dbconnection.select_query(sql)

        # Create a model for every tunnel
        for row in results:
            # Create new Connection
            tunnel = Tunnel()
            tunnel.id = 0 if row['id_tunnel'] is None else row['id_tunnel']
            tunnel.id_connection = 0 if row['id_connection'] is None else row['id_connection']
            tunnel.local_port = row['local_port']
            tunnel.address = row['address']
            tunnel.remote_port = row['remote_port']

            # Add to the list
            self.tunnels.append(tunnel)