Python clint.textui.colored.red() Examples
The following are 30
code examples of clint.textui.colored.red().
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
clint.textui.colored
, or try the search function
.
Example #1
Source File: docopt_dispatch.py From pgrepup with GNU General Public License v3.0 | 6 votes |
def __call__(self, *args, **kwargs): from docopt import docopt arguments = docopt(*args, **kwargs) from ..config import load as config_load from ..config import ConfigFileNotFound try: config_load(arguments['-c']) except ConfigFileNotFound as e: if not arguments['config']: puts(colored.red(str(e))) sys.exit(1) for patterns, function in self._functions.items(): if all(arguments[pattern] for pattern in patterns): function(**self._kwargify(arguments)) return raise DispatchError('None of dispatch conditions %s is triggered' % self._formated_patterns)
Example #2
Source File: mech.py From mech with MIT License | 6 votes |
def push(self, arguments): """ Push a snapshot of the current state of the machine. Usage: mech snapshot push [options] [<instance>] Notes: Take a snapshot of the current state of the machine and 'push' it onto the stack of states. You can use `mech snapshot pop` to restore back to this state at any time. If you use `mech snapshot save` or restore at any point after a push, pop will still bring you back to this pushed state. Options: -h, --help Print this help """ puts_err(colored.red("Not implemented!"))
Example #3
Source File: mech.py From mech with MIT License | 6 votes |
def delete(self, arguments): """ Delete a snapshot taken previously with snapshot save. Usage: mech snapshot delete [options] <name> [<instance>] Options: -h, --help Print this help """ name = arguments['<name>'] instance_name = arguments['<instance>'] instance_name = self.activate(instance_name) vmrun = VMrun(self.vmx, user=self.user, password=self.password) if vmrun.deleteSnapshot(name) is None: puts_err(colored.red("Cannot delete name")) else: puts_err(colored.green("Snapshot {} deleted".format(name)))
Example #4
Source File: mech.py From mech with MIT License | 6 votes |
def update(self, arguments): """ Update the box that is in use in the current mech environment. Usage: mech box update [options] [<name>] Notes: Only if there any updates available. This does not destroy/recreate the machine, so you'll have to do that to see changes. Options: -f, --force Overwrite an existing box if it exists --insecure Do not validate SSL certificates --cacert FILE CA certificate for SSL download --capath DIR CA certificate directory for SSL download --cert FILE A client SSL cert, if needed -h, --help Print this help """ puts_err(colored.red("Not implemented!"))
Example #5
Source File: reference.py From VCF-kit with MIT License | 6 votes |
def resolve_reference_genome(loc): """ Resolve location of reference genome file. """ if loc is None: message("You must specify a genome:") output_genome_list() exit() if os.path.exists(loc): return loc else: if loc in get_genome_list(): reference_location = "{gd}/{loc}/{loc}.fa.gz".format(gd = get_genome_directory(), loc = loc) with indent(4): puts_err(colored.green("\nUsing reference located at %s\n" % reference_location)) return reference_location else: with indent(4): exit(puts_err(colored.red("\nGenome '%s' does not exist\n" % loc)))
Example #6
Source File: mech.py From mech with MIT License | 6 votes |
def down(self, arguments): """ Stops the Mech machine. Usage: mech down [options] [<instance>] Options: --force Force a hard stop -h, --help Print this help """ force = arguments['--force'] instance_name = arguments['<instance>'] instance_name = self.activate(instance_name) vmrun = VMrun(self.vmx, user=self.user, password=self.password) if not force and vmrun.installedTools(): stopped = vmrun.stop() else: stopped = vmrun.stop(mode='hard') if stopped is None: puts_err(colored.red("Not stopped", vmrun)) else: puts_err(colored.green("Stopped", vmrun))
Example #7
Source File: cl_utils.py From bcwallet with Apache License 2.0 | 6 votes |
def confirm(user_prompt=DEFAULT_PROMPT, default=None): if default is True: prompt_to_use = user_prompt + ' [Y/n]: ' elif default is False: prompt_to_use = user_prompt + ' [y/N]: ' elif default is None: prompt_to_use = user_prompt + ': ' else: raise Exception('Bad Default Value: %s' % default) user_input = raw_input(prompt_to_use).strip() if not user_input: return default elif user_input.lower() == 'y': return True elif user_input.lower() == 'n': return False else: puts(colored.red('`%s` is not a valid entry. Please enter either Y or N.' % user_input)) return confirm(user_prompt=user_prompt, default=default)
Example #8
Source File: mech.py From mech with MIT License | 6 votes |
def activate(self, instance_name=None): if not hasattr(self, 'mechfiles'): self.mechfiles = {} if instance_name: instance = utils.settle_instance(instance_name) path = instance.get('path') if not path: puts_err(colored.red(textwrap.fill("Cannot find a valid path for '{}' instance".format(instance_name)))) sys.exit(1) path = os.path.abspath(os.path.expanduser(path)) os.chdir(path) self.activate_mechfile(path) else: path = os.getcwd() self.activate_mechfile(path) instance_name = self.active_mechfile.get('name') or os.path.basename(path) # Use the Mechfile's name if available return instance_name
Example #9
Source File: mech.py From mech with MIT License | 6 votes |
def suspend(self, arguments): """ Suspends the machine. Usage: mech suspend [options] [<instance>] Options: -h, --help Print this help """ instance_name = arguments['<instance>'] instance_name = self.activate(instance_name) vmrun = VMrun(self.vmx, user=self.user, password=self.password) if vmrun.suspend() is None: puts_err(colored.red("Not suspended", vmrun)) else: puts_err(colored.green("Suspended", vmrun))
Example #10
Source File: bcwallet.py From bcwallet with Apache License 2.0 | 6 votes |
def sign_tx_offline(wallet_obj): if wallet_obj.private_key is None: puts(colored.red("bcwallet was booted using a master PUBLIC key %s so it cannot sign transactions.\nPlease load bcwallet with your master PRIVATE key like this:")) priv_to_display = '%s123...' % first4mprv_from_mpub( mpub=wallet_obj.serialize_b58(private=False)) print_bcwallet_basic_priv_opening(priv_to_display=priv_to_display) puts(BCWALLET_PRIVPIPE_EXPLANATION) print_bcwallet_piped_priv_opening(priv_to_display=priv_to_display) puts(BCWALLET_PRIVPIPE_CAT_EXPLANATION) print_bcwallet_piped_priv_cat_opening() puts(BCWALLET_PIPE_ENCRYPTION_EXPLANATION) return else: if USER_ONLINE: # double check in case we booted online and then disconnected if is_connected_to_blockcypher(): puts(colored.red("Why are you trying to sign a transaction offline while connected to the internet?")) puts(colored.red('This feature is for developers to spend funds on their cold wallet without exposing their private keys to an internet connected machine.')) puts(colored.red("If you didn't mean to enter your master PRIVATE key on an internet connected machine, you may want to consider moving your funds to a cold wallet.\n")) # TODO: implement puts(colored.red('Feature Coming Soon'))
Example #11
Source File: __init__.py From s3tk with MIT License | 6 votes |
def delete_unencrypted_version(bucket_name, key, id, dry_run): object_version = s3().ObjectVersion(bucket_name, key, id) try: obj = object_version.get() if obj.get('ServerSideEncryption') or obj.get('SSECustomerAlgorithm'): puts(key + ' ' + id + ' ' + colored.green('encrypted')) return 'encrypted' else: if dry_run: puts(key + ' ' + id + ' ' + colored.blue('to be deleted')) return 'to be deleted' else: puts(key + ' ' + id + ' ' + colored.blue('deleted')) object_version.delete() return 'deleted' except (botocore.exceptions.ClientError, botocore.exceptions.NoCredentialsError) as e: puts(key + ' ' + id + ' ' + colored.red(str(e))) return 'error'
Example #12
Source File: mech.py From mech with MIT License | 6 votes |
def ip(self, arguments): """ Outputs ip of the Mech machine. Usage: mech ip [options] [<instance>] Options: -h, --help Print this help """ instance_name = arguments['<instance>'] instance_name = self.activate(instance_name) vmrun = VMrun(self.vmx, user=self.user, password=self.password) lookup = self.get("enable_ip_lookup", False) ip = vmrun.getGuestIPAddress(lookup=lookup) if ip: puts_err(colored.green(ip)) else: puts_err(colored.red("Unknown IP address"))
Example #13
Source File: __init__.py From s3tk with MIT License | 6 votes |
def scan_object(bucket_name, key): obj = s3().Object(bucket_name, key) str_key = unicode_key(key) try: mode = determine_mode(obj.Acl()) if mode == 'private': puts(str_key + ' ' + colored.green(mode)) else: puts(str_key + ' ' + colored.yellow(mode)) return mode except (botocore.exceptions.ClientError, botocore.exceptions.NoCredentialsError) as e: puts(str_key + ' ' + colored.red(str(e))) return 'error'
Example #14
Source File: __init__.py From s3tk with MIT License | 6 votes |
def fix_check(klass, buckets, dry_run, fix_args={}): for bucket in fetch_buckets(buckets): check = klass(bucket) check.perform() if check.status == 'passed': message = colored.green('already ' + check.pass_message) elif check.status == 'denied': message = colored.red('access denied') else: if dry_run: message = colored.yellow('to be ' + check.pass_message) else: try: check.fix(fix_args) message = colored.blue('just ' + check.pass_message) except botocore.exceptions.ClientError as e: message = colored.red(str(e)) puts(bucket.name + ' ' + message)
Example #15
Source File: core.py From slack-machine with MIT License | 6 votes |
def load_plugins(self): with indent(4): logger.debug("PLUGINS: %s", self._settings['PLUGINS']) for plugin in self._settings['PLUGINS']: for class_name, cls in import_string(plugin): if issubclass(cls, MachineBasePlugin) and cls is not MachineBasePlugin: logger.debug("Found a Machine plugin: {}".format(plugin)) storage = PluginStorage(class_name) instance = cls(SlackClient(), self._settings, storage) missing_settings = self._register_plugin(class_name, instance) if missing_settings: show_invalid(class_name) with indent(4): error_msg = "The following settings are missing: {}".format( ", ".join(missing_settings) ) puts(colored.red(error_msg)) puts(colored.red("This plugin will not be loaded!")) del instance else: instance.init() show_valid(class_name) self._storage.set('manual', dill.dumps(self._help))
Example #16
Source File: mech.py From mech with MIT License | 6 votes |
def port(self, arguments): """ Displays information about guest port mappings. Usage: mech port [options] [<instance>] Options: --guest PORT Output the host port that maps to the given guest port --machine-readable Display machine-readable output -h, --help Print this help """ instance_name = arguments['<instance>'] instance_name = self.activate(instance_name) vmrun = VMrun(self.vmx, user=self.user, password=self.password) for network in vmrun.listHostNetworks().split('\n'): network = network.split() if len(network) > 2 and network[2] == 'nat': print(vmrun.listPortForwardings(network[1])) break else: puts_err(colored.red("Cannot find a nat network"))
Example #17
Source File: i18ntool.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
def update(user, password, lang=None): langs = getlangs(lang) puts(u"Updating %s" % ', '.join(langs)) for loc in langs: with indent(2): puts(u"Downloading PO for %s" % loc) url = (u'https://www.transifex.com/projects/p/formhub/' u'resource/django/l/%(lang)s/download/for_use/' % {'lang': loc}) try: tmp_po_file = download_with_login(url, TX_LOGIN_URL, login=user, password=password, ext='po', username_field='identification', password_field='password', form_id=1) po_file = os.path.join(REPO_ROOT, 'locale', loc, 'LC_MESSAGES', 'django.po') with indent(2): puts(u"Copying downloaded file to %s" % po_file) shutil.move(tmp_po_file, po_file) except Exception as e: puts(colored.red(u"Unable to update %s " u"from Transifex: %r" % (loc, e))) puts(colored.green("sucesssfuly retrieved %s" % loc)) compile_mo(langs)
Example #18
Source File: text.py From slack-machine with MIT License | 5 votes |
def show_invalid(valid_str): puts(colored.red(f"✗ {valid_str}"))
Example #19
Source File: cli.py From blockade with Apache License 2.0 | 5 votes |
def run_cleanups(): _logger.debug("Running cleanup functions") try: get_host_exec().close() except: puts_err( colored.red("\nUnexpected error in cleanup! This may be a Blockade bug.\n")) traceback.print_exc()
Example #20
Source File: runner.py From polytester with MIT License | 5 votes |
def _print_error(self, message): puts(colored.red("ERROR: ") + message)
Example #21
Source File: text.py From slack-machine with MIT License | 5 votes |
def error(err_string): puts(colored.red(f"ERROR: {err_string}"))
Example #22
Source File: utils.py From mech with MIT License | 5 votes |
def catalog_to_mechfile(catalog, name=None, version=None): mechfile = {} versions = catalog.get('versions', []) for v in versions: current_version = v['version'] if not version or current_version == version: for provider in v['providers']: if 'vmware' in provider['name']: mechfile['box'] = catalog['name'] mechfile['box_version'] = current_version mechfile['url'] = provider['url'] return mechfile puts_err(colored.red("Couldn't find a VMWare compatible VM for '{}'{}".format(name, " ({})".format(version) if version else ""))) sys.exit(1)
Example #23
Source File: __init__.py From VCF-kit with MIT License | 5 votes |
def message(message, n_indent = 4, color = "blue"): with indent(n_indent): if color == "blue": puts_err(colored.blue('\n' + message + '\n')) elif color == "red": puts_err(colored.blue('\n' + message + '\n'))
Example #24
Source File: action_pp.py From angr-platforms with BSD 2-Clause "Simplified" License | 5 votes |
def action_pp(state): actions = state.actions.hardcopy for a in actions: if isinstance(a, SimActionExit): print(blue("[%#08x] ===> %s %s" % (a.ins_addr, a.exit_type, a.target))) elif isinstance(a, SimActionData): print("[%#08x] %s %s: %s" % (a.ins_addr, a.action, str(a.tmp), a.data)) elif isinstance(a, SimActionOperation): print(red("[%#08x] %s %s" % (a.ins_addr, a.op, ", ".join([str(e) for e in a.exprs]))))
Example #25
Source File: utils.py From mech with MIT License | 5 votes |
def init_box(name, version, force=False, save=True, requests_kwargs={}): if not locate('.mech', '*.vmx'): name_version_box = add_box(name, name=name, version=version, force=force, save=save, requests_kwargs=requests_kwargs) if not name_version_box: puts_err(colored.red("Cannot find a valid box with a VMX file in it")) sys.exit(1) name, version, box = name_version_box # box = locate(os.path.join(*filter(None, (HOME, 'boxes', name, version))), '*.box') puts_err(colored.blue("Extracting box '{}'...".format(name))) makedirs('.mech') if sys.platform == 'win32': cmd = tar_cmd('-xf', box, force_local=True) else: cmd = tar_cmd('-xf', box) if cmd: startupinfo = None if os.name == "nt": startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW proc = subprocess.Popen(cmd, cwd='.mech', startupinfo=startupinfo) if proc.wait(): puts_err(colored.red("Cannot extract box")) sys.exit(1) else: tar = tarfile.open(box, 'r') tar.extractall('.mech') if not save and box.startswith(tempfile.gettempdir()): os.unlink(box) vmx = get_vmx() update_vmx(vmx) return vmx
Example #26
Source File: utils.py From mech with MIT License | 5 votes |
def add_mechfile(mechfile, name=None, version=None, force=False, save=True, requests_kwargs={}): url = mechfile.get('url') file = mechfile.get('file') name = mechfile.get('box') version = mechfile.get('box_version') if file: return add_box_file(name, version, file, force=force, save=save) if url: return add_box_url(name, version, url, force=force, save=save, requests_kwargs=requests_kwargs) puts_err(colored.red("Couldn't find a VMWare compatible VM for '{}'{}".format(name, " ({})".format(version) if version else "")))
Example #27
Source File: tajima.py From VCF-kit with MIT License | 5 votes |
def main(debug=None): args = docopt(__doc__, version=__version__, argv=debug) if args["<vcf>"] == "": print(__doc__) wz = large_int(args["<window-size>"]) sz = None if not args["--sliding"]: sz = large_int(args["<step-size>"]) if wz < sz: exit(puts_err(colored.red("\n\tWindow size must be >= step size.\n"))) if args["--no-header"] is False: header_line = ["CHROM", "BIN_START", "BIN_END", "N_Sites", "N_SNPs", "TajimaD"] if args["--extra"]: header_line += ["filename", "window_size", "step_size"] print "\t".join(header_line) for i in tajima(args["<vcf>"]).calc_tajima(wz, sz, args["--sliding"], extra=args["--extra"]): print(i)
Example #28
Source File: sshmenu.py From sshmenu with MIT License | 5 votes |
def connection_delete(selected_target): global targets, config_name call(['clear']) puts(colored.red('Delete connection entry for %s' % targets[selected_target]['host'])) puts('') while True: response = input('Are you sure you want to delete this connection [yes|NO]: ').lower() if response == 'no' or response == 'n' or response == '': puts('') puts('Nothing done') break if response == 'yes': config = json.loads(resources.user.read(config_name)) del config['targets'][selected_target] resources.user.write(config_name, json.dumps(config, indent=4)) update_targets() puts('') puts('Connection deleted') break time.sleep(TRANSITION_DELAY_TIME)
Example #29
Source File: utils.py From mech with MIT License | 5 votes |
def index_active_instance(instance_name): path = os.getcwd() instance = settle_instance(instance_name, { 'path': path, }) if instance.get('path') != path: puts_err(colored.red(textwrap.fill(( "There is already a Mech box with the name '{}' at {}" ).format(instance_name, instance.get('path'))))) sys.exit(1) return path
Example #30
Source File: utils.py From mech with MIT License | 5 votes |
def get_vmx(silent=False): vmx = locate('.mech', '*.vmx') if not vmx and not silent: puts_err(colored.red("Cannot locate a VMX file")) sys.exit(1) return vmx