• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python minqlx.log_exception函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中minqlx.log_exception函数的典型用法代码示例。如果您正苦于以下问题:Python log_exception函数的具体用法?Python log_exception怎么用?Python log_exception使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了log_exception函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: handle_new_game

def handle_new_game(is_restart):
    # This is called early in the launch process, so it's a good place to initialize
    # minqlx stuff that needs QLDS to be initialized.
    global _first_game
    if _first_game:
        minqlx.late_init()
        _first_game = False

        # A good place to warn the owner if ZMQ stats are disabled.
        global _zmq_warning_issued
        if not bool(int(minqlx.get_cvar("zmq_stats_enable"))) and not _zmq_warning_issued:
            logger = minqlx.get_logger()
            logger.warning("Some events will not work because ZMQ stats is not enabled. "
                "Launch the server with \"zmq_stats_enable 1\"")
            _zmq_warning_issued = True

    minqlx.set_map_subtitles()

    if not is_restart:
        try:
            minqlx.EVENT_DISPATCHERS["map"].dispatch(
                minqlx.get_cvar("mapname"), 
                minqlx.get_cvar("g_factory"))
        except:
            minqlx.log_exception()
            return True

    try:
        minqlx.EVENT_DISPATCHERS["new_game"].dispatch()
    except:
        minqlx.log_exception()
        return True
开发者ID:h4t3,项目名称:minqlx,代码行数:32,代码来源:_handlers.py


示例2: handle_frame

def handle_frame():
    """This will be called every frame. To allow threads to call stuff from the
    main thread, tasks can be scheduled using the :func:`minqlx.next_frame` decorator
    and have it be executed here.

    """
    
    while True:
        # This will run all tasks that are currently scheduled.
        # If one of the tasks throw an exception, it'll log it
        # and continue execution of the next tasks if any.
        try:
            frame_tasks.run(blocking=False)
            break
        except:
            minqlx.log_exception()
            continue
    try:
        minqlx.EVENT_DISPATCHERS["frame"].dispatch()
    except:
        minqlx.log_exception()
        return True

    try:
        while True:
            func, args, kwargs = next_frame_tasks.popleft()
            frame_tasks.enter(0, 0, func, args, kwargs)
    except IndexError:
        pass
开发者ID:h4t3,项目名称:minqlx,代码行数:29,代码来源:_handlers.py


示例3: handle_server_command

def handle_server_command(client_id, cmd):
    try:
        # Dispatch the "server_command" event before further processing.
        try:
            player = minqlx.Player(client_id) if client_id >= 0 else None
        except minqlx.NonexistentPlayerError:
            return True

        retval = minqlx.EVENT_DISPATCHERS["server_command"].dispatch(player, cmd)
        if retval == False:
            return False
        elif isinstance(retval, str):
            cmd = retval

        res = _re_vote_ended.match(cmd)
        if res:
            if res.group("result") == "passed":
                minqlx.EVENT_DISPATCHERS["vote_ended"].dispatch(True)
            else:
                minqlx.EVENT_DISPATCHERS["vote_ended"].dispatch(False)
        
        return cmd
    except:
        minqlx.log_exception()
        return True
开发者ID:h4t3,项目名称:minqlx,代码行数:25,代码来源:_handlers.py


示例4: parse_mappool

    def parse_mappool(self, path):
        """Read and parse the map pool file into a dictionary.
    
        Structure as follows:
        {'campgrounds': ['ca', 'ffa'], 'overkill': ['ca']}
        
        """
        mappool = {}
        try:
            with open(path, "r") as f:
                lines = f.readlines()
        except:
            minqlx.log_exception()
            return None
        
        for line in lines:
            li = line.lstrip()
            # Ignore commented lines.
            if not li.startswith("#") and "|" in li:
                key, value = line.split('|', 1)
                # Maps are case-insensitive, but not factories.
                key = key.lower()

                if key in mappool:
                    mappool[key].append(value.strip())
                else:
                    mappool[key] = [value.strip()]
        
        return mappool
开发者ID:DieselPowerKOR,项目名称:minqlx-plugins,代码行数:29,代码来源:essentials.py


