当前位置: 首页>>代码示例>>Python>>正文


Python colorama.init方法代码示例

本文整理汇总了Python中colorama.init方法的典型用法代码示例。如果您正苦于以下问题:Python colorama.init方法的具体用法?Python colorama.init怎么用?Python colorama.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在colorama的用法示例。


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

示例1: __init__

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def __init__(self, **kwargs):
        """Setup the initial set of output stream functions."""

        # Begins intercepting output and converting ANSI characters to win32 as applicable
        colorama.init()

        # Refactor this as an Output class
        self.__dict__['redirectErr'] = OutputRedirect(sys.stderr, self.handlePrint, LOG_TYPES[Level.VERBOSE])
        self.__dict__['redirectOut'] = OutputRedirect(sys.stdout, self.handlePrint, LOG_TYPES[Level.VERBOSE])

        # by default, dont steal output and print to console
        self.stealStdio(False)
        self.logToConsole(True)

        # Setattr wraps the output objects in a
        # decorator that allows this class to intercept their output, This dict holds the
        # original objects.
        self.__dict__['outputMappings'] = {}

        for name, func in six.iteritems(kwargs):
            setattr(self, name, func) 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:23,代码来源:output.py

示例2: exe

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def exe(cmd, params):
    """This function runs after preprocessing of code. It actually executes commands with subprocess

    :param cmd: command to be executed with subprocess
    :param params: parameters passed before ` character, i.e. p`echo 1 which means print result of execution
    :return: result of execution. It may be either Result or InteractiveResult
    """

    global _colorama_intialized
    if _is_colorama_enabled() and not _colorama_intialized:
        _colorama_intialized = True
        colorama.init()

    if config.PRINT_ALL_COMMANDS:
        if _is_colorama_enabled():
            _print_stdout(Fore.GREEN + '>>> ' + cmd + Style.RESET_ALL)
        else:
            _print_stdout('>>> ' + cmd)

    if _is_param_set(params, _PARAM_INTERACTIVE):
        return _create_interactive_result(cmd, params)
    else:
        return _create_result(cmd, params) 
开发者ID:lamerman,项目名称:shellpy,代码行数:25,代码来源:core.py

示例3: main

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def main() -> None:
    colorama.init()
    start_time = datetime.now()
    loop = asyncio.get_event_loop()

    tasks = [
        loop.create_task(get_outputs(host_info, COMMANDS))
        for host_info in HOSTS.items()
    ]

    loop.run_until_complete(asyncio.wait(tasks))

    for hostname, task in zip(HOSTS, tasks):
        outputs = task.result()
        print(f"Device {hostname}")
        for command, output in zip(COMMANDS, outputs):
            print(f"===== Output from command {command} =====")
            print(f"{output}\n")
        print(f"=" * 80)

    exec_time = (datetime.now() - start_time).total_seconds()
    print(colorama.Fore.GREEN + f"Summary: it took {exec_time:,.2f} seconds to run") 
开发者ID:dmfigol,项目名称:network-programmability-stream,代码行数:24,代码来源:netdev-async.py

示例4: __init__

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def __init__(self, _args):
        """Initialize Class properties.

        Args:
            _args (namespace): The argparser args Namespace.
        """
        self.args = _args

        # properties
        self.app_path = os.getcwd()
        self.exit_code = 0
        self.ij = InstallJson()
        self.lj = LayoutJson()
        self.permutations = Permutations()
        self.tj = TcexJson()

        # initialize colorama
        c.init(autoreset=True, strip=False) 
开发者ID:ThreatConnect-Inc,项目名称:tcex,代码行数:20,代码来源:bin.py

示例5: __init__

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def __init__(self, color=False, caching=False, reset=False):
        if color:
            colorama.init()
            cmd.Cmd.__init__(self, stdout=colorama.initialise.wrapped_stdout)
        else:
            cmd.Cmd.__init__(self)

        if platform.system() == "Windows":
            self.use_rawinput = False

        self.color = color
        self.caching = caching
        self.reset = reset

        self.fe = None
        self.repl = None
        self.tokenizer = Tokenizer()

        self.__intro()
        self.__set_prompt_path() 
