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


Python blessings.Terminal方法代码示例

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


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

示例1: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self, n_epochs, train_size, valid_size):
        self.n_epochs = n_epochs
        self.train_size = train_size
        self.valid_size = valid_size
        self.t = Terminal()
        s = 10
        e = 1   # epoch bar position
        tr = 3  # train bar position
        ts = 6  # valid bar position
        value = self.t.height
        h = int(0 if value is None else value)

        for i in range(10):
            print('')
        self.epoch_bar = progressbar.ProgressBar(
            max_value=n_epochs, fd=Writer(self.t, (0, h-s+e)))

        self.train_writer = Writer(self.t, (0, h-s+tr))
        self.train_bar_writer = Writer(self.t, (0, h-s+tr+1))

        self.valid_writer = Writer(self.t, (0, h-s+ts))
        self.valid_bar_writer = Writer(self.t, (0, h-s+ts+1))

        self.reset_train_bar()
        self.reset_valid_bar() 
开发者ID:JiawangBian,项目名称:SC-SfMLearner-Release,代码行数:27,代码来源:logger.py

示例2: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self, n_epochs, train_size, valid_size):
        self.n_epochs = n_epochs
        self.train_size = train_size
        self.valid_size = valid_size
        self.t = Terminal()
        s = 10
        e = 1   # epoch bar position
        tr = 3  # train bar position
        ts = 6  # valid bar position
        h = self.t.height

        for i in range(10):
            print('')
        self.epoch_bar = progressbar.ProgressBar(max_value=n_epochs, fd=Writer(self.t, (0, h-s+e)))

        self.train_writer = Writer(self.t, (0, h-s+tr))
        self.train_bar_writer = Writer(self.t, (0, h-s+tr+1))

        self.valid_writer = Writer(self.t, (0, h-s+ts))
        self.valid_bar_writer = Writer(self.t, (0, h-s+ts+1))

        self.reset_train_bar()
        self.reset_valid_bar() 
开发者ID:ClementPinard,项目名称:SfmLearner-Pytorch,代码行数:25,代码来源:logger.py

示例3: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self):
        """The class initializer"""

        Cmd.__init__(self, startup_script=config.STARTUP_SCRIPT)

        self.aliases.update({'exit': 'quit'})
        self.hidden_commands.extend(['load', 'pyscript', 'set', 'shortcuts', 'alias', 'unalias', 'py'])

        self.current_victim = None
        self.mqtt_client = None
        self.current_scan = None

        self.t = Terminal()

        self.base_prompt = get_prompt(self)
        self.prompt = self.base_prompt

        categorize((
            BaseMixin.do_edit,
            BaseMixin.do_help,
            BaseMixin.do_history,
            BaseMixin.do_quit,
            BaseMixin.do_shell,
        ), BaseMixin.CMD_CAT_GENERAL) 
开发者ID:akamai-threat-research,项目名称:mqtt-pwn,代码行数:26,代码来源:__init__.py

示例4: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self, n_epochs, train_size, valid_size):
        self.n_epochs = n_epochs
        self.train_size = train_size
        self.valid_size = valid_size
        self.t = Terminal()
        s = 10
        e = 1   # epoch bar position
        tr = 3  # train bar position
        ts = 6  # valid bar position
        h = self.t.height

        for i in range(10):
            print('')
        self.epoch_bar = progressbar.ProgressBar(maxval=n_epochs, fd=Writer(self.t, (0, h-s+e)))

        self.train_writer = Writer(self.t, (0, h-s+tr))
        self.train_bar_writer = Writer(self.t, (0, h-s+tr+1))

        self.valid_writer = Writer(self.t, (0, h-s+ts))
        self.valid_bar_writer = Writer(self.t, (0, h-s+ts+1))

        self.reset_train_bar()
        self.reset_valid_bar() 
开发者ID:anuragranj,项目名称:cc,代码行数:25,代码来源:logger.py

示例5: print_code

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def print_code(code):

    """
    Print an HTTP status code.

    Args:
        code (int)
    """

    term = Terminal()

    if code == 200:
        click.echo(term.green(str(code)))

    else:
        click.echo(term.red(str(code))) 
开发者ID:davidmcclure,项目名称:open-syllabus-project,代码行数:18,代码来源:utils.py

示例6: status

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def status(self):

        """
        List pending/failed counts for each worker.
        """

        term = Terminal()

        for url in self.worker_urls:

            click.echo(url)

            # Get the queue counts.
            r = requests.get(url+'/rq/queues.json')

            for queue in r.json()['queues']:

                # Pending jobs:
                if queue['name'] == 'default':
                    click.echo(term.green(str(queue['count'])))

                # Failed jobs:
                if queue['name'] == 'failed':
                    click.echo(term.red(str(queue['count']))) 
开发者ID:davidmcclure,项目名称:open-syllabus-project,代码行数:26,代码来源:client.py

示例7: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self, vm, vmx):
        SurgicalCmd.__init__(self)
        self.logger = Logger()
        self.t = Terminal()
        self.u = Util()
        self.vm = vm
        self.vmx = vmx
        self.methods = self.vm.get_methods()
        self.intent = IntentModule()
        self.zip = ZipModule()
        self.socket = SocketModule()
        self.system = SystemModule()
        self.crypto = CryptoModule()
        self.modules = [m for m in self.zip,
                        self.intent,
                        self.socket,
                        self.system,
                        self.crypto]
        self.target_module = None
        self.methods_api_usage = list() 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:22,代码来源:surgical.py