示例5: cmd_reload_config

 def cmd_reload_config(self, player, msg, channel):
     try:
         minqlx.reload_config()
         channel.reply("^7The config file was reloaded successfully.")
     except Exception as e:
         channel.reply("^7The config file has failed to reload: {} - {}"
                 .format(e.__class__.__name__, e))
         minqlx.log_exception(self)
开发者ID:rulex,项目名称:minqlx-plugins,代码行数:8,代码来源:plugin_manager.py


示例6: handle_set_configstring

def handle_set_configstring(index, value):
    """Called whenever the server tries to set a configstring. Can return
    False to stop the event.

    """
    try:
        res = minqlx.EVENT_DISPATCHERS["set_configstring"].dispatch(index, value)
        if res == False:
            return False
        elif isinstance(res, str):
            value = res

        # GAME STATE CHANGES
        if index == 0:
            old_cs = minqlx.parse_variables(minqlx.get_configstring(index))
            if not old_cs:
                return

            new_cs = minqlx.parse_variables(value)
            old_state = old_cs["g_gameState"]
            new_state = new_cs["g_gameState"]
            if old_state != new_state:
                if old_state == "PRE_GAME" and new_state == "IN_PROGRESS":
                    minqlx.EVENT_DISPATCHERS["vote_ended"].cancel()  # Cancel current vote if any.
                    # minqlx.EVENT_DISPATCHERS["game_start"].dispatch()
                elif old_state == "PRE_GAME" and new_state == "COUNT_DOWN":
                    minqlx.EVENT_DISPATCHERS["game_countdown"].dispatch()
                elif old_state == "COUNT_DOWN" and new_state == "IN_PROGRESS":
                    minqlx.EVENT_DISPATCHERS["vote_ended"].cancel()  # Cancel current vote if any.
                    # minqlx.EVENT_DISPATCHERS["game_start"].dispatch()
                elif old_state == "IN_PROGRESS" and new_state == "PRE_GAME":
                    pass
                elif old_state == "COUNT_DOWN" and new_state == "PRE_GAME":
                    pass
                else:
                    logger = minqlx.get_logger()
                    logger.warning("UNKNOWN GAME STATES: {} - {}".format(old_state, new_state))

        # ROUND COUNTDOWN AND START
        if index == 661:
            cvars = minqlx.parse_variables(value)
            if cvars:
                round_number = int(cvars["round"])
                if round_number and "time" in cvars:
                    if round_number == 1:  # This is the case when the first countdown starts.
                        minqlx.EVENT_DISPATCHERS["round_countdown"].dispatch(round_number)
                        return

                    minqlx.EVENT_DISPATCHERS["round_countdown"].dispatch(round_number)
                    return
                elif round_number:
                    minqlx.EVENT_DISPATCHERS["round_start"].dispatch(round_number)
                    return

        return res
    except:
        minqlx.log_exception()
        return True
开发者ID:PerpetualWar,项目名称:minqlx,代码行数:58,代码来源:_handlers.py


示例7: dispatch

    def dispatch(self, *args, **kwargs):
        """Calls all the handlers that have been registered when hooking this event.
        The recommended way to use this for events that inherit this class is to
        override the method with explicit arguments (as opposed to the this one's)
        and call this method by using ``super().dispatch()``.

        Handlers have several options for return values that can affect the flow:
            - minqlx.RET_NONE or None -- Continue execution normally.
            - minqlx.RET_STOP -- Stop any further handlers from being called.
            - minqlx.RET_STOP_EVENT -- Let handlers process it, but stop the event
                at the engine-level.
            - minqlx.RET_STOP_ALL -- Stop handlers **and** the event.
            - Any other value -- Passed on to :func:`self.handle_return`, which will
                by default simply send a warning to the logger about an unknown value
                being returned. Can be overridden so that events can have their own
                special return values.

        :param args: Any arguments.
        :param kwargs: Any keyword arguments.

        """
        # Allow subclasses of this to edit the arguments without having
        # to reimplement this method. Whenever an unknown return value
        # is returned, we pass it on to handle_return.
        self.args = args
        self.kwargs = kwargs
        logger = minqlx.get_logger()
        # Log the events as they come in.
        if self.name not in self.no_debug:
            dbgstr = "{}{}".format(self.name, args)
            if len(dbgstr) > 100:
                dbgstr = dbgstr[0:99] + ")"
            logger.debug(dbgstr)

        plugins = self.plugins.copy()
        self.return_value = True
        for i in range(5):
            for plugin in plugins:
                for handler in plugins[plugin][i]:
                    try:
                        res = handler(*self.args, **self.kwargs)
                        if res == minqlx.RET_NONE or res is None:
                            continue
                        elif res == minqlx.RET_STOP:
                            return True
                        elif res == minqlx.RET_STOP_EVENT:
                            self.return_value = False
                        elif res == minqlx.RET_STOP_ALL:
                            return False
                        else: # Got an unknown return value.
                            return_handler = self.handle_return(handler, res)
                            if return_handler is not None:
                                return return_handler
                    except:
                        minqlx.log_exception(plugin)
                        continue

        return self.return_value
开发者ID:MinoMino,项目名称:minqlx,代码行数:58,代码来源:_events.py


示例8: f

        def f():
            try:
                minqlx.load_preset_plugins()
            except Exception as e:
                channel.reply("Plugins failed to load: {} - {}"
                    .format(e.__class__.__name__, e))
                minqlx.log_exception(self)

            channel.reply("Successfully loaded all plugins in ^6qlx_plugins^7.")
开发者ID:hjan,项目名称:minqlx-plugins,代码行数:9,代码来源:plugin_manager.py


示例9: keep_receiving

    def keep_receiving(self):
        """Receives until self.done is set to True. Works by scheduling this
        to be called every 0.25 seconds. If we get an exception, we try
        to reconnect and continue.

        """
        try:
            if self.done:
                return
            while True: # Will throw an expcetion if no more data to get.
                stats = self.socket.recv_json(zmq.NOBLOCK)
                minqlx.EVENT_DISPATCHERS["stats"].dispatch(stats)

                if stats["TYPE"] == "MATCH_STARTED":
                    self._in_progress = True
                    minqlx.EVENT_DISPATCHERS["game_start"].dispatch(stats["DATA"])
                elif stats["TYPE"] == "ROUND_OVER":
                    minqlx.EVENT_DISPATCHERS["round_end"].dispatch(stats["DATA"])
                elif stats["TYPE"] == "MATCH_REPORT":
                    global _in_progress
                    # MATCH_REPORT event goes off with a map change and map_restart,
                    # but we really only want it for when the game actually ends.
                    # We use a variable instead of Game().state because by the
                    # time we get the event, the game is probably gone.
                    if self._in_progress:
                        minqlx.EVENT_DISPATCHERS["game_end"].dispatch(stats["DATA"])
                    self._in_progress = False
                elif stats["TYPE"] == "PLAYER_DEATH":
                    # Dead player.
                    sid = int(stats["DATA"]["VICTIM"]["STEAM_ID"])
                    if sid:
                        player = minqlx.Plugin.player(sid)
                    else: # It's a bot. Forced to use name as an identifier.
                        player = minqlx.Plugin.player(stats["DATA"]["VICTIM"]["NAME"])
                    
                    # Killer player.
                    if not stats["DATA"]["KILLER"]:
                        player_killer = None
                    else:
                        sid_killer = int(stats["DATA"]["KILLER"]["STEAM_ID"])
                        if sid_killer:
                            player_killer = minqlx.Plugin.player(sid_killer)
                        else: # It's a bot. Forced to use name as an identifier.
                            player_killer = minqlx.Plugin.player(stats["DATA"]["KILLER"]["NAME"])

                    minqlx.EVENT_DISPATCHERS["death"].dispatch(player, player_killer, stats["DATA"])
                    if player_killer:
                        minqlx.EVENT_DISPATCHERS["kill"].dispatch(player, player_killer, stats["DATA"])
        except zmq.error.Again:
            pass
        except Exception:
            minqlx.log_exception()
            # Reconnect, just in case. GC will clean up for us.
            self.__init__()

        self.keep_receiving()