开发者ID:wendlers,项目名称:mpfshell,代码行数:22,代码来源:mpfshell.py

示例6: user_test

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def user_test(
    senna_path="",
    sent="",
    dep_model="",
    batch=False,
    stp_dir="",
    init=False,
    env=False,
    env_path="",
):

    if init:

        download_files()

    main(senna_path, sent, dep_model, batch, stp_dir) 
开发者ID:jawahar273,项目名称:practNLPTools-lite,代码行数:18,代码来源:cli.py

示例7: cprint

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def cprint(type, msg, reset):
    colorama.init()
    message = {
        "action": Fore.YELLOW,
        "positive": Fore.GREEN + Style.BRIGHT,
        "info": Fore.YELLOW,
        "reset": Style.RESET_ALL,
        "red": Fore.RED,
        "white": Fore.WHITE,
        "green": Fore.GREEN,
        "yellow": Fore.YELLOW
    }
    style = message.get(type.lower())

    if type == "error":
        print("{0}\n[*] Error: {1}".format(Fore.RED + Style.BRIGHT, Style.RESET_ALL + Fore.WHITE + msg))
    else:
        print(style + msg, end="")
    if (reset == 1):
        print(Style.RESET_ALL) 
开发者ID:superhedgy,项目名称:AttackSurfaceMapper,代码行数:22,代码来源:subhunter.py

示例8: cprint

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def cprint(type, msg, reset):
    colorama.init()
    message = {
        "action": Fore.YELLOW,
        "positive": Fore.GREEN + Style.BRIGHT,
        "info": Fore.YELLOW,
        "reset": Style.RESET_ALL,
        "red": Fore.RED,
        "white": Fore.WHITE,
        "green": Fore.GREEN,
        "yellow": Fore.YELLOW
    }
    style = message.get(type.lower())


# A resolver wrapper around dnslib.py 
开发者ID:superhedgy,项目名称:AttackSurfaceMapper,代码行数:18,代码来源:subbrute.py

示例9: cprint

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def cprint(type, msg, reset):
    colorama.init()
    message = {
        "action": Fore.YELLOW,
        "positive": Fore.GREEN + Style.BRIGHT,
        "info": Fore.YELLOW,
        "reset": Style.RESET_ALL,
        "red": Fore.RED,
        "white": Fore.WHITE,
        "green": Fore.GREEN,
        "yellow": Fore.YELLOW
    }
    style = message.get(type.lower())

    if type == "error":
        print("{0}\n[*] Error: {1}".format(Fore.RED + Style.BRIGHT, Style.RESET_ALL + Fore.WHITE + msg))
    else:
        print(style + msg, end="")
    if reset == 1:
        print(Style.RESET_ALL)


# Print Results Function - 
开发者ID:superhedgy,项目名称:AttackSurfaceMapper,代码行数:25,代码来源:asm.py

示例10: configure_loggers

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def configure_loggers():
    # first off, configure defaults
    # to enable the use of the logger
    # even before the init was executed.
    logger_config = copy.deepcopy(LOGGER)
    _configure_defaults(logger_config)

    if env.is_initialized():
        # init was already called
        # use the configuration file.
        _configure_from_file(logger_config)
    _set_loggers_verbosity(logger_config)
    logging.config.dictConfig(logger_config)

    global _lgr
    _lgr = logging.getLogger('cloudify.cli.main')

    # configuring events/logs loggers
    # (this will also affect local workflow loggers, which don't use
    # the get_events_logger method of this module)
    if is_use_colors():
        logs.EVENT_CLASS = ColorfulEvent
        # refactor this elsewhere if colorama is further used in CLI
        colorama.init(autoreset=True) 
开发者ID:cloudify-cosmo,项目名称:cloudify-cli,代码行数:26,代码来源:logger.py

