コード例 #1
0
def alias_event_handler(_, **kwargs):
    """
    An event handler for alias transformation when EVENT_INVOKER_PRE_TRUNCATE_CMD_TBL event is invoked.
    """
    try:
        telemetry.start()

        start_time = timeit.default_timer()
        args = kwargs.get('args')
        alias_manager = AliasManager(**kwargs)

        # [:] will keep the reference of the original args
        args[:] = alias_manager.transform(args)

        if is_alias_command(['create', 'import'], args):
            load_cmd_tbl_func = kwargs.get('load_cmd_tbl_func', lambda _: {})
            cache_reserved_commands(load_cmd_tbl_func)

        elapsed_time = (timeit.default_timer() - start_time) * 1000
        logger.debug(DEBUG_MSG_WITH_TIMING, args, elapsed_time)

        telemetry.set_execution_time(round(elapsed_time, 2))
    except Exception as client_exception:  # pylint: disable=broad-except
        telemetry.set_exception(client_exception)
        raise
    finally:
        telemetry.conclude()
コード例 #2
0
def alias_event_handler(_, **kwargs):
    """
    An event handler for alias transformation when EVENT_INVOKER_PRE_TRUNCATE_CMD_TBL event is invoked.
    """
    try:
        telemetry.start()

        start_time = timeit.default_timer()
        args = kwargs.get('args')
        alias_manager = AliasManager(**kwargs)

        # [:] will keep the reference of the original args
        args[:] = alias_manager.transform(args)

        if is_alias_command(['create', 'import'], args):
            load_cmd_tbl_func = kwargs.get('load_cmd_tbl_func', lambda _: {})
            cache_reserved_commands(load_cmd_tbl_func)

        elapsed_time = (timeit.default_timer() - start_time) * 1000
        logger.debug(DEBUG_MSG_WITH_TIMING, args, elapsed_time)

        telemetry.set_execution_time(round(elapsed_time, 2))
    except Exception as client_exception:  # pylint: disable=broad-except
        telemetry.set_exception(client_exception)
        raise
    finally:
        telemetry.conclude()
コード例 #3
0
 def load_full_command_table(self):
     """
     Perform a full load of the command table to get all the reserved command words.
     """
     load_cmd_tbl_func = self.kwargs.get('load_cmd_tbl_func', lambda _: {})
     cache_reserved_commands(load_cmd_tbl_func)
     telemetry.set_full_command_table_loaded()
コード例 #4
0
 def load_full_command_table(self):
     """
     Perform a full load of the command table to get all the reserved command words.
     """
     load_cmd_tbl_func = self.kwargs.get('load_cmd_tbl_func', lambda _: {})
     cache_reserved_commands(load_cmd_tbl_func)
     telemetry.set_full_command_table_loaded()