當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。