Python blessings.Terminal() Examples
The following are 29
code examples of blessings.Terminal().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
blessings
, or try the search function
.
Example #1
Source File: client.py From open-syllabus-project with Apache License 2.0 | 6 votes |
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'])))
Example #2
Source File: surgical.py From MARA_Framework with GNU Lesser General Public License v3.0 | 6 votes |
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()
Example #3
Source File: commands.py From MARA_Framework with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #4
Source File: ssh.py From mesos-cli with Apache License 2.0 | 6 votes |
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)
Example #5
Source File: logger.py From DPSNet with MIT License | 6 votes |
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()
Example #6
Source File: utils.py From open-syllabus-project with Apache License 2.0 | 6 votes |
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)))
Example #7
Source File: logger.py From cc with MIT License | 6 votes |
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()
Example #8
Source File: __init__.py From mqtt-pwn with GNU General Public License v3.0 | 6 votes |
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)
Example #9
Source File: logger.py From SfmLearner-Pytorch with MIT License | 6 votes |
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()
Example #10
Source File: logger.py From SC-SfMLearner-Release with GNU General Public License v3.0 | 6 votes |
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()
Example #11
Source File: logger.py From unsupervised-depthnet with MIT License | 6 votes |
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()
Example #12
Source File: binja.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, files, apk): Binja.__init__(self) self.t = Terminal() self.logger = Logger() self.files = files self.apk = apk self.libs = list() self.rpc = None self.target_library = None self._init_binja()
Example #13
Source File: cursor.py From progressive with MIT License | 5 votes |
def __init__(self, term=None): self.term = Terminal() if term is None else term self._stream = self.term.stream self._saved = False
Example #14
Source File: output.py From touchandgo with GNU General Public License v3.0 | 5 votes |
def select_chromecast(cls): name = None chromecasts = pychromecast.get_chromecasts_as_dict().keys() if not chromecasts: return if len(chromecasts) > 1: term = Terminal() print(term.clear()) print(term.bold("Touchandgo\n")) print(term.red("Chromecasts Availables")) for i, cc_name in enumerate(chromecasts, 1): option = term.cyan("%s) " % i) option += cc_name print(option) input_text = "Select which chromecast you want to cast (1-%d): " % \ len(chromecasts) user_input = raw_input(input_text) try: opt = int(user_input) - 1 if opt > len(chromecasts) or opt < 1: opt = 0 except ValueError: opt = 0 name = chromecasts[opt] elif len(chromecasts) == 1: name = chromecasts[0] return name
Example #15
Source File: frameworks.py From mesos-cli with Apache License 2.0 | 5 votes |
def main(args): term = blessings.Terminal() table_generator = OrderedDict([ ("ID", lambda x: x.id), ("name", lambda x: x.name), ("host", lambda x: x.hostname), ("active", lambda x: x.active), ("tasks", lambda x: x.task_count), ("cpu", lambda x: x.cpu_allocated), ("mem", lambda x: x.mem_allocated), ("disk", lambda x: x.disk_allocated), ]) tb = prettytable.PrettyTable( [x.upper() for x in table_generator.keys()], border=False, max_table_width=term.width, hrules=prettytable.NONE, vrules=prettytable.NONE, left_padding_width=0, right_padding_width=1 ) def format_row(framework): return [fn(framework) for fn in table_generator.values()] for framework in MASTER.frameworks(active_only=not args.inactive): tb.add_row(format_row(framework)) if tb.rowcount == 0: cli.header('You have no frameworks') else: print(tb)
Example #16
Source File: cli.py From mesos-cli with Apache License 2.0 | 5 votes |
def header(name): term = blessings.Terminal() print("==>" + term.red(str(name)) + "<==")
Example #17
Source File: commands.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, cmdargs=None, doc=""): self.t = Terminal() if not cmdargs: cmdargs = None self.cmdargs = cmdargs self.doc = doc def __str__(self): msg = [self.doc] if self.cmdargs: msg.insert(0, "\n\t{0} : {1} (!)".format("Command not found", self.cmdargs)) return "\n\n".join(msg)
Example #18
Source File: surgical.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, cmdargs=None, doc=""): self.t = Terminal() if not cmdargs: cmdargs = None self.cmdargs = cmdargs self.doc = doc
Example #19
Source File: custom_logging.py From codepost-python with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #20
Source File: util.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self): self.t = Terminal()
Example #21
Source File: attacksurface.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, apk, components): self.t = Terminal() self.logger = Logger() self.apk = apk self.xml = self.apk.get_AndroidManifest() # Populate XML elements self.xml_activities = self.xml.getElementsByTagName("activity") self.xml_services = self.xml.getElementsByTagName("service") self.xml_receivers = self.xml.getElementsByTagName("receiver") self.xml_providers = self.xml.getElementsByTagName("provider") self.components = components
Example #22
Source File: components.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, apk): self.logger = Logger() self.t = Terminal() self.apk = apk self.activities = list() self.services = list() self.receivers = list() self.providers = list()
Example #23
Source File: interact.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, vm, vmx): self.t = Terminal() self.vm = vm self.vmx = vmx self.config = Config()
Example #24
Source File: logger.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self): self.t = Terminal()
Example #25
Source File: jsondiff.py From portingdb with MIT License | 5 votes |
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()
Example #26
Source File: plot.py From westpa with MIT License | 5 votes |
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.")
Example #27
Source File: gpustat.py From mxbox with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()
Example #28
Source File: ps.py From mesos-cli with Apache License 2.0 | 4 votes |
def main(args): term = blessings.Terminal() table_generator = OrderedDict([ # user_time + system_time ("time", lambda x: x.cpu_time), ("state", lambda x: x["state"].split("_")[-1][0]), # mem_rss ("rss", lambda x: util.humanize_bytes(x.rss)), # cpus_limit ("cpu", lambda x: x.cpu_limit), # mem_rss / mem_limit ("%mem", get_memory), # executor.name ("command", lambda x: x.command), ("user", lambda x: x.user), # task_id ("id", lambda x: x["id"]), ]) tb = prettytable.PrettyTable( [x.upper() for x in table_generator.keys()], border=False, max_table_width=term.width, hrules=prettytable.NONE, vrules=prettytable.NONE, left_padding_width=0, right_padding_width=1 ) def format_row(task): try: return [fn(task) for fn in table_generator.values()] except exceptions.SlaveDoesNotExist: return None for row in parallel.by_slave( format_row, MASTER.tasks(active_only=(not args.inactive), fltr=args.task)): if row: tb.add_row(row) if tb.rowcount == 0: print("===>{0}You have no tasks for that filter{1}<===".format( term.red, term.white)) else: print(tb)
Example #29
Source File: main.py From touchandgo with GNU General Public License v3.0 | 4 votes |
def main(): parser = argparse.ArgumentParser( description="Command line tool to watch torrents") parser.add_argument("name", help="The name of the series or movie") parser.add_argument("season_number", default=None, nargs="?", type=int, help="Season number") parser.add_argument("episode_number", default=None, nargs="?", type=int, help="Episode number") parser.add_argument("--sub", nargs='?', default=None, help="Subtitle language") parser.add_argument("--serve", action="store_true", help="Do not run VLC") parser.add_argument("--quality", nargs='?', default=None, help="quality of the video [normal|hd|fullhd]") parser.add_argument("--daemon", action="store_true", help="Daemonize the process"), parser.add_argument("--port", "-p", default="8888", help="The port where the stream will be served") parser.add_argument("--verbose", action="store_true", default=None, help="Show _all_ the logs") parser.add_argument("--player", default='vlc', help="Player to use. vlc|omxplayer|chromecast") parser.add_argument("--nocache", action="store_false", default=True, help="Search for the torrent again"), args = parser.parse_args() log_set_up(args.verbose) log.info("Starting touchandgo") log.debug("Running Python %s on %r", sys.version_info, sys.platform) log.debug("Libtorrent version: %s", libtorrent_version) try: if args.sub is not None: Language(args.sub) touchandgo = SearchAndStream(args.name, season=args.season_number, episode=args.episode_number, sub_lang=args.sub, serve=args.serve, quality=args.quality, port=args.port, player=args.player, use_cache=args.nocache) if args.daemon: def callback(): touchandgo.serve = True touchandgo.watch() daemonize(args, callback) else: term = Terminal() #with term.fullscreen(): touchandgo.watch() except ValueError as e: print(e)