示例11: set_mode

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def set_mode(self, mode):
    """Set the mode of the worker.

    The mode SCRIPT_MODE should be used if this Worker is a driver that is being
    run as a Python script or interactively in a shell. It will print
    information about task failures.

    The mode WORKER_MODE should be used if this Worker is not a driver. It will
    not print information about tasks.

    The mode PYTHON_MODE should be used if this Worker is a driver and if you
    want to run the driver in a manner equivalent to serial Python for debugging
    purposes. It will not send remote function calls to the scheduler and will
    insead execute them in a blocking fashion.

    The mode SILENT_MODE should be used only during testing. It does not print
    any information about errors because some of the tests intentionally fail.

    args:
      mode: One of SCRIPT_MODE, WORKER_MODE, PYTHON_MODE, and SILENT_MODE.
    """
    self.mode = mode
    colorama.init() 
开发者ID:ray-project,项目名称:ray-legacy,代码行数:25,代码来源:worker.py

示例12: run_function_on_all_workers

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def run_function_on_all_workers(self, function):
    """Run arbitrary code on all of the workers.

    This function will first be run on the driver, and then it will be exported
    to all of the workers to be run. It will also be run on any new workers that
    register later. If ray.init has not been called yet, then cache the function
    and export it later.

    Args:
      function (Callable): The function to run on all of the workers. It should
        not take any arguments. If it returns anything, its return values will
        not be used.
    """
    if self.mode not in [None, raylib.SCRIPT_MODE, raylib.SILENT_MODE, raylib.PYTHON_MODE]:
      raise Exception("run_function_on_all_workers can only be called on a driver.")
    # First run the function on the driver.
    function(self)
    # If ray.init has not been called yet, then cache the function and export it
    # when connect is called. Otherwise, run the function on all workers.
    if self.mode is None:
      self.cached_functions_to_run.append(function)
    else:
      self.export_function_to_run_on_all_workers(function) 
开发者ID:ray-project,项目名称:ray-legacy,代码行数:25,代码来源:worker.py

示例13: message

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def message(
    *tokens: Token,
    end: str = "\n",
    sep: str = " ",
    fileobj: FileObj = sys.stdout,
    update_title: bool = False
) -> None:
    """ Helper method for error, warning, info, debug

    """
    if using_colorama():
        global _INITIALIZED
        if not _INITIALIZED:
            colorama.init()
            _INITIALIZED = True
    with_color, without_color = process_tokens(tokens, end=end, sep=sep)
    if CONFIG["record"]:
        _MESSAGES.append(without_color)
    if update_title and with_color:
        write_title_string(without_color, fileobj)
    to_write = with_color if config_color(fileobj) else without_color
    write_and_flush(fileobj, to_write) 
开发者ID:TankerHQ,项目名称:python-cli-ui,代码行数:24,代码来源:__init__.py

示例14: init_logger

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def init_logger(log_requests=False):
    """ Initialize the logger """

    logger = logging.getLogger(__name__.split(".")[0])
    for handler in logger.handlers:  # pragma: no cover
        logger.removeHandler(handler)

    if os.name == "nt" and "colorama" in sys.modules:  # pragma: no cover
        colorama.init()

    formatter = coloredlogs.ColoredFormatter(fmt="%(asctime)s: %(message)s")
    handler = logging.StreamHandler(stream=sys.stdout)
    handler.setLevel(logging.DEBUG)
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.setLevel(logging.DEBUG)
    logger.propagate = False

    if log_requests:
        requests.packages.urllib3.add_stderr_logger() 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:22,代码来源:logger.py

示例15: main

# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import init [as 别名]
def main():
    link_data = parse_yaml()
    colorama.init()
    start_time = datetime.now()
    banner()
    user_name = parse_args()
    if not user_name:
        print_usage()
        exit(1)
    print_username(user_name)
    print_delimiter()

    for group, data in link_data.items():
        print_title(group)
        threads = []
        for site, url in data.items():
            t = Thread(target=run_thread, args=[url, site, user_name])
            t.start()
            threads.append(t)
        [th.join() for th in threads]
        print_separator()

    complete_time = datetime.now() - start_time
    print_exec_time(complete_time)
    print_finish() 
开发者ID:0xknown,项目名称:Search4,代码行数:27,代码来源:search4.py


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