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


Python Fore.RESET属性代码示例

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


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

示例1: view_logs

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def view_logs(server: str, token: str) -> None:
    async with ClientSession() as session:
        async with session.ws_connect(f"{server}/_matrix/maubot/v1/logs") as ws:
            await ws.send_str(token)
            try:
                msg: WSMessage
                async for msg in ws:
                    if msg.type == WSMsgType.TEXT:
                        if not handle_msg(msg.json()):
                            break
                    elif msg.type == WSMsgType.ERROR:
                        print(Fore.YELLOW + "Connection error: " + msg.data + Fore.RESET)
                    elif msg.type == WSMsgType.CLOSE:
                        print(Fore.YELLOW + "Server closed connection" + Fore.RESET)
            except asyncio.CancelledError:
                pass 
开发者ID:maubot,项目名称:maubot,代码行数:18,代码来源:logs.py

示例2: read_meta

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def read_meta(path: str) -> Optional[PluginMeta]:
    try:
        with open(os.path.join(path, "maubot.yaml")) as meta_file:
            try:
                meta_dict = yaml.load(meta_file)
            except YAMLError as e:
                print(Fore.RED + "Failed to build plugin: Metadata file is not YAML")
                print(Fore.RED + str(e) + Fore.RESET)
                return None
    except FileNotFoundError:
        print(Fore.RED + "Failed to build plugin: Metadata file not found" + Fore.RESET)
        return None
    try:
        meta = PluginMeta.deserialize(meta_dict)
    except SerializerError as e:
        print(Fore.RED + "Failed to build plugin: Metadata file is not valid")
        print(Fore.RED + str(e) + Fore.RESET)
        return None
    return meta 
开发者ID:maubot,项目名称:maubot,代码行数:21,代码来源:build.py

示例3: build

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def build(path: str, output: str, upload: bool, server: str) -> None:
    meta = read_meta(path)
    if not meta:
        return
    if output or not upload:
        output = read_output_path(output, meta)
        if not output:
            return
    else:
        output = BytesIO()
    os.chdir(path)
    write_plugin(meta, output)
    if isinstance(output, str):
        print(f"{Fore.GREEN}Plugin built to {Fore.CYAN}{output}{Fore.GREEN}.{Fore.RESET}")
    else:
        output.seek(0)
    if upload:
        upload_plugin(output, server) 
开发者ID:maubot,项目名称:maubot,代码行数:20,代码来源:build.py

示例4: login

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def login(server, username, password, alias) -> None:
    data = {
        "username": username,
        "password": password,
    }
    try:
        with urlopen(f"{server}/_matrix/maubot/v1/auth/login",
                     data=json.dumps(data).encode("utf-8")) as resp_data:
            resp = json.load(resp_data)
            config["servers"][server] = resp["token"]
            if not config["default_server"]:
                print(Fore.CYAN, "Setting", server, "as the default server")
                config["default_server"] = server
            if alias:
                config["aliases"][alias] = server
            save_config()
            print(Fore.GREEN + "Logged in successfully")
    except HTTPError as e:
        try:
            err = json.load(e)
        except json.JSONDecodeError:
            err = {}
        print(Fore.RED + err.get("error", str(e)) + Fore.RESET) 
开发者ID:maubot,项目名称:maubot,代码行数:25,代码来源:login.py

示例5: perform

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def perform(self, requests=None):
        for stage_info, code, request in self.api.dispatch_open_requests(requests):
            action = request.find('action')
            target_package = action.find('target').get('package')
            if code == 'unstage':
                # Technically, the new request has not been staged, but superseded the old one.
                code = None
            verbage = self.CODE_MAP[code]
            if code is not None:
                verbage += ' in favor of'
            print('request {} for {} {} {} in {}'.format(
                request.get('id'),
                Fore.CYAN + target_package + Fore.RESET,
                verbage,
                stage_info['rq_id'],
                Fore.YELLOW + stage_info['prj'] + Fore.RESET)) 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:18,代码来源:supersede_command.py

