def test_no_generic_or_default_warn_readon(self):

        # load the default plugin_admin.xml file after having remove the 'generic' setting from section 'warn_reasons'
        from b3.lib.elementtree import ElementTree as ET
        root = ET.parse(ADMIN_CONFIG_FILE).getroot()
        warn_reasons_nodes = [
            x for x in root.findall('settings')
            if x.get('name') == 'warn_reasons'
        ][0]
        if len(warn_reasons_nodes):
            generic_nodes = [
                x for x in warn_reasons_nodes[0].findall('set')
                if x.get('name') == "generic"
            ]
            if len(generic_nodes):
                warn_reasons_nodes[0].remove(generic_nodes[0])
            default_nodes = [
                x for x in warn_reasons_nodes[0].findall('set')
                if x.get('name') == "default"
            ]
            if len(default_nodes):
                warn_reasons_nodes[0].remove(default_nodes[0])
        self.init(ET.tostring(root))

        self.joe.message = Mock(
            lambda x: sys.stdout.write("message to Joe: " + x + "\n"))
        self.joe.connects(0)
        self.joe.says('!warntest')
        self.joe.message.assert_called_once_with(
            '^2TEST: ^1WARNING^7 [^31^7]: ^7behave yourself')
        self.joe.message.reset_mock()
        self.joe.says('!warntest argue')
        self.joe.message.assert_called_once_with(
            '^2TEST: ^1WARNING^7 [^31^7]: ^3Rule #3: No arguing with admins (listen and learn or leave)'
        )
    def test_no_generic_or_default_warn_readon(self):

        # load the default plugin_admin.xml file after having remove the 'generic' setting from section 'warn_reasons'
        from b3.lib.elementtree import ElementTree as ET

        root = ET.parse(ADMIN_CONFIG_FILE).getroot()
        warn_reasons_nodes = [x for x in root.findall("settings") if x.get("name") == "warn_reasons"][0]
        if len(warn_reasons_nodes):
            generic_nodes = [x for x in warn_reasons_nodes[0].findall("set") if x.get("name") == "generic"]
            if len(generic_nodes):
                warn_reasons_nodes[0].remove(generic_nodes[0])
            default_nodes = [x for x in warn_reasons_nodes[0].findall("set") if x.get("name") == "default"]
            if len(default_nodes):
                warn_reasons_nodes[0].remove(default_nodes[0])
        self.init(ET.tostring(root))

        self.joe.message = Mock(lambda x: sys.stdout.write("message to Joe: " + x + "\n"))
        self.joe.connects(0)
        self.joe.says("!warntest")
        self.joe.message.assert_called_once_with("^2TEST: ^1WARNING^7 [^31^7]: ^7behave yourself")
        self.joe.message.reset_mock()
        self.joe.says("!warntest argue")
        self.joe.message.assert_called_once_with(
            "^2TEST: ^1WARNING^7 [^31^7]: ^3Rule #3: No arguing with admins (listen and learn or leave)"
        )
示例#3
0
    def setXml(self, xml):
        """\
        Read the xml config file from a string
        """
        self._xml = ElementTree.fromstring(xml)

        self._loadSettings()
示例#4
0
	def readfp(self, fp):
		"""\
		Read the xml config file from a file pointer
		"""
		self._xml = ElementTree.parse(fp)

		self._loadSettings()
示例#5
0
    def setXml(self, xml):
        """\
        Read the xml config file from a string
        """
        self._xml = ElementTree.fromstring(xml)

        self._loadSettings()
示例#6
0
 def readfp(self, fp):
     """\
     Read the xml config file from a file pointer
     """
     try:
         self._xml = ElementTree.parse(fp)
     except ExpatError, e:
         raise ConfigFileNotValid("%s" % e)
示例#7
0
 def readfp(self, fp):
     """\
     Read the xml config file from a file pointer
     """
     try:
         self._xml = ElementTree.parse(fp)
     except ExpatError, e:
         raise ConfigFileNotValid("%s" % e)
示例#8
0
    def loadFromString(self, xmlstring):
        """\
        Read the xml config from a string
        """

        self.fileName = None
        self.fileMtime = time.time()

        try:
            self._xml = ElementTree.XML(xmlstring)
        except ExpatError, e:
            raise ConfigFileNotValid("%s" % e)
示例#9
0
        self._checkqueue.put(self._checkqueue_end_token)

            
    def _checkClient(self, client):
        """\
        Examine players steam community id and allow/deny connection.
        """
        self.debug('checking %s (%s)', client, client.guid)
        try:
            response = self._query_service(client.guid)
        except Exception, err:
            self.exception(err)
        else:
            if response:
                try:
                    xml = ElementTree.XML(response)
                    error = xml.findtext('./error', None)
                    if error:
                        self.warning("Steam answered with error : %s", error)
                    else:
                        bandata = xml.findtext('./vacBanned', None)
                        if bandata is None:
                            self.info("cannot tell if banned. received : %s" % response)
                        elif bandata == '0':
                            self.info("%s has no VAC ban", client.name)
                        elif bandata == '1':
                            self.info("%s (%s) is banned by VAC", client.name, client.guid)
                            self._takeActionAgainst(client)
                except ExpatError, e:
                    self.error(e)
            else: