Example #1
0
 def refresh_ops(self, read_super_ops=True):
     self.ownernames = config_to_dict_read("superops.txt", ".")
     if self.ownernames == {}:
         sample = "<op_player_1>=10\n<op_player_2>=9"
         with open("superops.txt", "w") as f:
             f.write(sample)
     self.operator_list = self.read_ops_file(read_super_ops)
Example #2
0
 def refresh_ops(self, read_super_ops=True):
     self.ownernames = config_to_dict_read("superops.txt", ".")
     if self.ownernames == {}:
         sample = "<op_player_1>=10\n<op_player_2>=9"
         with open("superops.txt", "w") as f:
             f.write(sample)
     self.operator_list = self.read_ops_file(read_super_ops)
Example #3
0
    def reloadproperties(self):
        # Load server icon
        if os.path.exists("%s/server-icon.png" % self.serverpath):
            with open("%s/server-icon.png" % self.serverpath, "rb") as f:
                theicon = f.read()
                iconencoded = base64.standard_b64encode(theicon)
                self.serverIcon = b"data:image/png;base64," + iconencoded

        # Read server.properties and extract some information out of it
        # the PY3.5 ConfigParser seems broken.  This way was much more
        # straightforward and works in both PY2 and PY3
        self.properties = config_to_dict_read(
            "server.properties", self.serverpath)

        if self.properties == {}:
            self.log.warning("File 'server.properties' not found.")
            return False

        if "level-name" in self.properties:
            self.worldname = self.properties["level-name"]
        else:
            self.log.warning("No 'level-name=(worldname)' was"
                             " found in the server.properties.")
            return False
        self.motd = self.properties["motd"]
        if "max-players" in self.properties:
            self.maxPlayers = self.properties["max-players"]
        else:
            self.log.warning(
                "No 'max-players=(count)' was found in the"
                " server.properties. The default of '20' will be used.")
            self.maxPlayers = 20
        self.onlineMode = self.properties["online-mode"]
Example #4
0
    def reloadproperties(self):
        # Read server.properties and extract some information out of it
        # the PY3.5 ConfigParser seems broken.  This way was much more
        # straightforward and works in both PY2 and PY3

        # Load server icon
        if os.path.exists("%s/server-icon.png" % self.serverpath):
            with open("%s/server-icon.png" % self.serverpath, "rb") as f:
                theicon = f.read()
                iconencoded = base64.standard_b64encode(theicon)
                self.servericon = b"data:image/png;base64," + iconencoded

        self.properties = config_to_dict_read(
            "server.properties", self.serverpath)

        if self.properties == {}:
            self.log.warning("File 'server.properties' not found.")
            return False

        if "level-name" in self.properties:
            self.worldname = self.properties["level-name"]
        else:
            self.log.warning("No 'level-name=(worldname)' was"
                             " found in the server.properties.")
            return False
        self.motd = self.properties["motd"]