开发者ID:PerpetualWar,项目名称:minqlx,代码行数:56,代码来源:_zmq.py


示例10: handle_client_command

def handle_client_command(client_id, cmd):
    """Client commands are commands such as "say", "say_team", "scores",
    "disconnect" and so on. This function parses those and passes it
    on to the event dispatcher.

    :param client_id: The client identifier.
    :type client_id: int
    :param cmd: The command being ran by the client.
    :type cmd: str

    """
    try:
        # Dispatch the "client_command" event before further processing.
        player = minqlx.Player(client_id)
        if minqlx.EVENT_DISPATCHERS["client_command"].dispatch(player, cmd) == False:
            return False

        # Beyond this point, we deal with events that don't overlap,
        # meaning we can safely return the result of the dispatch method.
        res = _re_say.match(cmd)
        if res:
            msg = res.group("msg").replace('"', "")
            channel = minqlx.CHAT_CHANNEL
            return minqlx.EVENT_DISPATCHERS["chat"].dispatch(player, msg, channel)

        res = _re_say_team.match(cmd)
        if res:
            msg = res.group("msg").replace('"', "")
            if player.team == "free":  # I haven't tried this, but I don't think it's even possible.
                channel = minqlx.FREE_CHAT_CHANNEL
            elif player.team == "red":
                channel = minqlx.RED_TEAM_CHAT_CHANNEL
            elif player.team == "blue":
                channel = minqlx.BLUE_TEAM_CHAT_CHANNEL
            else:
                channel = minqlx.SPECTATOR_CHAT_CHANNEL
            return minqlx.EVENT_DISPATCHERS["chat"].dispatch(player, msg, channel)

        res = _re_callvote.match(cmd)
        if res:
            vote = res.group("cmd")
            args = res.group("args") if res.group("args") else ""
            return minqlx.EVENT_DISPATCHERS["vote_called"].dispatch(player, vote, args)

        res = _re_vote.match(cmd)
        if res and minqlx.Plugin.is_vote_active():
            arg = res.group("arg")
            if arg.lower() == "y" or arg == "1":
                return minqlx.EVENT_DISPATCHERS["vote"].dispatch(True)
            elif arg.lower() == "n" or arg == "1":
                return minqlx.EVENT_DISPATCHERS["vote"].dispatch(False)
    except:
        minqlx.log_exception()
        return True
开发者ID:PerpetualWar,项目名称:minqlx,代码行数:54,代码来源:_handlers.py


示例11: handle_rcon

def handle_rcon(cmd):
    """Console commands that are to be processed as regular pyminqlx
    commands as if the owner executes it. This allows the owner to
    interact with the Python part of minqlx without having to connect.

    """
    try:
        minqlx.COMMANDS.handle_input(minqlx.RconDummyPlayer(), cmd, minqlx.CONSOLE_CHANNEL)
    except:
        minqlx.log_exception()
        return True
开发者ID:h4t3,项目名称:minqlx,代码行数:11,代码来源:_handlers.py


示例12: cmd_reload

 def cmd_reload(self, player, msg, channel):
     if len(msg) < 2:
         return minqlx.CMD_USAGE
     else:
         try:
             minqlx.reload_plugin(msg[1])
             channel.reply("^7Plugin ^6{} ^7has been successfully reloaded."
                 .format(msg[1]))
         except Exception as e:
             channel.reply("^7Plugin ^6{} ^7has failed to reload: {} - {}"
                 .format(msg[1], e.__class__.__name__, e))
             minqlx.log_exception(self)
开发者ID:rulex,项目名称:minqlx-plugins,代码行数:12,代码来源:plugin_manager.py


示例13: handle_player_spawn

def handle_player_spawn(client_id):
    """Called when a player spawns. Note that a spectator going in free spectate mode
    makes the client spawn, so you'll want to check for that if you only want "actual"
    spawns.

    """
    try:
        player = minqlx.Player(client_id)
        return minqlx.EVENT_DISPATCHERS["player_spawn"].dispatch(player)
    except:
        minqlx.log_exception()
        return True
开发者ID:h4t3,项目名称:minqlx,代码行数:12,代码来源:_handlers.py