示例6: run_feed_server

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def run_feed_server():
    #stands up the feed server, points to the CB/json_feeds dir
    chdir('data/json_feeds/')
    port = 8000
    handler = http.server.SimpleHTTPRequestHandler
    httpd = socketserver.TCPServer(("", port), handler)

    try:
        print((Fore.GREEN + '\n[+]' + Fore.RESET), end=' ')
        print(('Feed Server listening at http://%s:8000' % gethostname()))
        httpd.serve_forever()
    except:
        print((Fore.RED + '\n[-]' + Fore.RESET), end=' ')
        print("Server exited")

    return 
开发者ID:opensourcesec,项目名称:Forager,代码行数:18,代码来源:cb_tools.py

示例7: format

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def format(self, record):
        # add color
        if self.colors and record.levelname in COLORS:
            start = COLORS[record.levelname]
            record.levelname = start + record.levelname + Fore.RESET
            record.msg = Fore.WHITE + record.msg + Fore.RESET

        # add extras
        if self.extras:
            extras = merge_record_extra(record=record, target=dict(), reserved=RESERVED_ATTRS)
            record.extras = ', '.join('{}={}'.format(k, v) for k, v in extras.items())
            if record.extras:
                record.extras = Fore.MAGENTA + '({})'.format(record.extras) + Fore.RESET

        # hide traceback
        if not self.traceback:
            record.exc_text = None
            record.exc_info = None
            record.stack_info = None

        return super().format(record) 
开发者ID:dephell,项目名称:dephell,代码行数:23,代码来源:logging_helpers.py

示例8: walker

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def walker(node, source_lines, indent=''):
    """Recursively visit the ast in a preorder traversal."""

    node_name = str(node)[0:str(node).index('(')]
    value = None
    if hasattr(node, 'value'):
        if '(' in str(node.value):
            value = str(node.value)[0:str(node.value).index('(')]
        else:
            value = node.value

    name = node.name if hasattr(node, 'name') else None
    print('{}{} {} (name: {}, value: {})'.format(
        indent, CHAR_TUBE, node_name, name, value))

    lines = [line for line in node.as_string().split('\n')]
    for line in lines:
        print(indent + FILL + '>>>' + Fore.BLUE + line + Fore.RESET)

    for child in node.get_children():
        walker(child, source_lines, indent + FILL + CHAR_PIPE) 
开发者ID:pyta-uoft,项目名称:pyta,代码行数:23,代码来源:print_ast.py

示例9: execute

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def execute():
    cfg = Configuration(".bitmaskctl")
    print_json = '--json' in sys.argv

    cli = BitmaskCLI(cfg)
    cli.data = ['core', 'version']
    args = None if '--noverbose' in sys.argv else ['--verbose']

    if should_start(sys.argv):
        timeout_fun = cli.start
    else:
        def status_timeout(args):
            raise RuntimeError('bitmaskd is not running')
        timeout_fun = status_timeout

    try:
        yield cli._send(
            timeout=0.1, printer=_null_printer,
            errb=lambda: timeout_fun(args))
    except Exception, e:
        print(Fore.RED + "ERROR: " + Fore.RESET +
              "%s" % str(e))
        yield reactor.stop() 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:25,代码来源:bitmask_cli.py

示例10: watch

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def watch(self, raw_args):
        def tail(_file):
            _file.seek(0, 2)      # Go to the end of the file
            while True:
                line = _file.readline()
                if not line:
                    time.sleep(0.1)
                    continue
                yield line

        _file = open(_log_path, 'r')
        print(Fore.GREEN + '[bitmask] ' +
              Fore.RESET + 'Watching log file %s' % _log_path)
        for line in _file.readlines():
            print line,
        for line in tail(_file):
            print line, 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:19,代码来源:logs.py

示例11: print_color

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def print_color(mtype, message=''):
    """@todo: Docstring for print_text.

    :mtype: set if message is 'ok', 'updated', '+', 'fail' or 'sub'
    :type mtype: str
    :message: the message to be shown to the user
    :type message: str

    """

    init(autoreset=False)
    if (mtype == 'ok'):
        print(Fore.GREEN + 'OK' + Fore.RESET + message)
    elif (mtype == '+'):
        print('[+] ' + message + '...'),
    elif (mtype == 'fail'):
        print(Fore.RED + "\n[!]" + message)
    elif (mtype == 'sub'):
        print(('  -> ' + message).ljust(65, '.')),
    elif (mtype == 'subsub'):
        print("\n    -> " + message + '...'),
    elif (mtype == 'up'):
        print(Fore.CYAN + 'UPDATED') 
开发者ID:deimosfr,项目名称:galera_innoptimizer,代码行数:25,代码来源:ginnoptimizer.py

示例12: main

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def main():
    start_time = time.time()
    nr = InitNornir("config.yaml", configure_logging=False)
    # result = nr.run(
    #     task=netmiko_send_command,
    #     command_string="show cdp neighbors detail",
    #     use_textfsm=True,
    # )
    nr.run(
        task=update_lldp_neighbors,
    )
    logger.info("LLDP details were successfully fetched using RESTCONF and OPENCONFIG")
    milestone = time.time()
    time_to_run = milestone - start_time
    print(
        f"{Fore.RED}It took {time_to_run:.2f} seconds to get and parse LLDP details"
        f"{Fore.RESET}"
    )
    graph, edge_labels = build_graph(nr.inventory.hosts.values())
    draw_and_save_topology(graph, edge_labels)
    time_to_run = time.time() - milestone
    print(
        f"{Fore.RED}It took additional {time_to_run:.2f} seconds "
        f"to draw and save the network topology{Fore.RESET}"
    ) 
开发者ID:dmfigol,项目名称:network-programmability-stream,代码行数:27,代码来源:main.py

示例13: print_results

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def print_results(self,results):
    try:
      if results['status'] == 'Pass':
        print ("Status: " + Fore.GREEN + 'Pass' + Fore.RESET)
      elif results['status'] == 'Fail':
        print ("Status: " + Fore.RED + 'Fail' + Fore.RESET)
    except KeyError:
      pass
    except TypeError:
      pass
    print "Description: " + results['descr']
    try:
      res = str(results['output'])
      print "Output: "
      print(Style.DIM + res + Style.RESET_ALL)
    except KeyError:
      pass
    print "\n" 
开发者ID:zuBux,项目名称:drydock,代码行数:20,代码来源:output.py

示例14: print_line

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def print_line(message, level=1, category = None, title = None, status=False):
    sts = get_status(category, status)

    if sts == 'applied':
        color = Fore.GREEN
        pre = '[+] '
    elif sts == 'touse':
        color = Fore.YELLOW
        pre = '[+] '
    elif sts == 'toremove':
        color = Fore.RED
        pre = '[-] '
    else:
        color = ''
        pre = ''

    if title:
        print(' '*4*level + Style.BRIGHT + title + ': ' + Style.RESET_ALL + message)
    else:
        print(' '*4*level + color + Style.BRIGHT + pre + Fore.RESET + message) 
开发者ID:gildasio,项目名称:h2t,代码行数:22,代码来源:output.py

示例15: main

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RESET [as 别名]
def main(city=0):
    send_url = (
        "http://api.openweathermap.org/data/2.5/forecast/daily?q={0}&cnt=1"
        "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=metric".format(city)
    )
    r = requests.get(send_url)
    j = json.loads(r.text)
    rain = j['list'][0]['weather'][0]['id']
    if rain >= 300 and rain <= 500:  # In case of drizzle or light rain
        print(
            Fore.CYAN
            + "It appears that you might need an umbrella today."
            + Fore.RESET)
    elif rain > 700:
        print(
            Fore.CYAN
            + "Good news! You can leave your umbrella at home for today!"
            + Fore.RESET)
    else:
        print(
            Fore.CYAN
            + "Uhh, bad luck! If you go outside, take your umbrella with you."
            + Fore.RESET) 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:25,代码来源:umbrella.py


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