示例8: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self, ROOT_DIR):
        Lobotomy.__init__(self)
        self.ROOT_DIR = ROOT_DIR
        self.t = Terminal()
        self.logger = Logger()
        self.util = Util()
        self.apk = None
        self.package = None
        self.vm = None
        self.vmx = None
        self.gmx = None
        self.components = None
        self.dex = None
        self.strings = None
        self.permissions = None
        self.permissions_details = None
        self.files = None
        self.attack_surface = None 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:20,代码来源:commands.py

示例9: main

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def main(args):
    term = blessings.Terminal()

    # There's a security bug in Mavericks wrt. urllib2:
    #     http://bugs.python.org/issue20585
    if platform.system() == "Darwin":
        os.environ["no_proxy"] = "*"

    task = MASTER.task(args.task)

    cmd = [
        "ssh",
        "-t",
        task.slave["hostname"],
        "cd {0} && bash".format(task.directory)
    ]
    if task.directory == "":
        print(term.red + "warning: the task no longer exists on the " +
              "target slave. Will not enter sandbox" + term.white + "\n\n")
        cmd = cmd[:-1]

    log.fn(os.execvp, "ssh", cmd) 
开发者ID:mesosphere-backup,项目名称:mesos-cli,代码行数:24,代码来源:ssh.py

示例10: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self, *args, **kwargs):
        """
        Configure the formatter by initializing the colored terminal captions,
        for the log events which are output to standard output.
        """
        import blessings as _blessings
        _t = _blessings.Terminal()
        f = lambda s: s.format(_t=_t) # Python 2 compatibility of f"..."
        self._title = {
            "DEBUG":   f("{_t.normal}[{_t.bold}{_t.blue}DBUG{_t.normal}]"),
            "INFO":    f("{_t.normal}[{_t.bold}{_t.green}INFO{_t.normal}]"),
            "WARNING": f("{_t.normal}[{_t.bold}{_t.yellow}WARN{_t.normal}]"),
            "ERROR":   f("{_t.normal}[{_t.bold}{_t.red}ERR.{_t.normal}]"),
        }
        super(_SimpleColorFormatter, self).__init__(*args, **kwargs) 
开发者ID:codepost-io,项目名称:codepost-python,代码行数:17,代码来源:custom_logging.py

示例11: print_formatted

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def print_formatted(self, fp=sys.stdout, no_color=False,
                        show_cmd=False, show_user=False, show_pid=False,
                        gpuname_width=16,
                        ):
        # header
        time_format = locale.nl_langinfo(locale.D_T_FMT)
        header_msg = '{t.bold_white}{hostname}{t.normal}  {timestr}'.format(**{
            'hostname' : self.hostname,
            'timestr' : self.query_time.strftime(time_format),
            't' : term if not no_color \
                       else Terminal(force_styling=None)
        })

        fp.write(header_msg)
        fp.write('\n')

        # body
        gpuname_width = max([gpuname_width] + [len(g.entry['name']) for g in self])
        for g in self:
            g.print_to(fp,
                       with_colors=not no_color,
                       show_cmd=show_cmd,
                       show_user=show_user,
                       show_pid=show_pid,
                       gpuname_width=gpuname_width)
            fp.write('\n')

        fp.flush() 
开发者ID:Lyken17,项目名称:mxbox,代码行数:30,代码来源:gpustat.py

示例12: __terminal_histo__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __terminal_histo__(self, vector, labels, fullscreen_mode=True):
        from blessings import Terminal

        self.t = Terminal()
        h = int(self.t.height / 4) * 3
        w = self.t.width
        cols = np.array(vector).shape[0]
        # Let's print this business!

        colwidth = w / cols
        with self.t.fullscreen():
            for y in range(0, h):
                for x in range(0, cols):
                    if x == 0:
                        with self.t.location(0, y):
                            print(self.t.red('{0:.4f}|'.format(float(h-y)/float(h))))
                    with self.t.location((x*colwidth)+8+len(labels[x])/2, y):
                        if vector[x] >= (float(h-y)/float(h)):
                            #print(float(h-y)/float(h))
                            print(self.t.on_blue(' '))
            for x in range(0, cols):
                if x == 0:
                    with self.t.location(x, h):
                        print('States| ')
                with self.t.location((x*colwidth)+8, h):
                    print(self.t.blue(labels[x]))

            if fullscreen_mode:
                input("Press enter to continue.") 
开发者ID:westpa,项目名称:westpa,代码行数:31,代码来源:plot.py

示例13: main

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def main(first_filename, second_filename):
    term = blessings.Terminal()

    with open(first_filename) as f:
        first_data = json.load(f)

    with open(second_filename) as f:
        second_data = json.load(f)

    status_changes = compare_files(first_data, second_data)

    # Print changes.
    print(term.green('Update Fedora data'))
    print(term.green('=================='))
    print()

    for change, packages in sorted(status_changes.items()):
        change_from, change_to = change
        if (
            change_from in {'idle', 'mispackaged'}
            and change_to in {'released', 'legacy-leaf', 'py3-only'}
        ):
            badge_marker = '♥'
        else:
            badge_marker = ''
        print(term.blue('**{}** → **{}** ({}) {}'.format(
            *change, len(packages), badge_marker,
        )))
        for package in packages:
            print('-', package)
        print() 
开发者ID:fedora-python,项目名称:portingdb,代码行数:33,代码来源:jsondiff.py

示例14: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self):
        self.t = Terminal() 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:4,代码来源:logger.py

示例15: __init__

# 需要导入模块: import blessings [as 别名]
# 或者: from blessings import Terminal [as 别名]
def __init__(self, vm, vmx):
        self.t = Terminal()
        self.vm = vm
        self.vmx = vmx
        self.config = Config() 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:7,代码来源:interact.py


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