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