from pyrcon.rcon import RConnection


class PugState():

    def __init__(self, config):
        self.server = config["server"]
        self.port = config["port"]

        self.nick = config["nick"]
        self.channel = config["channel"]

        self.cmdPrefixes = config["prefixes"]
        self.owners = config["owners"]
        self.pugSize = config["size"]

        self.password = ""

        self.Q = []
        self.maps = config["maps"]
        self.votes = {}

        self.loggedIn = self.owners

        self.servers = []

        for s in config["urt_servers"]:
            server = {
                "host": s["host"],
                "port": s["port"],
                "password": s["password"],
                "active": False,
                "connection": RConnection(s["host"], s["port"], s["password"])
            }
            if server["connection"].test():
                self.servers.append(server)

@@ -586,88 +586,75 @@
     
-server = %7B%0A                %22host%22: s%5B%22host%22%5D,%0A                
+with Rconnection(s%5B%22host%22%5D, s%5B
 %22port%22
-:
+%5D,
  s%5B%22p
+assw
 or
-t%22%5D,
+d%22%5D) as urtserver:
 %0A   
@@ -670,35 +670,34 @@
     
-%22password%22: s%5B%22password%22%5D,%0A
+self.servers.append(%7B%0A    
     
@@ -741,16 +741,20 @@
         
+    
 %22connect
@@ -763,155 +763,33 @@
 n%22: 
-RConnection(s%5B%22host%22%5D, s%5B%22port%22%5D, s%5B%22password%22%5D)%0A            %7D%0A            if server%5B%22connection%22%5D.test():%0A                self.servers.append(server
+urtserver%0A                %7D
 )%0A

clean up self.servers