示例14: cmd_unloadall

    def cmd_unloadall(self, player, msg, channel):
        for plugin in self.plugins:
            if plugin != self.__class__.__name__:
                try:
                    minqlx.unload_plugin(plugin)
                except Exception as e:
                    channel.reply("Plugin ^6{} ^7has failed to unload: {} - {}"
                        .format(plugin, e.__class__.__name__, e))
                    minqlx.log_exception(self)

        channel.reply("Successfully unloaded all plugins except {}."
            .format(self.__class__.__name__))
开发者ID:hjan,项目名称:minqlx-plugins,代码行数:12,代码来源:plugin_manager.py


示例15: handle_player_disconnect

def handle_player_disconnect(client_id, reason):
    """This will be called whenever a player disconnects.

    :param client_id: The client identifier.
    :type client_id: int

    """
    try:
        player = minqlx.Player(client_id)
        return minqlx.EVENT_DISPATCHERS["player_disconnect"].dispatch(player, reason)
    except:
        minqlx.log_exception()
        return True
开发者ID:h4t3,项目名称:minqlx,代码行数:13,代码来源:_handlers.py


示例16: handle_kamikaze_use

def handle_kamikaze_use(client_id):
    """This will be called whenever player uses kamikaze item.

    :param client_id: The client identifier.
    :type client_id: int

    """
    try:
        player = minqlx.Player(client_id)
        return minqlx.EVENT_DISPATCHERS["kamikaze_use"].dispatch(player)
    except:
        minqlx.log_exception()
        return True
开发者ID:MinoMino,项目名称:minqlx,代码行数:13,代码来源:_handlers.py


示例17: restoreIdentFile

 def restoreIdentFile(self):
     """Restore the identfile."""
     if not os.path.isfile(IDENTFILE):
         return
     
     try:
         with open(IDENTFILE, 'w') as ifile:
             for l in self.ifile_buf:
                 ifile.write(l)
     except Exception:
         minqlx.log_exception()
     # We're done, release the lock so other 
     # minqlx-plugins can do the same
     self.flock.release()
开发者ID:dsverdlo,项目名称:minqlx-plugins,代码行数:14,代码来源:myirc.py


示例18: handle_console_print

    def handle_console_print(self, text):
        """Called whenever the server prints something to the console."""
        try:
            if not text:
                return

            if _map_redirection:
                global _map_buffer
                if '.bsp' in text:
                    _map_buffer += text

        except:
            minqlx.log_exception()
            return True
开发者ID:BarelyMiSSeD,项目名称:minqlx-plugins,代码行数:14,代码来源:listmaps.py


示例19: run

 def run(self):
     loop = asyncio.new_event_loop()
     logger = minqlx.get_logger("irc")
     asyncio.set_event_loop(loop)
     while not self.stop_event.is_set():
         try:
             loop.run_until_complete(self.connect())
         except Exception:
             minqlx.log_exception()
         
         # Disconnected. Try reconnecting in 30 seconds.
         logger.info("Disconnected from IRC. Reconnecting in 30 seconds...")
         time.sleep(30)
     loop.close()
开发者ID:JohnnyDenver,项目名称:minqlx-plugins,代码行数:14,代码来源:irc.py


示例20: run

 def run(self):
     loop = asyncio.new_event_loop()
     logger = minqlx.get_logger("irc")
     asyncio.set_event_loop(loop)
     while not self.stop_event.is_set():
         try:
             loop.run_until_complete(self.connect())
         except Exception:
             minqlx.log_exception()
         
         # Disconnected. Try reconnecting in 30 seconds.
         logger.info("Disconnected from IRC. Reconnecting in 30 seconds...")
         minqlx.CHAT_CHANNEL.reply("Connection attempt to ^3CommLink^7 server failed, retrying in 30 seconds.")
         time.sleep(30)
     loop.close()
开发者ID:TomTec-Solutions,项目名称:QL-Server-Config,代码行数:15,代码来源:irc.py



注:本文中的minqlx.log_exception函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python minqlx.set_cvar函数代码示例发布时间:2022-05-27
下一篇:
Python minqlx.get_configstring函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap