예제 #1
0
    def __init__(self, fmt=None, datefmt=None, colored=True):
        '''
        Creates formatter.

        Checks whether we are capable of displaying colors.
        If not, colors are disabled regardless of the :colored:.

        Also performs MS Windows CMD init for color support, if necessary.
        '''

        super(DefaultFormatter, self).__init__(fmt=fmt,
                                               datefmt=datefmt
                                               or "%Y.%m.%d %H:%M:%S")
        self.wrapper = TextWrapper()
        self.colored = colored and sys.__stderr__.isatty()
        self.join_str = "\n"

        self._wrap = self.wrapper.wrap
        self._indent = "{}{{0}} ".format(" " * 33)
        self._header = (
            "{inds}{asctime}.{msecs:003.0f} |{levelname:>8}{inde}{block}"
            " {{b}} {name}:{process} {filename}:{lineno}:{funcName}(){{/b}}\n")

        if not self.colored:
            self._wrap = lambda x: [x]
            self._indent = ""
            self._header = (
                "{asctime}.{msecs:003.0f} |{levelname:>8}{block}"
                " {name}:{process} {filename}:{lineno}:{funcName}():")
            self.join_str = ""
        elif os.name == 'nt':
            Windows.enable(auto_colors=True, reset_atexit=True)
예제 #2
0
파일: __init__.py 프로젝트: gomes-/alx
    def print_compare(self, src, dst, a, b, sym):

        from colorclass import Color, Windows

        from terminaltables import SingleTable

        Windows.enable(auto_colors=True, reset_atexit=True)  # Does nothing if not on Windows.

        max_width = 50
        l = [Color('{autocyan}' + self.wrap_text(src, max_width) + '{/autocyan}'),
             sym[0],
             Color('{autocyan}' + self.wrap_text(dst, max_width) + '{/autocyan}')]
        table_data = []
        table_data.append(l)

        for key, value in a.items():
            l = [self.wrap_text(key, max_width), sym[1], ""]
            table_data.append(l)
        for key, value in b.items():
            l = ["", sym[2], self.wrap_text(key, max_width)]
            table_data.append(l)

        table = SingleTable(table_data)
        table.inner_heading_row_border = True
        table.inner_row_border = True
        print(table.table)
예제 #3
0
    def __init__(self, fmt=None, datefmt=None, colored=True):
        '''
        Creates formatter.

        Checks whether we are capable of displaying colors.
        If not, colors are disabled regardless of the :colored:.

        Also performs MS Windows CMD init for color support, if necessary.
        '''

        super(DefaultFormatter, self).__init__(
            fmt=fmt, datefmt=datefmt or "%Y.%m.%d %H:%M:%S"
        )
        self.wrapper = TextWrapper()
        self.colored = colored and sys.__stderr__.isatty()
        self.join_str = "\n"

        self._wrap = self.wrapper.wrap
        self._indent = "{}{{0}} ".format(" " * 33)
        self._header = (
            "{inds}{asctime}.{msecs:003.0f} |{levelname:>8}{inde}{block}"
            " {{b}} {name}:{process} {filename}:{lineno}:{funcName}(){{/b}}\n"
        )

        if not self.colored:
            self._wrap = lambda x: [x]
            self._indent = ""
            self._header = (
                "{asctime}.{msecs:003.0f} |{levelname:>8}{block}"
                " {name}:{process} {filename}:{lineno}:{funcName}():"
            )
            self.join_str = ""
        elif os.name == 'nt':
            Windows.enable(auto_colors=True, reset_atexit=True)
예제 #4
0
    def __init__(self, wallet):
        Windows.enable(auto_colors=True, reset_atexit=True)  # For just Windows
        self.wallet_ = wallet

        self.ETH_usd_ = 0.0
        self.BTC_usd_ = 0.0

        self.time_str_ = "Hello Buddy!"
        self.total_mined_ = 0.0

        self.stats_table_ = []
        self.workers_table_ = []
        self.values_table_ = []

        self.miner_ = {}
        self.worker_ = {}

        self.printDotInfo('Getting data')
        self.getValues()
        self.getStats()
        self.printStats()

        if args.n == 'YES':
            self.displayNonStop()
        else:
            exit()
예제 #5
0
def test():
    """Basic test."""
    with Windows(auto_colors=True):
        print(Color('{autored}Test{/autored}.'))
        sys.stdout.flush()

    Windows.enable(reset_atexit=True)
    print(Color('{autored}{autobgyellow}Test{bgblack}2{/bg}.{/all}'))
예제 #6
0
def main():
    """ Main CLI entrypoint. """
    options = get_options()
    Windows.enable(auto_colors=True, reset_atexit=True)

    try:
        # maybe check if virtualenv is not activated
        check_for_virtualenv(options)

        # 1. detect requirements files
        filenames = RequirementsDetector(
            options.get('<requirements_file>')).get_filenames()
        if filenames:
            print(
                Color(
                    '{{autoyellow}}Found valid requirements file(s):{{/autoyellow}} '
                    '{{autocyan}}\n{}{{/autocyan}}'.format(
                        '\n'.join(filenames))))
        else:  # pragma: nocover
            print(
                Color(
                    '{autoyellow}No requirements files found in current directory. CD into your project '
                    'or manually specify requirements files as arguments.{/autoyellow}'
                ))
            return
        # 2. detect all packages inside requirements
        packages = PackagesDetector(filenames).get_packages()

        # 3. query pypi API, see which package has a newer version vs the one in requirements (or current env)
        packages_status_map = PackagesStatusDetector(
            packages, options.get(
                '--use-default-index')).detect_available_upgrades(options)

        # 4. [optionally], show interactive screen when user can choose which packages to upgrade
        selected_packages = PackageInteractiveSelector(packages_status_map,
                                                       options).get_packages()

        # 5. having the list of packages, do the actual upgrade and replace the version inside all filenames
        upgraded_packages = PackagesUpgrader(selected_packages, filenames,
                                             options).do_upgrade()

        print(
            Color(
                '{{autogreen}}Successfully upgraded (and updated requirements) for the following packages: '
                '{}{{/autogreen}}'.format(','.join(
                    [package['name'] for package in upgraded_packages]))))
        if options['--dry-run']:
            print(
                Color(
                    '{automagenta}Actually, no, because this was a simulation using --dry-run{/automagenta}'
                ))

    except KeyboardInterrupt:  # pragma: nocover
        print(Color('\n{autored}Upgrade interrupted.{/autored}'))
예제 #7
0
def test_enable_then_disable():
    """Test enabling then disabling on Windows."""
    original_stderr_id, original_stdout_id = id(sys.stderr), id(sys.stdout)

    assert not Windows.is_enabled()
    assert Windows.enable()
    assert original_stderr_id != id(sys.stderr)
    assert original_stdout_id != id(sys.stdout)

    assert Windows.disable()
    assert original_stderr_id == id(sys.stderr)
예제 #8
0
파일: tui.py 프로젝트: ghmkoch/winsau
    def _print_screen(self, msg=''):
        from colorclass import Color, Windows
        Windows.enable(auto_colors=True, reset_atexit=True)
        self._update_table()

        os.system('cls')
        print Color(
            '{autobgblack}{autocyan}{}{/autocyan}{/autobgblack}').format(
                'List of tasks'.center(self.MAX_COLUMNS - 1))
        print b'\xc4'.decode('ibm437') * (self.MAX_COLUMNS - 1)
        print self._table.table
        print msg[:self.MAX_COLUMNS]
        input = raw_input("Select a task number or 'q' or 'quit' to quit:")
        Windows.disable()
        if input.lower() in ('quit', 'q', 'exit', 'e'):
            quit()
        else:
            os.system('cls')
            return input
예제 #9
0
def main():
    args = parse_args()
    Windows.enable()

    if args.os:
        os_result = analyze_os()
        columns = os_result.keys()
        values = map(result_color_wrapper, os_result.values())
        print('os:', platform())
        print(tabulate([columns, values], tablefmt='plain'), end='\n\n')

    results = {}
    for file_path in args.file_paths:
        result = engine(file_path)
        if result:
            results[file_path] = result
        else:
            print('[W] not executable file: %s' % file_path, file=sys.stderr)
    
    if not results:
        return

    for file_path, result in results.items():
        columns = result.keys()
        values = map(result_color_wrapper, result.values())
        print('file_path:', file_path)
        print(tabulate([columns, values], tablefmt='plain'), end='\n\n')

    # file
    if args.csv:
        columns = ['file_path'] + list(columns)
        with open('result.csv', 'w', newline='') as f:
            w = csv.writer(f)
            w.writerow(columns)

            for file_path, result in results.items():
                values = [file_path] + list(result.values())
                w.writerow(values)

    if args.json:
        with open('result.json', 'w') as f:
            json.dump(results, f, ensure_ascii=False)
예제 #10
0
def main():
    """Main function."""
    Windows.enable(auto_colors=True, reset_atexit=True)  # Does nothing if not on Windows.

    # Server timings.
    print(table_server_timings())
    print()

    # Server status.
    print(table_server_status())
    print()

    # Two A B C D tables.
    print(table_abcd())
    print()

    # Instructions.
    table_instance = SingleTable([['Obey Obey Obey Obey']], 'Instructions')
    print(table_instance.table)
    print()
def main():
    Windows.enable()  # Does nothing if not on Windows.
    # Prepare.
    if os.name == 'nt':
        locale.setlocale(locale.LC_ALL, 'english-us')
    else:
        locale.resetlocale()
    progress_bar = ProgressBar(5 if OPTIONS['--fast'] else 100)
    progress_bar.bar.CHAR_FULL = Color('{autoyellow}#{/autoyellow}')
    progress_bar.bar.CHAR_LEADING = Color('{autoyellow}#{/autoyellow}')
    progress_bar.bar.CHAR_LEFT_BORDER = Color('{autoblue}[{/autoblue}')
    progress_bar.bar.CHAR_RIGHT_BORDER = Color('{autoblue}]{/autoblue}')

    # Run.
    for i in range(6 if OPTIONS['--fast'] else 101):
        progress_bar.numerator = i
        print(progress_bar, end='\r')
        sys.stdout.flush()
        time.sleep(0.25)
    print(progress_bar)  # Always print one last time.
예제 #12
0
파일: azure.py 프로젝트: gomes-/alx
    def print_list(self):
        try:
            rows = self.tbl_row_query(self.tbl_name, "PartitionKey eq 'net'")
            #print(dir(row))

            from colorclass import Color, Windows

            from terminaltables import AsciiTable

            Windows.enable(auto_colors=True, reset_atexit=True)

            table_data = [[Color('{autocyan}Hostname'),
                           Color('{autocyan}Last Reply'),
                           Color('{autocyan}IP'),
                           Color('{autocyan}OS'),
                           Color('{autocyan}OS Release'),
                           Color('{autocyan}OS Version'),
                           Color('{autocyan}System'),
                           Color('{autocyan}Processor'),
                           ]
                          ]

            max_wrap=10

            for row in rows:
                #d = self.entity2dict(row)
                d = row.__dict__
                time = alxlib.time_help.format_from_timestamp(d['Timestamp'])
                li = [d['hostname'], time, d['ip'], d['os'], d['osrelease'],
                      self.wrap_text(d['osversion'], max_wrap), d["system"],
                      self.wrap_text(d["processor"], max_wrap), ]
                table_data.append(li)

            table = AsciiTable(table_data)

            table.table_data = table_data

            print(table.table)
        except Exception as e:
            logging.warning("Error print_list")
            print(e)
예제 #13
0
def main():
    """Main function."""
    Windows.enable(auto_colors=True,
                   reset_atexit=True)  # Does nothing if not on Windows.

    # Server timings.
    print(table_server_timings())
    print()

    # Server status.
    print(table_server_status())
    print()

    # Two A B C D tables.
    print(table_abcd())
    print()

    # Instructions.
    table_instance = SingleTable([['Obey Obey Obey Obey']], 'Instructions')
    print(table_instance.table)
    print()
예제 #14
0
    def print_node_id_table(self, json, **kwargs):

        for struct in json['results']['nodes']:
            table_data_host = str(struct['hostname'])
            table_data_city = str(struct['city'])
            table_data_countrycode = str(struct['countrycode'])
            table_data_datacenter = str(struct['datacenter'])
            table_data_asn = str(struct['asn'])
            table_data_id = str(struct['id'])
            table_data_ipv4 = str(struct['ipv4'])
            table_data_ipv6 = str(struct['ipv6'])

        if not self.quiet:
            table_data_url = self.ring.build_api_url(
                self.ringconfig.RING_GET_NODE_BY_ID, id=table_data_id)

            Windows.enable(auto_colors=True, reset_atexit=True)
            table_data = [[
                Color('{autogreen}' + str(table_data_host) + '{/autogreen}'),
                Color('{autoblue}' + table_data_url + '{/autoblue}')
            ], [table_data_ipv4 + '\n' + table_data_ipv6, '']]
            table_instance = SingleTable(table_data)
            column_max_width = table_instance.column_max_width(1)
            table_dc_location = table_data_datacenter + " (ASN: " + table_data_asn + ") " + table_data_city + ", " + table_data_countrycode
            table_dc_location = '\n'.join(
                wrap(table_dc_location, column_max_width))
            table_instance.table_data[1][1] = table_dc_location

            print(table_instance.table)

        if self.quiet:
            line_title = Color('{green}' + table_data_host + '{/green}')
            api_url = self.ring.build_api_url(
                self.ringconfig.RING_GET_NODE_BY_ID, id=table_data_id)
            api_url = Color('{blue}' + api_url + '{/blue}')
            print("Node: " + line_title + " ASN " + table_data_asn + " " +
                  table_data_city + " " + table_data_countrycode + " @ " +
                  api_url)
예제 #15
0
def test_disable_safe():
    """Test for safety."""
    original_stderr_id, original_stdout_id = id(sys.stderr), id(sys.stdout)

    assert not Windows.is_enabled()
    assert not Windows.disable()

    assert not Windows.is_enabled()
    assert not Windows.disable()

    assert not Windows.is_enabled()
    assert not Windows.disable()

    assert original_stderr_id == id(sys.stderr)
    assert original_stdout_id == id(sys.stdout)
예제 #16
0
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, print_function, unicode_literals)

import math
import os

from colorclass import Color, Windows
from terminaltables import AsciiTable

from acli.utils import get_console_dimensions

try:
    input = raw_input
except NameError:
    pass
Windows.enable(auto_colors=True, reset_atexit=True)


def output_ascii_table(table_title=None,
                       table_data=None,
                       inner_heading_row_border=False,
                       inner_footing_row_border=False,
                       inner_row_border=False):
    """
    @type table_title: unicode
    @type table_data: list
    @type inner_heading_row_border: bool
    @type inner_footing_row_border: bool
    @type inner_row_border: bool
    """
    table = AsciiTable(table_data)
예제 #17
0
from core.qm.qm import QM
import argparse
import sys
from colorclass import Windows

# TODO
# add validation for variables from CLI and GUI

# enable colours on terminal for windows

if sys.platform == "win32":
    Windows.enable(auto_colors=True)


# used to check if a string can be an integer
def representsInt(s):
    # checks if the string s represents an integer
    try:
        int(s)
        return True
    except ValueError:
        return False


####### read and parse arguments from the command line ########
parser = argparse.ArgumentParser(
    description='Quine McCluskey Circuit Minimizer')
group = parser.add_mutually_exclusive_group()
group.add_argument('-m', '--minterms', default=None)
group.add_argument('-p', '--sop', default='')
# parser.add_argument('minterms', metavar='m', type=str, nargs='+',
예제 #18
0
파일: terminal.py 프로젝트: Flexget/Flexget
from flexget.logger import local_context
from flexget.options import ArgumentParser
from flexget.utils.tools import io_encoding
from terminaltables import (
    AsciiTable,
    SingleTable,
    DoubleTable,
    GithubFlavoredMarkdownTable,
    PorcelainTable,
)
from terminaltables.terminal_io import terminal_size

# Enable terminal colors on windows.
# pythonw (flexget-headless) does not have a sys.stdout, this command would crash in that case
if sys.platform == 'win32' and sys.stdout:
    Windows.enable(auto_colors=True)


def terminal_info():
    """
    Returns info we need about the output terminal.
    When called over IPC, this function is monkeypatched to return the info about the client terminal.
    """
    return {'size': terminal_size(), 'isatty': sys.stdout.isatty()}


class TerminalTable(object):
    """
    A data table suited for CLI output, created via its sent parameters. For example::

        header = ['Col1', 'Col2']
예제 #19
0
            # print(u'Поток', str(i), u'стартовал')
            # print("Number of active flows: ", threading.activeCount())
            # print(u"Количчество активных потоков: ", threading.activeCount())
            t1 = threading.Thread(target=ping, args=(
                work_queue,
                paths,
            ))
            t1.setDaemon(True)
            t1.start()
            time.sleep(0.1)

        work_queue.join(
        )  # Ставим блокировку до тех пор пока не будут выполнены все задания
        if "win" in platform:
            Windows.enable(
                auto_colors=True,
                reset_atexit=True)  # Enable colors in the windows terminal
        else:
            pass
        os.system("cls||clear")
        print(start)
        dict_failed_check_old = get_failed_check_path(path2)
        # print(dict_failed_check_old, 'old_dict')
        dict_failed_check_result = get_list_failed_device(
            dict_failed_check_cur, dict_failed_check_old)
        # print(dict_failed_check_result, 'dict_result')
        print(create_table(dict_devices, dict_failed_check_result))
        with open(path2, "w"
                  ) as f:  # заполняем словарь с ранее проблемными устройствами
            for key in dict_failed_check_result:
                f.writelines('{0};{1}\r\n'.format(
예제 #20
0
def main():
    """Main function called upon script execution."""
    if OPTIONS.get("--no-colors"):
        disable_all_colors()
    elif OPTIONS.get("--colors"):
        enable_all_colors()

    if is_enabled() and os.name == "nt":
        Windows.enable(auto_colors=True, reset_atexit=True)
    elif OPTIONS.get("--light-bg"):
        set_light_background()
    elif OPTIONS.get("--dark-bg"):
        set_dark_background()

    # Light or dark colors.
    print("Autocolors for all backgrounds:")
    print(Color("    {autoblack}Black{/black} {autored}Red{/red} {autogreen}Green{/green} "), end="")
    print(Color("{autoyellow}Yellow{/yellow} {autoblue}Blue{/blue} {automagenta}Magenta{/magenta} "), end="")
    print(Color("{autocyan}Cyan{/cyan} {autowhite}White{/white}"))

    print(Color("    {autobgblack}{autoblack}Black{/black}{/bgblack} "), end="")
    print(Color("{autobgblack}{autored}Red{/red}{/bgblack} {autobgblack}{autogreen}Green{/green}{/bgblack} "), end="")
    print(Color("{autobgblack}{autoyellow}Yellow{/yellow}{/bgblack} "), end="")
    print(Color("{autobgblack}{autoblue}Blue{/blue}{/bgblack} "), end="")
    print(Color("{autobgblack}{automagenta}Magenta{/magenta}{/bgblack} "), end="")
    print(Color("{autobgblack}{autocyan}Cyan{/cyan}{/bgblack} {autobgblack}{autowhite}White{/white}{/bgblack}"))

    print(Color("    {autobgred}{autoblack}Black{/black}{/bgred} {autobgred}{autored}Red{/red}{/bgred} "), end="")
    print(Color("{autobgred}{autogreen}Green{/green}{/bgred} {autobgred}{autoyellow}Yellow{/yellow}{/bgred} "), end="")
    print(Color("{autobgred}{autoblue}Blue{/blue}{/bgred} {autobgred}{automagenta}Magenta{/magenta}{/bgred} "), end="")
    print(Color("{autobgred}{autocyan}Cyan{/cyan}{/bgred} {autobgred}{autowhite}White{/white}{/bgred}"))

    print(Color("    {autobggreen}{autoblack}Black{/black}{/bggreen} "), end="")
    print(Color("{autobggreen}{autored}Red{/red}{/bggreen} {autobggreen}{autogreen}Green{/green}{/bggreen} "), end="")
    print(Color("{autobggreen}{autoyellow}Yellow{/yellow}{/bggreen} "), end="")
    print(Color("{autobggreen}{autoblue}Blue{/blue}{/bggreen} "), end="")
    print(Color("{autobggreen}{automagenta}Magenta{/magenta}{/bggreen} "), end="")
    print(Color("{autobggreen}{autocyan}Cyan{/cyan}{/bggreen} {autobggreen}{autowhite}White{/white}{/bggreen}"))

    print(Color("    {autobgyellow}{autoblack}Black{/black}{/bgyellow} "), end="")
    print(Color("{autobgyellow}{autored}Red{/red}{/bgyellow} "), end="")
    print(Color("{autobgyellow}{autogreen}Green{/green}{/bgyellow} "), end="")
    print(Color("{autobgyellow}{autoyellow}Yellow{/yellow}{/bgyellow} "), end="")
    print(Color("{autobgyellow}{autoblue}Blue{/blue}{/bgyellow} "), end="")
    print(Color("{autobgyellow}{automagenta}Magenta{/magenta}{/bgyellow} "), end="")
    print(Color("{autobgyellow}{autocyan}Cyan{/cyan}{/bgyellow} {autobgyellow}{autowhite}White{/white}{/bgyellow}"))

    print(Color("    {autobgblue}{autoblack}Black{/black}{/bgblue} {autobgblue}{autored}Red{/red}{/bgblue} "), end="")
    print(Color("{autobgblue}{autogreen}Green{/green}{/bgblue} "), end="")
    print(Color("{autobgblue}{autoyellow}Yellow{/yellow}{/bgblue} {autobgblue}{autoblue}Blue{/blue}{/bgblue} "), end="")
    print(Color("{autobgblue}{automagenta}Magenta{/magenta}{/bgblue} "), end="")
    print(Color("{autobgblue}{autocyan}Cyan{/cyan}{/bgblue} {autobgblue}{autowhite}White{/white}{/bgblue}"))

    print(Color("    {autobgmagenta}{autoblack}Black{/black}{/bgmagenta} "), end="")
    print(Color("{autobgmagenta}{autored}Red{/red}{/bgmagenta} "), end="")
    print(Color("{autobgmagenta}{autogreen}Green{/green}{/bgmagenta} "), end="")
    print(Color("{autobgmagenta}{autoyellow}Yellow{/yellow}{/bgmagenta} "), end="")
    print(Color("{autobgmagenta}{autoblue}Blue{/blue}{/bgmagenta} "), end="")
    print(Color("{autobgmagenta}{automagenta}Magenta{/magenta}{/bgmagenta} "), end="")
    print(Color("{autobgmagenta}{autocyan}Cyan{/cyan}{/bgmagenta} "), end="")
    print(Color("{autobgmagenta}{autowhite}White{/white}{/bgmagenta}"))

    print(Color("    {autobgcyan}{autoblack}Black{/black}{/bgcyan} {autobgcyan}{autored}Red{/red}{/bgcyan} "), end="")
    print(Color("{autobgcyan}{autogreen}Green{/green}{/bgcyan} "), end="")
    print(Color("{autobgcyan}{autoyellow}Yellow{/yellow}{/bgcyan} {autobgcyan}{autoblue}Blue{/blue}{/bgcyan} "), end="")
    print(Color("{autobgcyan}{automagenta}Magenta{/magenta}{/bgcyan} "), end="")
    print(Color("{autobgcyan}{autocyan}Cyan{/cyan}{/bgcyan} {autobgcyan}{autowhite}White{/white}{/bgcyan}"))

    print(Color("    {autobgwhite}{autoblack}Black{/black}{/bgwhite} "), end="")
    print(Color("{autobgwhite}{autored}Red{/red}{/bgwhite} {autobgwhite}{autogreen}Green{/green}{/bgwhite} "), end="")
    print(Color("{autobgwhite}{autoyellow}Yellow{/yellow}{/bgwhite} "), end="")
    print(Color("{autobgwhite}{autoblue}Blue{/blue}{/bgwhite} "), end="")
    print(Color("{autobgwhite}{automagenta}Magenta{/magenta}{/bgwhite} "), end="")
    print(Color("{autobgwhite}{autocyan}Cyan{/cyan}{/bgwhite} {autobgwhite}{autowhite}White{/white}{/bgwhite}"))
    print()

    # Light colors.
    print("Light colors for dark backgrounds:")
    print(Color("    {hiblack}Black{/black} {hired}Red{/red} {higreen}Green{/green} "), end="")
    print(Color("{hiyellow}Yellow{/yellow} {hiblue}Blue{/blue} {himagenta}Magenta{/magenta} "), end="")
    print(Color("{hicyan}Cyan{/cyan} {hiwhite}White{/white}"))

    print(Color("    {hibgblack}{hiblack}Black{/black}{/bgblack} "), end="")
    print(Color("{hibgblack}{hired}Red{/red}{/bgblack} {hibgblack}{higreen}Green{/green}{/bgblack} "), end="")
    print(Color("{hibgblack}{hiyellow}Yellow{/yellow}{/bgblack} "), end="")
    print(Color("{hibgblack}{hiblue}Blue{/blue}{/bgblack} "), end="")
    print(Color("{hibgblack}{himagenta}Magenta{/magenta}{/bgblack} "), end="")
    print(Color("{hibgblack}{hicyan}Cyan{/cyan}{/bgblack} {hibgblack}{hiwhite}White{/white}{/bgblack}"))

    print(Color("    {hibgred}{hiblack}Black{/black}{/bgred} {hibgred}{hired}Red{/red}{/bgred} "), end="")
    print(Color("{hibgred}{higreen}Green{/green}{/bgred} {hibgred}{hiyellow}Yellow{/yellow}{/bgred} "), end="")
    print(Color("{hibgred}{hiblue}Blue{/blue}{/bgred} {hibgred}{himagenta}Magenta{/magenta}{/bgred} "), end="")
    print(Color("{hibgred}{hicyan}Cyan{/cyan}{/bgred} {hibgred}{hiwhite}White{/white}{/bgred}"))

    print(Color("    {hibggreen}{hiblack}Black{/black}{/bggreen} "), end="")
    print(Color("{hibggreen}{hired}Red{/red}{/bggreen} {hibggreen}{higreen}Green{/green}{/bggreen} "), end="")
    print(Color("{hibggreen}{hiyellow}Yellow{/yellow}{/bggreen} "), end="")
    print(Color("{hibggreen}{hiblue}Blue{/blue}{/bggreen} "), end="")
    print(Color("{hibggreen}{himagenta}Magenta{/magenta}{/bggreen} "), end="")
    print(Color("{hibggreen}{hicyan}Cyan{/cyan}{/bggreen} {hibggreen}{hiwhite}White{/white}{/bggreen}"))

    print(Color("    {hibgyellow}{hiblack}Black{/black}{/bgyellow} "), end="")
    print(Color("{hibgyellow}{hired}Red{/red}{/bgyellow} "), end="")
    print(Color("{hibgyellow}{higreen}Green{/green}{/bgyellow} "), end="")
    print(Color("{hibgyellow}{hiyellow}Yellow{/yellow}{/bgyellow} "), end="")
    print(Color("{hibgyellow}{hiblue}Blue{/blue}{/bgyellow} "), end="")
    print(Color("{hibgyellow}{himagenta}Magenta{/magenta}{/bgyellow} "), end="")
    print(Color("{hibgyellow}{hicyan}Cyan{/cyan}{/bgyellow} {hibgyellow}{hiwhite}White{/white}{/bgyellow}"))

    print(Color("    {hibgblue}{hiblack}Black{/black}{/bgblue} {hibgblue}{hired}Red{/red}{/bgblue} "), end="")
    print(Color("{hibgblue}{higreen}Green{/green}{/bgblue} "), end="")
    print(Color("{hibgblue}{hiyellow}Yellow{/yellow}{/bgblue} {hibgblue}{hiblue}Blue{/blue}{/bgblue} "), end="")
    print(Color("{hibgblue}{himagenta}Magenta{/magenta}{/bgblue} "), end="")
    print(Color("{hibgblue}{hicyan}Cyan{/cyan}{/bgblue} {hibgblue}{hiwhite}White{/white}{/bgblue}"))

    print(Color("    {hibgmagenta}{hiblack}Black{/black}{/bgmagenta} "), end="")
    print(Color("{hibgmagenta}{hired}Red{/red}{/bgmagenta} "), end="")
    print(Color("{hibgmagenta}{higreen}Green{/green}{/bgmagenta} "), end="")
    print(Color("{hibgmagenta}{hiyellow}Yellow{/yellow}{/bgmagenta} "), end="")
    print(Color("{hibgmagenta}{hiblue}Blue{/blue}{/bgmagenta} "), end="")
    print(Color("{hibgmagenta}{himagenta}Magenta{/magenta}{/bgmagenta} "), end="")
    print(Color("{hibgmagenta}{hicyan}Cyan{/cyan}{/bgmagenta} "), end="")
    print(Color("{hibgmagenta}{hiwhite}White{/white}{/bgmagenta}"))

    print(Color("    {hibgcyan}{hiblack}Black{/black}{/bgcyan} {hibgcyan}{hired}Red{/red}{/bgcyan} "), end="")
    print(Color("{hibgcyan}{higreen}Green{/green}{/bgcyan} "), end="")
    print(Color("{hibgcyan}{hiyellow}Yellow{/yellow}{/bgcyan} {hibgcyan}{hiblue}Blue{/blue}{/bgcyan} "), end="")
    print(Color("{hibgcyan}{himagenta}Magenta{/magenta}{/bgcyan} "), end="")
    print(Color("{hibgcyan}{hicyan}Cyan{/cyan}{/bgcyan} {hibgcyan}{hiwhite}White{/white}{/bgcyan}"))

    print(Color("    {hibgwhite}{hiblack}Black{/black}{/bgwhite} "), end="")
    print(Color("{hibgwhite}{hired}Red{/red}{/bgwhite} {hibgwhite}{higreen}Green{/green}{/bgwhite} "), end="")
    print(Color("{hibgwhite}{hiyellow}Yellow{/yellow}{/bgwhite} "), end="")
    print(Color("{hibgwhite}{hiblue}Blue{/blue}{/bgwhite} "), end="")
    print(Color("{hibgwhite}{himagenta}Magenta{/magenta}{/bgwhite} "), end="")
    print(Color("{hibgwhite}{hicyan}Cyan{/cyan}{/bgwhite} {hibgwhite}{hiwhite}White{/white}{/bgwhite}"))
    print()

    # Dark colors.
    print("Dark colors for light backgrounds:")
    print(Color("    {black}Black{/black} {red}Red{/red} {green}Green{/green} {yellow}Yellow{/yellow} "), end="")
    print(Color("{blue}Blue{/blue} {magenta}Magenta{/magenta} {cyan}Cyan{/cyan} {white}White{/white}"))

    print(Color("    {bgblack}{black}Black{/black}{/bgblack} {bgblack}{red}Red{/red}{/bgblack} "), end="")
    print(Color("{bgblack}{green}Green{/green}{/bgblack} {bgblack}{yellow}Yellow{/yellow}{/bgblack} "), end="")
    print(Color("{bgblack}{blue}Blue{/blue}{/bgblack} {bgblack}{magenta}Magenta{/magenta}{/bgblack} "), end="")
    print(Color("{bgblack}{cyan}Cyan{/cyan}{/bgblack} {bgblack}{white}White{/white}{/bgblack}"))

    print(Color("    {bgred}{black}Black{/black}{/bgred} {bgred}{red}Red{/red}{/bgred} "), end="")
    print(Color("{bgred}{green}Green{/green}{/bgred} {bgred}{yellow}Yellow{/yellow}{/bgred} "), end="")
    print(Color("{bgred}{blue}Blue{/blue}{/bgred} {bgred}{magenta}Magenta{/magenta}{/bgred} "), end="")
    print(Color("{bgred}{cyan}Cyan{/cyan}{/bgred} {bgred}{white}White{/white}{/bgred}"))

    print(Color("    {bggreen}{black}Black{/black}{/bggreen} {bggreen}{red}Red{/red}{/bggreen} "), end="")
    print(Color("{bggreen}{green}Green{/green}{/bggreen} {bggreen}{yellow}Yellow{/yellow}{/bggreen} "), end="")
    print(Color("{bggreen}{blue}Blue{/blue}{/bggreen} {bggreen}{magenta}Magenta{/magenta}{/bggreen} "), end="")
    print(Color("{bggreen}{cyan}Cyan{/cyan}{/bggreen} {bggreen}{white}White{/white}{/bggreen}"))

    print(Color("    {bgyellow}{black}Black{/black}{/bgyellow} {bgyellow}{red}Red{/red}{/bgyellow} "), end="")
    print(Color("{bgyellow}{green}Green{/green}{/bgyellow} {bgyellow}{yellow}Yellow{/yellow}{/bgyellow} "), end="")
    print(Color("{bgyellow}{blue}Blue{/blue}{/bgyellow} {bgyellow}{magenta}Magenta{/magenta}{/bgyellow} "), end="")
    print(Color("{bgyellow}{cyan}Cyan{/cyan}{/bgyellow} {bgyellow}{white}White{/white}{/bgyellow}"))

    print(Color("    {bgblue}{black}Black{/black}{/bgblue} {bgblue}{red}Red{/red}{/bgblue} "), end="")
    print(Color("{bgblue}{green}Green{/green}{/bgblue} {bgblue}{yellow}Yellow{/yellow}{/bgblue} "), end="")
    print(Color("{bgblue}{blue}Blue{/blue}{/bgblue} {bgblue}{magenta}Magenta{/magenta}{/bgblue} "), end="")
    print(Color("{bgblue}{cyan}Cyan{/cyan}{/bgblue} {bgblue}{white}White{/white}{/bgblue}"))

    print(Color("    {bgmagenta}{black}Black{/black}{/bgmagenta} {bgmagenta}{red}Red{/red}{/bgmagenta} "), end="")
    print(Color("{bgmagenta}{green}Green{/green}{/bgmagenta} {bgmagenta}{yellow}Yellow{/yellow}{/bgmagenta} "), end="")
    print(Color("{bgmagenta}{blue}Blue{/blue}{/bgmagenta} {bgmagenta}{magenta}Magenta{/magenta}{/bgmagenta} "), end="")
    print(Color("{bgmagenta}{cyan}Cyan{/cyan}{/bgmagenta} {bgmagenta}{white}White{/white}{/bgmagenta}"))

    print(Color("    {bgcyan}{black}Black{/black}{/bgcyan} {bgcyan}{red}Red{/red}{/bgcyan} "), end="")
    print(Color("{bgcyan}{green}Green{/green}{/bgcyan} {bgcyan}{yellow}Yellow{/yellow}{/bgcyan} "), end="")
    print(Color("{bgcyan}{blue}Blue{/blue}{/bgcyan} {bgcyan}{magenta}Magenta{/magenta}{/bgcyan} "), end="")
    print(Color("{bgcyan}{cyan}Cyan{/cyan}{/bgcyan} {bgcyan}{white}White{/white}{/bgcyan}"))

    print(Color("    {bgwhite}{black}Black{/black}{/bgwhite} {bgwhite}{red}Red{/red}{/bgwhite} "), end="")
    print(Color("{bgwhite}{green}Green{/green}{/bgwhite} {bgwhite}{yellow}Yellow{/yellow}{/bgwhite} "), end="")
    print(Color("{bgwhite}{blue}Blue{/blue}{/bgwhite} {bgwhite}{magenta}Magenta{/magenta}{/bgwhite} "), end="")
    print(Color("{bgwhite}{cyan}Cyan{/cyan}{/bgwhite} {bgwhite}{white}White{/white}{/bgwhite}"))

    if OPTIONS["--wait"]:
        print("Waiting for {0} to exist within 10 seconds...".format(OPTIONS["--wait"]), file=sys.stderr, end="")
        stop_after = time.time() + 20
        while not os.path.exists(OPTIONS["--wait"]) and time.time() < stop_after:
            print(".", file=sys.stderr, end="")
            sys.stderr.flush()
            time.sleep(0.5)
        print(" done")
예제 #21
0
#!/usr/bin/env python
"""Example usage of terminaltables using colorclass.

Just prints sample text and exits.
"""

from __future__ import print_function

from colorclass import Color, Windows

from terminaltables import SingleTable


Windows.enable(auto_colors=True, reset_atexit=True)  # Does nothing if not on Windows.

table_data = [
    [Color('{autobgred}{autogreen}<10ms{/autogreen}{/bgred}'), '192.168.0.100, 192.168.0.101'],
    [Color('{autoyellow}10ms <= 100ms{/autoyellow}'), '192.168.0.102, 192.168.0.103'],
    [Color('{autored}>100ms{/autored}'), '192.168.0.105'],
]
table = SingleTable(table_data)
table.inner_heading_row_border = False
print()
print(table.table)

table.title = '192.168.0.105'
table.justify_columns = {0: 'center', 1: 'center', 2: 'center'}
table.inner_row_border = True
table.table_data = [
    [Color('Low Space'), Color('{autocyan}Nominal Space{/autocyan}'), Color('Excessive Space')],
    [Color('Low Load'), Color('Nominal Load'), Color('{autored}High Load{/autored}')],
예제 #22
0
def main():
    Windows.enable(auto_colors=True, reset_atexit=True)
    bingo()
예제 #23
0
파일: es.py 프로젝트: kalaiser/acli
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, print_function, unicode_literals)

from colorclass import Color, Windows

from acli.output import (output_ascii_table, output_ascii_table_list)

Windows.enable(auto_colors=True, reset_atexit=True)
from external.six import iteritems


def get_tag(name=None, tags=None):
    if tags:
        for tag in tags:
            if tag.get('Key') == name:
                return tag.get('Value')


def output_domain_list(domains=None):
    """
    @type domains: dict
    """
    td = list()
    table_header = [Color('{autoblue}domain name{/autoblue}')]
    for domain in domains:
        td.append([domain.get('DomainName')])
    output_ascii_table_list(
        table_title=Color('{autowhite}ES domains{/autowhite}'),
        table_data=td,
        table_header=table_header,
        inner_heading_row_border=True)
예제 #24
0
def main():
    """Main function called upon script execution."""
    if OPTIONS.get('--no-colors'):
        disable_all_colors()
    elif os.name == 'nt':
        Windows.enable(auto_colors=True, reset_atexit=True)
    elif OPTIONS.get('--light-bg'):
        set_light_background()

    # Light or dark colors.
    print('Autocolors for all backgrounds:')
    print(Color('    {autoblack}Black{/black} {autored}Red{/red} {autogreen}Green{/green} '), end='')
    print(Color('{autoyellow}Yellow{/yellow} {autoblue}Blue{/blue} {automagenta}Magenta{/magenta} '), end='')
    print(Color('{autocyan}Cyan{/cyan} {autowhite}White{/white}'))

    print(Color('    {autobgblack}{autoblack}Black{/black}{/bgblack} '), end='')
    print(Color('{autobgblack}{autored}Red{/red}{/bgblack} {autobgblack}{autogreen}Green{/green}{/bgblack} '), end='')
    print(Color('{autobgblack}{autoyellow}Yellow{/yellow}{/bgblack} '), end='')
    print(Color('{autobgblack}{autoblue}Blue{/blue}{/bgblack} '), end='')
    print(Color('{autobgblack}{automagenta}Magenta{/magenta}{/bgblack} '), end='')
    print(Color('{autobgblack}{autocyan}Cyan{/cyan}{/bgblack} {autobgblack}{autowhite}White{/white}{/bgblack}'))

    print(Color('    {autobgred}{autoblack}Black{/black}{/bgred} {autobgred}{autored}Red{/red}{/bgred} '), end='')
    print(Color('{autobgred}{autogreen}Green{/green}{/bgred} {autobgred}{autoyellow}Yellow{/yellow}{/bgred} '), end='')
    print(Color('{autobgred}{autoblue}Blue{/blue}{/bgred} {autobgred}{automagenta}Magenta{/magenta}{/bgred} '), end='')
    print(Color('{autobgred}{autocyan}Cyan{/cyan}{/bgred} {autobgred}{autowhite}White{/white}{/bgred}'))

    print(Color('    {autobggreen}{autoblack}Black{/black}{/bggreen} '), end='')
    print(Color('{autobggreen}{autored}Red{/red}{/bggreen} {autobggreen}{autogreen}Green{/green}{/bggreen} '), end='')
    print(Color('{autobggreen}{autoyellow}Yellow{/yellow}{/bggreen} '), end='')
    print(Color('{autobggreen}{autoblue}Blue{/blue}{/bggreen} '), end='')
    print(Color('{autobggreen}{automagenta}Magenta{/magenta}{/bggreen} '), end='')
    print(Color('{autobggreen}{autocyan}Cyan{/cyan}{/bggreen} {autobggreen}{autowhite}White{/white}{/bggreen}'))

    print(Color('    {autobgyellow}{autoblack}Black{/black}{/bgyellow} '), end='')
    print(Color('{autobgyellow}{autored}Red{/red}{/bgyellow} '), end='')
    print(Color('{autobgyellow}{autogreen}Green{/green}{/bgyellow} '), end='')
    print(Color('{autobgyellow}{autoyellow}Yellow{/yellow}{/bgyellow} '), end='')
    print(Color('{autobgyellow}{autoblue}Blue{/blue}{/bgyellow} '), end='')
    print(Color('{autobgyellow}{automagenta}Magenta{/magenta}{/bgyellow} '), end='')
    print(Color('{autobgyellow}{autocyan}Cyan{/cyan}{/bgyellow} {autobgyellow}{autowhite}White{/white}{/bgyellow}'))

    print(Color('    {autobgblue}{autoblack}Black{/black}{/bgblue} {autobgblue}{autored}Red{/red}{/bgblue} '), end='')
    print(Color('{autobgblue}{autogreen}Green{/green}{/bgblue} '), end='')
    print(Color('{autobgblue}{autoyellow}Yellow{/yellow}{/bgblue} {autobgblue}{autoblue}Blue{/blue}{/bgblue} '), end='')
    print(Color('{autobgblue}{automagenta}Magenta{/magenta}{/bgblue} '), end='')
    print(Color('{autobgblue}{autocyan}Cyan{/cyan}{/bgblue} {autobgblue}{autowhite}White{/white}{/bgblue}'))

    print(Color('    {autobgmagenta}{autoblack}Black{/black}{/bgmagenta} '), end='')
    print(Color('{autobgmagenta}{autored}Red{/red}{/bgmagenta} '), end='')
    print(Color('{autobgmagenta}{autogreen}Green{/green}{/bgmagenta} '), end='')
    print(Color('{autobgmagenta}{autoyellow}Yellow{/yellow}{/bgmagenta} '), end='')
    print(Color('{autobgmagenta}{autoblue}Blue{/blue}{/bgmagenta} '), end='')
    print(Color('{autobgmagenta}{automagenta}Magenta{/magenta}{/bgmagenta} '), end='')
    print(Color('{autobgmagenta}{autocyan}Cyan{/cyan}{/bgmagenta} '), end='')
    print(Color('{autobgmagenta}{autowhite}White{/white}{/bgmagenta}'))

    print(Color('    {autobgcyan}{autoblack}Black{/black}{/bgcyan} {autobgcyan}{autored}Red{/red}{/bgcyan} '), end='')
    print(Color('{autobgcyan}{autogreen}Green{/green}{/bgcyan} '), end='')
    print(Color('{autobgcyan}{autoyellow}Yellow{/yellow}{/bgcyan} {autobgcyan}{autoblue}Blue{/blue}{/bgcyan} '), end='')
    print(Color('{autobgcyan}{automagenta}Magenta{/magenta}{/bgcyan} '), end='')
    print(Color('{autobgcyan}{autocyan}Cyan{/cyan}{/bgcyan} {autobgcyan}{autowhite}White{/white}{/bgcyan}'))

    print(Color('    {autobgwhite}{autoblack}Black{/black}{/bgwhite} '), end='')
    print(Color('{autobgwhite}{autored}Red{/red}{/bgwhite} {autobgwhite}{autogreen}Green{/green}{/bgwhite} '), end='')
    print(Color('{autobgwhite}{autoyellow}Yellow{/yellow}{/bgwhite} '), end='')
    print(Color('{autobgwhite}{autoblue}Blue{/blue}{/bgwhite} '), end='')
    print(Color('{autobgwhite}{automagenta}Magenta{/magenta}{/bgwhite} '), end='')
    print(Color('{autobgwhite}{autocyan}Cyan{/cyan}{/bgwhite} {autobgwhite}{autowhite}White{/white}{/bgwhite}'))
    print()

    # Light colors.
    print('Light colors for dark backgrounds:')
    print(Color('    {hiblack}Black{/black} {hired}Red{/red} {higreen}Green{/green} '), end='')
    print(Color('{hiyellow}Yellow{/yellow} {hiblue}Blue{/blue} {himagenta}Magenta{/magenta} '), end='')
    print(Color('{hicyan}Cyan{/cyan} {hiwhite}White{/white}'))

    print(Color('    {hibgblack}{hiblack}Black{/black}{/bgblack} '), end='')
    print(Color('{hibgblack}{hired}Red{/red}{/bgblack} {hibgblack}{higreen}Green{/green}{/bgblack} '), end='')
    print(Color('{hibgblack}{hiyellow}Yellow{/yellow}{/bgblack} '), end='')
    print(Color('{hibgblack}{hiblue}Blue{/blue}{/bgblack} '), end='')
    print(Color('{hibgblack}{himagenta}Magenta{/magenta}{/bgblack} '), end='')
    print(Color('{hibgblack}{hicyan}Cyan{/cyan}{/bgblack} {hibgblack}{hiwhite}White{/white}{/bgblack}'))

    print(Color('    {hibgred}{hiblack}Black{/black}{/bgred} {hibgred}{hired}Red{/red}{/bgred} '), end='')
    print(Color('{hibgred}{higreen}Green{/green}{/bgred} {hibgred}{hiyellow}Yellow{/yellow}{/bgred} '), end='')
    print(Color('{hibgred}{hiblue}Blue{/blue}{/bgred} {hibgred}{himagenta}Magenta{/magenta}{/bgred} '), end='')
    print(Color('{hibgred}{hicyan}Cyan{/cyan}{/bgred} {hibgred}{hiwhite}White{/white}{/bgred}'))

    print(Color('    {hibggreen}{hiblack}Black{/black}{/bggreen} '), end='')
    print(Color('{hibggreen}{hired}Red{/red}{/bggreen} {hibggreen}{higreen}Green{/green}{/bggreen} '), end='')
    print(Color('{hibggreen}{hiyellow}Yellow{/yellow}{/bggreen} '), end='')
    print(Color('{hibggreen}{hiblue}Blue{/blue}{/bggreen} '), end='')
    print(Color('{hibggreen}{himagenta}Magenta{/magenta}{/bggreen} '), end='')
    print(Color('{hibggreen}{hicyan}Cyan{/cyan}{/bggreen} {hibggreen}{hiwhite}White{/white}{/bggreen}'))

    print(Color('    {hibgyellow}{hiblack}Black{/black}{/bgyellow} '), end='')
    print(Color('{hibgyellow}{hired}Red{/red}{/bgyellow} '), end='')
    print(Color('{hibgyellow}{higreen}Green{/green}{/bgyellow} '), end='')
    print(Color('{hibgyellow}{hiyellow}Yellow{/yellow}{/bgyellow} '), end='')
    print(Color('{hibgyellow}{hiblue}Blue{/blue}{/bgyellow} '), end='')
    print(Color('{hibgyellow}{himagenta}Magenta{/magenta}{/bgyellow} '), end='')
    print(Color('{hibgyellow}{hicyan}Cyan{/cyan}{/bgyellow} {hibgyellow}{hiwhite}White{/white}{/bgyellow}'))

    print(Color('    {hibgblue}{hiblack}Black{/black}{/bgblue} {hibgblue}{hired}Red{/red}{/bgblue} '), end='')
    print(Color('{hibgblue}{higreen}Green{/green}{/bgblue} '), end='')
    print(Color('{hibgblue}{hiyellow}Yellow{/yellow}{/bgblue} {hibgblue}{hiblue}Blue{/blue}{/bgblue} '), end='')
    print(Color('{hibgblue}{himagenta}Magenta{/magenta}{/bgblue} '), end='')
    print(Color('{hibgblue}{hicyan}Cyan{/cyan}{/bgblue} {hibgblue}{hiwhite}White{/white}{/bgblue}'))

    print(Color('    {hibgmagenta}{hiblack}Black{/black}{/bgmagenta} '), end='')
    print(Color('{hibgmagenta}{hired}Red{/red}{/bgmagenta} '), end='')
    print(Color('{hibgmagenta}{higreen}Green{/green}{/bgmagenta} '), end='')
    print(Color('{hibgmagenta}{hiyellow}Yellow{/yellow}{/bgmagenta} '), end='')
    print(Color('{hibgmagenta}{hiblue}Blue{/blue}{/bgmagenta} '), end='')
    print(Color('{hibgmagenta}{himagenta}Magenta{/magenta}{/bgmagenta} '), end='')
    print(Color('{hibgmagenta}{hicyan}Cyan{/cyan}{/bgmagenta} '), end='')
    print(Color('{hibgmagenta}{hiwhite}White{/white}{/bgmagenta}'))

    print(Color('    {hibgcyan}{hiblack}Black{/black}{/bgcyan} {hibgcyan}{hired}Red{/red}{/bgcyan} '), end='')
    print(Color('{hibgcyan}{higreen}Green{/green}{/bgcyan} '), end='')
    print(Color('{hibgcyan}{hiyellow}Yellow{/yellow}{/bgcyan} {hibgcyan}{hiblue}Blue{/blue}{/bgcyan} '), end='')
    print(Color('{hibgcyan}{himagenta}Magenta{/magenta}{/bgcyan} '), end='')
    print(Color('{hibgcyan}{hicyan}Cyan{/cyan}{/bgcyan} {hibgcyan}{hiwhite}White{/white}{/bgcyan}'))

    print(Color('    {hibgwhite}{hiblack}Black{/black}{/bgwhite} '), end='')
    print(Color('{hibgwhite}{hired}Red{/red}{/bgwhite} {hibgwhite}{higreen}Green{/green}{/bgwhite} '), end='')
    print(Color('{hibgwhite}{hiyellow}Yellow{/yellow}{/bgwhite} '), end='')
    print(Color('{hibgwhite}{hiblue}Blue{/blue}{/bgwhite} '), end='')
    print(Color('{hibgwhite}{himagenta}Magenta{/magenta}{/bgwhite} '), end='')
    print(Color('{hibgwhite}{hicyan}Cyan{/cyan}{/bgwhite} {hibgwhite}{hiwhite}White{/white}{/bgwhite}'))
    print()

    # Dark colors.
    print('Dark colors for light backgrounds:')
    print(Color('    {black}Black{/black} {red}Red{/red} {green}Green{/green} {yellow}Yellow{/yellow} '), end='')
    print(Color('{blue}Blue{/blue} {magenta}Magenta{/magenta} {cyan}Cyan{/cyan} {white}White{/white}'))

    print(Color('    {bgblack}{black}Black{/black}{/bgblack} {bgblack}{red}Red{/red}{/bgblack} '), end='')
    print(Color('{bgblack}{green}Green{/green}{/bgblack} {bgblack}{yellow}Yellow{/yellow}{/bgblack} '), end='')
    print(Color('{bgblack}{blue}Blue{/blue}{/bgblack} {bgblack}{magenta}Magenta{/magenta}{/bgblack} '), end='')
    print(Color('{bgblack}{cyan}Cyan{/cyan}{/bgblack} {bgblack}{white}White{/white}{/bgblack}'))

    print(Color('    {bgred}{black}Black{/black}{/bgred} {bgred}{red}Red{/red}{/bgred} '), end='')
    print(Color('{bgred}{green}Green{/green}{/bgred} {bgred}{yellow}Yellow{/yellow}{/bgred} '), end='')
    print(Color('{bgred}{blue}Blue{/blue}{/bgred} {bgred}{magenta}Magenta{/magenta}{/bgred} '), end='')
    print(Color('{bgred}{cyan}Cyan{/cyan}{/bgred} {bgred}{white}White{/white}{/bgred}'))

    print(Color('    {bggreen}{black}Black{/black}{/bggreen} {bggreen}{red}Red{/red}{/bggreen} '), end='')
    print(Color('{bggreen}{green}Green{/green}{/bggreen} {bggreen}{yellow}Yellow{/yellow}{/bggreen} '), end='')
    print(Color('{bggreen}{blue}Blue{/blue}{/bggreen} {bggreen}{magenta}Magenta{/magenta}{/bggreen} '), end='')
    print(Color('{bggreen}{cyan}Cyan{/cyan}{/bggreen} {bggreen}{white}White{/white}{/bggreen}'))

    print(Color('    {bgyellow}{black}Black{/black}{/bgyellow} {bgyellow}{red}Red{/red}{/bgyellow} '), end='')
    print(Color('{bgyellow}{green}Green{/green}{/bgyellow} {bgyellow}{yellow}Yellow{/yellow}{/bgyellow} '), end='')
    print(Color('{bgyellow}{blue}Blue{/blue}{/bgyellow} {bgyellow}{magenta}Magenta{/magenta}{/bgyellow} '), end='')
    print(Color('{bgyellow}{cyan}Cyan{/cyan}{/bgyellow} {bgyellow}{white}White{/white}{/bgyellow}'))

    print(Color('    {bgblue}{black}Black{/black}{/bgblue} {bgblue}{red}Red{/red}{/bgblue} '), end='')
    print(Color('{bgblue}{green}Green{/green}{/bgblue} {bgblue}{yellow}Yellow{/yellow}{/bgblue} '), end='')
    print(Color('{bgblue}{blue}Blue{/blue}{/bgblue} {bgblue}{magenta}Magenta{/magenta}{/bgblue} '), end='')
    print(Color('{bgblue}{cyan}Cyan{/cyan}{/bgblue} {bgblue}{white}White{/white}{/bgblue}'))

    print(Color('    {bgmagenta}{black}Black{/black}{/bgmagenta} {bgmagenta}{red}Red{/red}{/bgmagenta} '), end='')
    print(Color('{bgmagenta}{green}Green{/green}{/bgmagenta} {bgmagenta}{yellow}Yellow{/yellow}{/bgmagenta} '), end='')
    print(Color('{bgmagenta}{blue}Blue{/blue}{/bgmagenta} {bgmagenta}{magenta}Magenta{/magenta}{/bgmagenta} '), end='')
    print(Color('{bgmagenta}{cyan}Cyan{/cyan}{/bgmagenta} {bgmagenta}{white}White{/white}{/bgmagenta}'))

    print(Color('    {bgcyan}{black}Black{/black}{/bgcyan} {bgcyan}{red}Red{/red}{/bgcyan} '), end='')
    print(Color('{bgcyan}{green}Green{/green}{/bgcyan} {bgcyan}{yellow}Yellow{/yellow}{/bgcyan} '), end='')
    print(Color('{bgcyan}{blue}Blue{/blue}{/bgcyan} {bgcyan}{magenta}Magenta{/magenta}{/bgcyan} '), end='')
    print(Color('{bgcyan}{cyan}Cyan{/cyan}{/bgcyan} {bgcyan}{white}White{/white}{/bgcyan}'))

    print(Color('    {bgwhite}{black}Black{/black}{/bgwhite} {bgwhite}{red}Red{/red}{/bgwhite} '), end='')
    print(Color('{bgwhite}{green}Green{/green}{/bgwhite} {bgwhite}{yellow}Yellow{/yellow}{/bgwhite} '), end='')
    print(Color('{bgwhite}{blue}Blue{/blue}{/bgwhite} {bgwhite}{magenta}Magenta{/magenta}{/bgwhite} '), end='')
    print(Color('{bgwhite}{cyan}Cyan{/cyan}{/bgwhite} {bgwhite}{white}White{/white}{/bgwhite}'))
예제 #25
0
#!/usr/bin/env python
"""Example usage of terminaltables using colorclass.

Just prints sample text and exits.
"""

from __future__ import print_function

from colorclass import Color, Windows

from terminaltables import SingleTable

Windows.enable(auto_colors=True,
               reset_atexit=True)  # Does nothing if not on Windows.

table_data = [
    [
        Color('{autobgred}{autogreen}<10ms{/autogreen}{/bgred}'),
        '192.168.0.100, 192.168.0.101'
    ],
    [
        Color('{autoyellow}10ms <= 100ms{/autoyellow}'),
        '192.168.0.102, 192.168.0.103'
    ],
    [Color('{autored}>100ms{/autored}'), '192.168.0.105'],
]
table = SingleTable(table_data)
table.inner_heading_row_border = False
print()
print(table.table)
예제 #26
0
    def __init__(self, api_key, id, currency, fiat_currency, dcoin, d2coin,
                 d3coin, d4coin, reload_time):
        Windows.enable(auto_colors=True, reset_atexit=True)  # For just Windows
        self.key_ = api_key
        self.id_ = id
        self.cur_ = currency
        self.fcur_ = fiat_currency
        self.coin_ = dcoin
        self.coin2_ = d2coin
        self.coin3_ = d3coin
        self.coin4_ = d4coin
        self.reload_time_ = int(reload_time)
        self.crypto_symbols_ = {}

        self.btc_ = 0.0  # 1 BTC in USD

        if self.reload_time_ > 1800 or int(reload_time) < 15:
            print(
                'reload_time argument must be between 10 and 1800. For more info, run $ python3 display.py --help'
            )
            exit()

        self.setSymbols()

        #print(Color('{autoyellow}benafleck{/autoyellow}')) # lol ;)

        self.time_str_ = 'Hello world, What time is it?'

        self.dot_count_ = 0

        self.other_cur = False
        if args.f != None:
            self.other_cur = True

        self.dashb_ = False
        self.dashb2_ = False
        self.dashb3_ = False
        self.dashb4_ = False
        if args.d != None:
            self.dashb_ = True
        if args.d2 != None:
            self.dashb2_ = True
        if args.d3 != None:
            self.dashb3_ = True
        if args.d4 != None:
            self.dashb4_ = True

        self.balances_table_data_ = []
        self.balances_table_ = SingleTable([])

        if self.dashb_:
            self.dashb_table_data_ = []
            self.dashb_table_ = SingleTable([])

        if self.dashb2_:
            self.dashb2_table_data_ = []
            self.dashb2_table_ = SingleTable([])

        if self.dashb3_:
            self.dashb3_table_data_ = []
            self.dashb3_table_ = SingleTable([])

        if self.dashb4_:
            self.dashb4_table_data_ = []
            self.dashb4_table_ = SingleTable([])

        self.printDotInfo('Getting values and converting to currencies')
        self.getStats()
        self.printTables()

        if args.n == 'YES':
            self.displayNonStop()
        else:
            exit()
예제 #27
0
from colorclass import Windows
import re
import traceback

Windows.enable()

# distributions
#

PACKET_SIZE_DISTRIBUTION = ""
INTERARRIVAL_TIME_DISTRIBUTION = ""
UNIFORM_MIN = 1
UNIFORM_MAX = 1
GAMMA_SHAPE = 1
GAMMA_SCALE = 1
SEED = None

POINTS = []
packet_size_re = "\t(\w+)\(a=(\d+), b=(\d+).*"
arrival_time_re = "\t(\w+)\(shape=([\d\?\.]+), scale=([\d\?\.]+).*"
points_re = "Node\d\(0\.(\d+), 0\.(\d+)\);"
try:
    for i, line in enumerate(open('./data/affabris.data')):
        size = re.search(packet_size_re, line)
        if(size):
            PACKET_SIZE_DISTRIBUTION = size.group(1)
            UNIFORM_MIN = int(size.group(2))
            UNIFORM_MAX = int(size.group(3))
        time = re.search(arrival_time_re, line)
        if(time):
            INTERARRIVAL_TIME_DISTRIBUTION = time.group(1)