Ejemplo n.º 1
0
    def read_ops_file(self, read_super_ops=True):
        """Keep a list of ops in the server instance to stop
        reading the disk for it.
        :rtype: Dictionary
        """
        ops = False
        # (4 = PROTOCOL_1_7 ) - 1.7.6 or greater use ops.json
        if self.protocolVersion > 4:
            ops = getjsonfile("ops", self.serverpath, encodedas=self.encoding)
        if not ops:
            # try for an old "ops.txt" file instead.
            ops = []
            opstext = getfileaslines("ops.txt", self.serverpath)
            if not opstext:
                return False
            for op in opstext:
                # create a 'fake' ops list from the old pre-1.8
                # text line name list notice that the level (an
                # option not the old list) is set to 1 This will
                # pass as true, but if the plugin is also
                # checking op-levels, it may not pass truth.
                indivop = {"uuid": op,
                           "name": op,
                           "level": 1}
                ops.append(indivop)

        # Grant "owner" an op level above 4. required for some wrapper commands
        if read_super_ops:
            for eachop in ops:
                if eachop["name"] in self.ownernames:
                    eachop["level"] = self.ownernames[eachop["name"]]
        return ops
Ejemplo n.º 2
0
    def read_ops_file(self, read_super_ops=True):
        """Keep a list of ops in the server instance to stop
        reading the disk for it.
        :rtype: Dictionary
        """
        ops = False
        # (4 = PROTOCOL_1_7 ) - 1.7.6 or greater use ops.json
        if self.version_compute > 10700:
            ops = getjsonfile(
                "ops", self.serverpath, encodedas=self.encoding
            )
        if not ops:
            # try for an old "ops.txt" file instead.
            ops = []
            opstext = getfileaslines("ops.txt", self.serverpath)
            if not opstext:
                return False
            for op in opstext:
                # create a 'fake' ops list from the old pre-1.8
                # text line name list notice that the level (an
                # option not the old list) is set to 1 This will
                # pass as true, but if the plugin is also
                # checking op-levels, it may not pass truth.
                indivop = {"uuid": op,
                           "name": op,
                           "level": 1}
                ops.append(indivop)

        # Grant "owner" an op level above 4. required for some wrapper commands
        if read_super_ops:
            for eachop in ops:
                if eachop["name"] in self.ownernames:
                    eachop["level"] = self.ownernames[eachop["name"]]
        return ops