Exemplo n.º 1
0
def check(three=None, python=False):
    # Ensure that virtualenv is available.
    ensure_project(three=three, python=python, validate=False)

    click.echo(crayons.yellow('Checking PEP 508 requirements...'))

    # Run the PEP 508 checker in the virtualenv.
    c = delegator.run('{0} {1}'.format(which('python'), pep508checker.__file__.rstrip('cdo')))
    results = json.loads(c.out)

    # Load the pipfile.
    p = pipfile.Pipfile.load(project.pipfile_location)

    failed = False
    # Assert each specified requirement.
    for marker, specifier in p.data['_meta']['requires'].items():

            if marker in results:
                try:
                    assert results[marker] == specifier
                except AssertionError:
                    failed = True
                    click.echo('Specifier {0} does not match {1} ({2}).'.format(crayons.green(marker), crayons.blue(specifier), crayons.red(results[marker])))
    if failed:
        click.echo(crayons.red('Failed!'))
        sys.exit(1)
    else:
        click.echo(crayons.green('Passed!'))
Exemplo n.º 2
0
def format_help(help):
    """Formats the help string."""
    help = help.replace('  check', str(crayons.green('  check')))
    help = help.replace('  uninstall', str(crayons.yellow('  uninstall', bold=True)))
    help = help.replace('  install', str(crayons.yellow('  install', bold=True)))
    help = help.replace('  lock', str(crayons.red('  lock', bold=True)))
    help = help.replace('  run', str(crayons.blue('  run')))
    help = help.replace('  shell', str(crayons.blue('  shell', bold=True)))
    help = help.replace('  update', str(crayons.yellow('  update')))

    additional_help = """
Usage Examples:
   Create a new project using Python 3:
   $ {0}

   Install all dependencies for a project (including dev):
   $ {1}

   Create a lockfile:
   $ {2}

Commands:""".format(
        crayons.red('pipenv --three'),
        crayons.red('pipenv install --dev'),
        crayons.red('pipenv lock')
    )

    help = help.replace('Commands:', additional_help)

    return help
Exemplo n.º 3
0
def login_sso(show_token: bool, one_time: bool, confirm_all: bool, detached_mode: bool, env_name: str):
    if env_name:
        context.set_active_env(env_name)
    env = context.current_env()
    if not confirm_all:
        response = click.confirm(_sso_disclaimer)
        if not response:
            exit(1)
    if not one_time:
        click.echo('Logging in to [{0}]...'.format(env.name))

    try:
        if detached_mode:
            token = auth.login_sso_detached(env.api_url)
        else:
            token = auth.login_sso(env.api_url)
    except Exception as ex:
        click.echo(crayons.red(str(ex)), err=True)
        exit(1)
        return

    if not one_time:
        env.set_token(token)
        context.save()

    if show_token or one_time:
        print(token.strip())
    else:
        click.echo(crayons.green('You\'re now logged in as [{0}] in [{1}].'.format(env.username, env.name)))
Exemplo n.º 4
0
def proper_case(package_name):

    # Capture tag contents here.
    collected = []

    class SimpleHTMLParser(HTMLParser):
        def handle_data(self, data):
            # Remove extra blank data from https://pypi.org/simple
            data = data.strip()
            if len(data) > 2:
                collected.append(data)

    # Hit the simple API.
    r = requests.get('https://pypi.org/simple/{0}'.format(package_name))
    if not r.ok:
        raise IOError('Unable to find package {0} in PyPI repository.'.format(crayons.green(package_name)))

    # Parse the HTML.
    parser = SimpleHTMLParser()
    parser.feed(r.text)

    r = parse.parse('Links for {name}', collected[1])
    good_name = r['name']

    return good_name
Exemplo n.º 5
0
def clear_context():
    try:
        context.clear()
    except Exception as ex:
        click.echo(crayons.red(str(ex)), err=True)
        exit(1)
        return
    click.echo(crayons.green('Context cleared'))
Exemplo n.º 6
0
def install(package_name=False, more_packages=False, dev=False, three=False, python=False, system=False, lock=False):

    # Ensure that virtualenv is available.
    ensure_project(three=three, python=python)

    # Allow more than one package to be provided.
    package_names = (package_name,) + more_packages

    # Install all dependencies, if none was provided.
    if package_name is False:
        click.echo(crayons.yellow('No package provided, installing all dependencies.'), err=True)
        do_init(dev=dev, allow_global=system)
        sys.exit(0)

    for package_name in package_names:
        click.echo('Installing {0}...'.format(crayons.green(package_name)))

        # pip install:
        with spinner():
            c = pip_install(package_name, allow_global=system)

        click.echo(crayons.blue(format_pip_output(c.out)))

        # TODO: This
        # Ensure that package was successfully installed.
        try:
            assert c.return_code == 0
        except AssertionError:
            click.echo('{0} An error occurred while installing {1}!'.format(crayons.red('Error: '), crayons.green(package_name)))
            click.echo(crayons.blue(format_pip_error(c.err)))
            sys.exit(1)

        if dev:
            click.echo('Adding {0} to Pipfile\'s {1}...'.format(crayons.green(package_name), crayons.red('[dev-packages]')))
        else:
            click.echo('Adding {0} to Pipfile\'s {1}...'.format(crayons.green(package_name), crayons.red('[packages]')))

        # Add the package to the Pipfile.
        project.add_package_to_pipfile(package_name, dev)

        # Ego boost.
        easter_egg(package_name)

        if lock:
            do_lock()
Exemplo n.º 7
0
def uninstall(package_name=False, more_packages=False, three=None, python=False, system=False, lock=False, dev=False, all=False):
    # Ensure that virtualenv is available.
    ensure_project(three=three, python=python)

    package_names = (package_name,) + more_packages
    pipfile_remove = True

    # Un-install all dependencies, if --all was provided.
    if all is True:
        if not dev:
            click.echo(crayons.yellow('Un-installing all packages from virtualenv...'))
            do_purge(allow_global=system)
            sys.exit(0)

    # Uninstall [dev-packages], if --dev was provided.
    if dev:
        if 'dev-packages' in project.parsed_pipfile:
            click.echo(crayons.yellow('Un-installing {0}...'.format(crayons.red('[dev-packages]'))))
            package_names = project.parsed_pipfile['dev-packages']
            pipfile_remove = False
        else:
            click.echo(crayons.yellow('No {0} to uninstall.'.format(crayons.red('[dev-packages]'))))
            sys.exit(0)

    if package_name is False and not dev:
        click.echo(crayons.red('No package provided!'))
        sys.exit(1)

    for package_name in package_names:

        click.echo('Un-installing {0}...'.format(crayons.green(package_name)))

        c = delegator.run('{0} uninstall {1} -y'.format(which_pip(allow_global=system), package_name))
        click.echo(crayons.blue(c.out))

        if pipfile_remove:
            if dev:
                click.echo('Removing {0} from Pipfile\'s {1}...'.format(crayons.green(package_name), crayons.red('[dev-packages]')))
            else:
                click.echo('Removing {0} from Pipfile\'s {1}...'.format(crayons.green(package_name), crayons.red('[packages]')))

            project.remove_package_from_pipfile(package_name, dev)

        if lock:
            do_lock()
Exemplo n.º 8
0
def set_active_env(env_name: str):
    try:
        context.set_active_env(env_name)
        context.save()
    except Exception as ex:
        click.echo(crayons.red(str(ex)), err=True)
        exit(1)
        return

    click.echo(crayons.green('Current environment set to: {0}'.format(env_name)))
Exemplo n.º 9
0
def add_env(env_name: str, api_url: str, bundle_url: str):
    try:
        context.add_env(env_name, api_url, bundle_url)
        context.set_active_env(env_name)
        context.save()
    except Exception as ex:
        click.echo(crayons.red(str(ex)), err=True)
        exit(1)
        return

    click.echo(crayons.green('Environment [{0}] added and set as active'.format(env_name)))
Exemplo n.º 10
0
 def update_status(config, status, computer, manager):
     """Update each application's status."""
     log.info("Recording application status...")
     for application in config.applications:
         latest = status.get_latest(application)
         if manager.is_running(application):
             if computer != latest:
                 if status.is_running(application, computer):
                     # case 1: application just launched remotely
                     manager.stop(application)
                     status.stop(application, computer)
                     print(crayons.green(
                         f"{application} is now running on {latest}"))
                     print(crayons.red(
                         f"{application} is now stopped on {computer}"))
                 else:
                     # case 2: application just launched locally
                     status.start(application, computer)
                     print(crayons.green(
                         f"{application} is now running on {computer}"))
             else:
                 # case 3: application already running locally
                 print(crayons.cyan(
                     f"{application} is running on {computer}"))
         else:
             if status.is_running(application, computer):
                 # case 4: application just closed locally
                 status.stop(application, computer)
                 print(crayons.red(
                     f"{application} is now stopped on {computer}"))
             elif latest:
                 # case 5: application already closed locally
                 print(crayons.magenta(
                     f"{application} is running on {latest}"))
             else:
                 # case 6: application is not running
                 print(crayons.white(
                     f"{application} is not running"))
Exemplo n.º 11
0
def do_where(virtualenv=False, bare=True):
    """Executes the where functionality."""

    if not virtualenv:
        location = project.pipfile_location

        if not location:
            click.echo('No Pipfile present at project home. Consider running {0} first to automatically generate a Pipfile for you.'.format(crayons.green('`pipenv install`')), err=True)
        elif not bare:
            click.echo('Pipfile found at {0}. Considering this to be the project home.'.format(crayons.green(location)), err=True)
        else:
            click.echo(location)

    else:
        location = project.virtualenv_location

        if not bare:
            click.echo('Virtualenv location: {0}'.format(crayons.green(location)), err=True)
        else:
            click.echo(location)
Exemplo n.º 12
0
def login(username: str, password: str, show_token: bool, one_time: bool, env_name: str):
    if env_name:
        context.set_active_env(env_name)
    env = context.current_env()
    if not one_time:
        click.echo('Logging in to [{0}]...'.format(env.name))
    try:
        token = auth.login(username, password, env.api_url)
    except Exception as ex:
        click.echo(crayons.red(str(ex)), err=True)
        exit(1)
        return

    if not one_time:
        env.set_token(token)
        context.save()

    if show_token or one_time:
        print(token.strip())
    else:
        click.echo(crayons.green('You\'re now logged in as [{0}] in [{1}].'.format(username, env.name)))
Exemplo n.º 13
0
def do_download_dependencies(dev=False, only=False, bare=False):
    """"Executes the download functionality."""

    # Load the Pipfile.
    p = pipfile.load(project.pipfile_location)

    # Load the Pipfile.
    if not bare:
        click.echo(crayons.yellow('Downloading dependencies from Pipfile...'))
    lockfile = json.loads(p.lock())

    # Install default dependencies, always.
    deps = lockfile['default'] if not only else {}

    # Add development deps if --dev was passed.
    if dev:
        deps.update(lockfile['develop'])

    # Convert the deps to pip-compatible arguments.
    deps = convert_deps_to_pip(deps, r=False)

    # Actually install each dependency into the virtualenv.
    name_map = {}
    for package_name in deps:

        if not bare:
            click.echo('Downloading {0}...'.format(crayons.green(package_name)))

        # pip install:
        c = pip_download(package_name)

        if not bare:
            click.echo(crayons.blue(c.out))

        parsed_output = parse_install_output(c.out)
        for filename, name in parsed_output:
            name_map[filename] = name

    return name_map
Exemplo n.º 14
0
def shell(
    three=None,
    python=False,
    fancy=False,
    shell_args=None,
    anyway=False,
    pypi_mirror=None,
):
    """Spawns a shell within the virtualenv."""
    from .core import load_dot_env, do_shell

    # Prevent user from activating nested environments.
    if "PIPENV_ACTIVE" in os.environ:
        # If PIPENV_ACTIVE is set, VIRTUAL_ENV should always be set too.
        venv_name = os.environ.get("VIRTUAL_ENV", "UNKNOWN_VIRTUAL_ENVIRONMENT")
        if not anyway:
            echo(
                "{0} {1} {2}\nNo action taken to avoid nested environments.".format(
                    crayons.normal("Shell for"),
                    crayons.green(venv_name, bold=True),
                    crayons.normal("already activated.", bold=True),
                ),
                err=True,
            )
            sys.exit(1)
    # Load .env file.
    load_dot_env()
    # Use fancy mode for Windows.
    if os.name == "nt":
        fancy = True
    do_shell(
        three=three,
        python=python,
        fancy=fancy,
        shell_args=shell_args,
        pypi_mirror=pypi_mirror,
    )
Exemplo n.º 15
0
def install(package_name=False,
            more_packages=False,
            dev=False,
            three=False,
            system=False,
            lock=False,
            requirements=False):

    # Ensure that virtualenv is available.
    ensure_project(three=three)

    # Allow more than one package to be provided.
    package_names = (package_name, ) + more_packages

    # Install all dependencies, if none was provided.
    if package_name is False:
        click.echo(crayons.yellow(
            'No package provided, installing all dependencies.'),
                   err=True)
        do_init(dev=dev, requirements=requirements, allow_global=system)
        sys.exit(0)

    for package_name in package_names:

        # Proper-case incoming package name (check against API).
        old_name = [k for k in convert_deps_from_pip(package_name).keys()][0]
        try:
            new_name = proper_case(old_name)
        except IOError as e:
            click.echo('{0} {1}'.format(crayons.red('Error: '), e.args[0],
                                        crayons.green(package_name)))
            continue
        package_name = package_name.replace(old_name, new_name)

        click.echo('Installing {0}...'.format(crayons.green(package_name)))

        # pip install:
        c = pip_install(package_name, allow_global=system)
        click.echo(crayons.blue(format_pip_output(c.out)))

        # Ensure that package was successfully installed.
        try:
            assert c.return_code == 0
        except AssertionError:
            click.echo('{0} An error occurred while installing {1}!'.format(
                crayons.red('Error: '), crayons.green(package_name)))
            click.echo(crayons.blue(format_pip_error(c.err)))
            sys.exit(1)

        if dev:
            click.echo('Adding {0} to Pipfile\'s {1}...'.format(
                crayons.green(package_name), crayons.red('[dev-packages]')))
        else:
            click.echo('Adding {0} to Pipfile\'s {1}...'.format(
                crayons.green(package_name), crayons.red('[packages]')))

        # Add the package to the Pipfile.
        project.add_package_to_pipfile(package_name, dev)

        # Ego boost.
        easter_egg(package_name)

        if lock:
            do_lock()
Exemplo n.º 16
0
        sys.exit()
        
    sha="MISSION - PASTE HERE THE SHA256"
    amp_query_params = f"detection_sha256={sha}" 
        
    i_got_it=0
    if i_got_it==0:
        print(cyan(env.get_line(),bold=True))
        print (yellow("Third : Call the correct function with the correct query params "))
        print (yellow("Hint : ")) 
        print (yellow("https://www.base64decode.org/"))  
        print (yellow("Here under the solution :"))
        print (yellow("Change the value of i_got_it to 1 in order to move forward"))
        print (yellow("You can try the following as well :"))
        print (yellow("start a python shell console"))
        print (yellow("import base64"))
        print (yellow("then => m='aG9zdG5hbWVfbGlzdD1nZXRfaG9zdG5hbWVfZnJvbV9zaGEocXVlcnlfcGFyYW1zPWFtcF9xdWVyeV9wYXJhbXMp'"))
        print (yellow("then => func = base64.b64decode(m).decode('utf-8')"))
        print (yellow("then => print(func)"))    
        sys.exit()   
    hostname_list="MISSION CALL THE CORRECT FUNCTION"   
    result=''
    for item in hostname_list:
        if item['computer']['hostname'] not in result:
            result+=item['computer']['hostname']+'\n'
    computers_path = repository_root / "resulting.json"
    print()
    print(yellow("Infected endpoint hostname list :"))
    print(green(result,bold=True))
    print(green("======================="))
Exemplo n.º 17
0
def cli(ctx,
        where=False,
        venv=False,
        rm=False,
        bare=False,
        three=False,
        python=False,
        help=False,
        update=False,
        jumbotron=False,
        py=False,
        site_packages=False,
        envs=False,
        man=False,
        completion=False):
    from . import core

    if jumbotron:
        # Awesome sauce.
        click.echo(crayons.normal(xyzzy, bold=True))

    if not update:
        if core.need_update_check():
            # Spun off in background thread, not unlike magic.
            core.check_for_updates()
    else:
        # Update pip to latest version.
        core.ensure_latest_pip()

        # Upgrade self to latest version.
        core.ensure_latest_self()

        sys.exit()

    if completion:
        if PIPENV_SHELL:
            os.environ['_PIPENV_COMPLETE'] = 'source-{0}'.format(
                PIPENV_SHELL.split(os.sep)[-1])
        else:
            click.echo('Please ensure that the {0} environment variable '
                       'is set.'.format(crayons.normal('SHELL', bold=True)),
                       err=True)
            sys.exit(1)

        c = delegator.run('pipenv')
        click.echo(c.out)
        sys.exit(0)

    if man:
        if core.system_which('man'):
            path = os.sep.join([os.path.dirname(__file__), 'pipenv.1'])
            os.execle(core.system_which('man'), 'man', path, os.environ)
        else:
            click.echo('man does not appear to be available on your system.',
                       err=True)

    if envs:
        click.echo(
            'The following environment variables can be set, to do various things:\n'
        )
        for key in environments.__dict__:
            if key.startswith('PIPENV'):
                click.echo('  - {0}'.format(crayons.normal(key, bold=True)))

        click.echo('\nYou can learn more at:\n   {0}'.format(
            crayons.green(
                'http://docs.pipenv.org/advanced.html#configuration-with-environment-variables'
            )))
        sys.exit(0)

    core.warn_in_virtualenv()

    if ctx.invoked_subcommand is None:
        # --where was passed...
        if where:
            core.do_where(bare=True)
            sys.exit(0)

        elif py:
            core.do_py()
            sys.exit()

        # --venv was passed...
        elif venv:
            # There is no virtualenv yet.
            if not core.project.virtualenv_exists:
                click.echo(crayons.red(
                    'No virtualenv has been created for this project yet!'),
                           err=True)
                sys.exit(1)
            else:
                click.echo(core.project.virtualenv_location)
                sys.exit(0)

        # --rm was passed...
        elif rm:
            # Abort if --system (or running in a virtualenv).
            if PIPENV_USE_SYSTEM:
                click.echo(
                    crayons.red(
                        'You are attempting to remove a virtualenv that '
                        'Pipenv did not create. Aborting.'))
                sys.exit(1)
            if core.project.virtualenv_exists:
                loc = core.project.virtualenv_location
                click.echo(
                    crayons.normal(u'{0} ({1})…'.format(
                        crayons.normal('Removing virtualenv', bold=True),
                        crayons.green(loc))))

                with core.spinner():
                    # Remove the virtualenv.
                    core.cleanup_virtualenv(bare=True)
                sys.exit(0)
            else:
                click.echo(crayons.red(
                    'No virtualenv has been created for this project yet!',
                    bold=True),
                           err=True)
                sys.exit(1)

    # --two / --three was passed...
    if (python or three is not None) or site_packages:
        core.ensure_project(three=three,
                            python=python,
                            warn=True,
                            site_packages=site_packages)

    # Check this again before exiting for empty ``pipenv`` command.
    elif ctx.invoked_subcommand is None:
        # Display help to user, if no commands were passed.
        click.echo(core.format_help(ctx.get_help()))
Exemplo n.º 18
0
def report_git_pull(repo):
    colored_repo = crayons.green(repo, bold=True)
    print(MESSAGE_PULLING_REPO.format(colored_repo))
Exemplo n.º 19
0
def format_pip_error(error):
    error = error.replace('Expected', str(crayons.green('Expected', bold=True)))
    error = error.replace('Got', str(crayons.red('Got', bold=True)))
    error = error.replace('THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE', str(crayons.red('THESE PACKAGES DO NOT MATCH THE HASHES FROM Pipfile.lock!', bold=True)))
    error = error.replace('someone may have tampered with them', str(crayons.red('someone may have tampered with them')))
    return error
Exemplo n.º 20
0
def report_full_run(file_count):
    figure = crayons.green(str(file_count), bold=True)
    message = MESSAGE_TEMPLATED_ALL.format(figure)
    print(_format_single(message, file_count))
Exemplo n.º 21
0
def report_info_message(message):
    print(crayons.white("Info: ") + crayons.green(message))
Exemplo n.º 22
0
import pygame
import crayons

if __name__ == '__main__':

    pygame.font.init()

    pygame.init()

    print(crayons.green('Initialized PyGame'))

    from gui.app import App

    app = App()

    app.start()
Exemplo n.º 23
0
	}
	login_success = login(api_session, login_request_data)

	# If the login was successful
	if login_success:

		# Get all the tenants
		tenants_content = get_tenants(api_session)

		# If managed to get the list of tenants
		if tenants_content:

			# Store the tenants (domains) IDs as a variable to use later
			tenant_list = json.loads(tenants_content)["data"]
			# TODO: Print all the tenants IDs returned and find the one you need.
			print(green(f'Found all the following tenants: {tenant_list}'))
			SMC_TENANT_ID = tenant_list[0]['id']

			# Print the SMC Tenant ID selected
			print(f'Working on Tenant ID is: {SMC_TENANT_ID}')
			
			# Get all hosts with abnormally high traffic
			time_window = 60
			query_search_id = get_security_events(time_window)

			# If successfully created a search query 
			if query_search_id:

				print(f"\n==> Created query looking for all the hosts that generate high amount of traffic in the last {time_window} minutes.")
				print("Generating results. Please wait...")
Exemplo n.º 24
0
tickers = ['btc', 'eth']
exchange_tickers = tickers + ['usd']
ticker_to_coin = {'btc': 'bitcoin', 'eth': 'ethereum'}
coins = [ticker_to_coin[ticker] for ticker in tickers]
session = requests.Session()

if __name__ == '__main__':
    conn = sqlite3.connect('/v/filer5b/v38q001/maynard/hackrice/prices.db')

    master_df = pandas.DataFrame()

    print(crayons.yellow('Scraping coins {}...'.format(coins)))

    for ticker, coin in [(ticker, ticker_to_coin[ticker])
                         for ticker in tickers]:
        print(crayons.green('Scraping {}'.format(coin)))

        url = 'https://coinmarketcap.com/currencies/{}/#markets'.format(coin)

        r = session.get(url)
        html = pq(pq(r.content)('table')[0]).html()
        df = pandas.read_html('<table>{}</table>'.format(html), index_col=0)
        df = pandas.concat(df)

        df = df.filter(items=['Pair', 'Source', 'Price'])
        df = df.loc[df['Source'].isin(trusted_exchanges)]
        df['Price'] = df['Price'].map(
            lambda price_str: float(price_str[price_str.index('$') + 1:]))

        exchange_pairs = [
            '{}/{}'.format(ticker.upper(), to_ticker.upper())
Exemplo n.º 25
0
Arquivo: cli.py Projeto: sseg/pipenv
def uninstall(package_name=False,
              more_packages=False,
              three=None,
              python=False,
              system=False,
              lock=False,
              no_hashes=False,
              dev=False,
              all=False):
    # Ensure that virtualenv is available.
    ensure_project(three=three, python=python)

    package_names = (package_name, ) + more_packages
    pipfile_remove = True

    # Un-install all dependencies, if --all was provided.
    if all is True:
        if not dev:
            click.echo(
                crayons.yellow(
                    'Un-installing all packages from virtualenv...'))
            do_purge(allow_global=system)
            sys.exit(0)

    # Uninstall [dev-packages], if --dev was provided.
    if dev:
        if 'dev-packages' in project.parsed_pipfile:
            click.echo(
                crayons.yellow('Un-installing {0}...'.format(
                    crayons.red('[dev-packages]'))))
            package_names = project.parsed_pipfile['dev-packages']
            pipfile_remove = False
        else:
            click.echo(
                crayons.yellow('No {0} to uninstall.'.format(
                    crayons.red('[dev-packages]'))))
            sys.exit(0)

    if package_name is False and not dev:
        click.echo(crayons.red('No package provided!'))
        sys.exit(1)

    for package_name in package_names:

        click.echo('Un-installing {0}...'.format(crayons.green(package_name)))

        c = delegator.run('"{0}" uninstall {1} -y'.format(
            which_pip(allow_global=system), package_name))
        click.echo(crayons.blue(c.out))

        if pipfile_remove:
            if dev:
                click.echo('Removing {0} from Pipfile\'s {1}...'.format(
                    crayons.green(package_name),
                    crayons.red('[dev-packages]')))
            else:
                click.echo('Removing {0} from Pipfile\'s {1}...'.format(
                    crayons.green(package_name), crayons.red('[packages]')))

            project.remove_package_from_pipfile(package_name, dev)

    if lock:
        do_lock(no_hashes=no_hashes)
Exemplo n.º 26
0
def cli(
    ctx,
    where=False,
    venv=False,
    rm=False,
    bare=False,
    three=False,
    python=False,
    help=False,
    py=False,
    site_packages=False,
    envs=False,
    man=False,
    completion=False,
    pypi_mirror=None,
    support=None,
    clear=False,
):
    # Handle this ASAP to make shell startup fast.
    if completion:
        from . import shells

        try:
            shell = shells.detect_info()[0]
        except shells.ShellDetectionFailure:
            echo(
                "Fail to detect shell. Please provide the {0} environment "
                "variable.".format(crayons.normal("PIPENV_SHELL", bold=True)),
                err=True,
            )
            sys.exit(1)
        print(click_completion.get_code(shell=shell, prog_name="pipenv"))
        sys.exit(0)

    from .core import (
        system_which,
        do_py,
        warn_in_virtualenv,
        do_where,
        project,
        spinner,
        cleanup_virtualenv,
        ensure_project,
        format_help,
        do_clear,
    )

    if man:
        if system_which("man"):
            path = os.sep.join([os.path.dirname(__file__), "pipenv.1"])
            os.execle(system_which("man"), "man", path, os.environ)
        else:
            echo("man does not appear to be available on your system.", err=True)
    if envs:
        echo("The following environment variables can be set, to do various things:\n")
        for key in environments.__dict__:
            if key.startswith("PIPENV"):
                echo("  - {0}".format(crayons.normal(key, bold=True)))
        echo(
            "\nYou can learn more at:\n   {0}".format(
                crayons.green(
                    "http://docs.pipenv.org/advanced/#configuration-with-environment-variables"
                )
            )
        )
        sys.exit(0)
    warn_in_virtualenv()
    if ctx.invoked_subcommand is None:
        # --where was passed…
        if where:
            do_where(bare=True)
            sys.exit(0)
        elif py:
            do_py()
            sys.exit()
        # --support was passed…
        elif support:
            from .help import get_pipenv_diagnostics

            get_pipenv_diagnostics()
            sys.exit(0)
        # --clear was passed…
        elif clear:
            do_clear()
            sys.exit(0)

        # --venv was passed…
        elif venv:
            # There is no virtualenv yet.
            if not project.virtualenv_exists:
                echo(
                    crayons.red("No virtualenv has been created for this project yet!"),
                    err=True,
                )
                sys.exit(1)
            else:
                echo(project.virtualenv_location)
                sys.exit(0)
        # --rm was passed…
        elif rm:
            # Abort if --system (or running in a virtualenv).
            if environments.PIPENV_USE_SYSTEM:
                echo(
                    crayons.red(
                        "You are attempting to remove a virtualenv that "
                        "Pipenv did not create. Aborting."
                    )
                )
                sys.exit(1)
            if project.virtualenv_exists:
                loc = project.virtualenv_location
                echo(
                    crayons.normal(
                        u"{0} ({1})…".format(
                            crayons.normal("Removing virtualenv", bold=True),
                            crayons.green(loc),
                        )
                    )
                )
                with spinner():
                    # Remove the virtualenv.
                    cleanup_virtualenv(bare=True)
                sys.exit(0)
            else:
                echo(
                    crayons.red(
                        "No virtualenv has been created for this project yet!",
                        bold=True,
                    ),
                    err=True,
                )
                sys.exit(1)
    # --two / --three was passed…
    if (python or three is not None) or site_packages:
        ensure_project(
            three=three,
            python=python,
            warn=True,
            site_packages=site_packages,
            pypi_mirror=pypi_mirror,
            clear=clear,
        )
    # Check this again before exiting for empty ``pipenv`` command.
    elif ctx.invoked_subcommand is None:
        # Display help to user, if no commands were passed.
        echo(format_help(ctx.get_help()))
Exemplo n.º 27
0
def update(
    ctx,
    three=None,
    python=False,
    pypi_mirror=None,
    system=False,
    verbose=False,
    clear=False,
    keep_outdated=False,
    pre=False,
    dev=False,
    bare=False,
    sequential=False,
    package=None,
    dry_run=None,
    outdated=False,
    more_packages=None,
):
    from .core import (
        ensure_project,
        do_outdated,
        do_lock,
        do_sync,
        project,
    )

    ensure_project(three=three, python=python, warn=True, pypi_mirror=pypi_mirror)
    if not outdated:
        outdated = bool(dry_run)
    if outdated:
        do_outdated(pypi_mirror=pypi_mirror)
    if not package:
        echo(
            "{0} {1} {2} {3}{4}".format(
                crayons.white("Running", bold=True),
                crayons.red("$ pipenv lock", bold=True),
                crayons.white("then", bold=True),
                crayons.red("$ pipenv sync", bold=True),
                crayons.white(".", bold=True),
            )
        )
    else:
        for package in [package] + list(more_packages) or []:
            if package not in project.all_packages:
                echo(
                    "{0}: {1} was not found in your Pipfile! Aborting."
                    "".format(
                        crayons.red("Warning", bold=True),
                        crayons.green(package, bold=True),
                    ),
                    err=True,
                )
                sys.exit(1)
    do_lock(
        verbose=verbose,
        clear=clear,
        pre=pre,
        keep_outdated=keep_outdated,
        pypi_mirror=pypi_mirror,
    )
    do_sync(
        ctx=ctx,
        dev=dev,
        three=three,
        python=python,
        bare=bare,
        dont_upgrade=False,
        user=False,
        verbose=verbose,
        clear=clear,
        unused=False,
        sequential=sequential,
        pypi_mirror=pypi_mirror,
    )
Exemplo n.º 28
0
def cli(ctx, where=False, venv=False, rm=False, bare=False, three=False, python=False, help=False):

    if ctx.invoked_subcommand is None:
        # --where was passed...
        if where:
            do_where(bare=bare)
            sys.exit(0)

        # --venv was passed...
        elif venv:

            with spinner():
                loc = project.virtualenv_location

            # There is no virtualenv yet.
            if not project.virtualenv_exists:
                click.echo(crayons.red('No virtualenv has been created for this project yet!'), err=True)
                sys.exit(1)
            else:
                click.echo(project.virtualenv_location)
                sys.exit(0)

        # --rm was passed...
        elif rm:

            with spinner():
                loc = project.virtualenv_location

            if project.virtualenv_exists:
                click.echo(crayons.yellow('{0} ({1})...'.format(crayons.yellow('Removing virtualenv'), crayons.green(loc))))
                with spinner():
                    # Remove the virtualenv.
                    shutil.rmtree(project.virtualenv_location)
                sys.exit(0)
            else:
                click.echo(crayons.red('No virtualenv has been created for this project yet!'), err=True)
                sys.exit(1)

        # --two / --three was passed...
        if python or three is not None:
            ensure_project(three=three, python=python)

        else:
            # Display help to user, if no commands were passed.
            click.echo(format_help(ctx.get_help()))
Exemplo n.º 29
0
def run_solver(screen_shot):
    os.system("clear")
    
    if IDENTIFIER not in screen_shot:
        print(crayons.yellow("No screen shot found"))
        return
    
    time.sleep(0.1)
    start = screen_shot.index("Screen Shot")
    end = screen_shot.index("png")
    screen_shot = screen_shot[start:end+3]

    # step 1: image pre-processing and OCR recognition
    file_path = os.path.join(SCREEN_DIR, screen_shot)
    # print file_path
    # print screen_shot
    screen = process_image(Image.open(file_path))
    # screen.save(SCREEN_DIR + "/test.png")

    result = pytesseract.image_to_string(
        screen, config="load_system_dawg=0 load_freq_dawg=0")
    result = unicodedata.normalize('NFKD', result)

    # step 2: Parse up the question and answer options
    parts = result.lower().split("\n")
    parts = filter(None, parts)
    ind = map(lambda word:"?" in word, parts).index(True)
    question = " ".join(parts[:ind+1]).replace("\n", " ")
    options = parts[ind+1:]
    

    negation_flag = len(set(question.split(" ")).intersection(NEGATION)) > 0

    # query terms: question less stop words
    q_terms = filter(lambda t: t not in STOPWORDS and len(t) > 2, question.split(" "))
    joined_q_terms = " ".join(q_terms)
    # print "joined_q_terms", joined_q_terms

    # step 3: do google search with 3 separate approaches
    answer_results = search(question, options, joined_q_terms)
    

    # step 4: printing the results
    print("\n{}\n\n{}\n\n".format(
        crayons.blue(question),
        crayons.blue(", ".join(options)),
    ))

    
    if sum(answer_results['count'].itervalues()) > 0:
        if 'what' in question:
            print color.BOLD + "Good for 'what' type question\n" + color.END
        else:
            print(crayons.green("Good for 'what' type question\n"))
        for key,value in sorted(answer_results['count'].iteritems(), key=lambda (k,v): (v,k), reverse=True):
            print(crayons.green(key +":"+ str(value)))

    
    if sum(answer_results['scope'].itervalues()) > 0:
        if 'which' in question:
            print color.BOLD + "\nGood for 'which' or selection type question\n" + color.END
        else:
            print(crayons.red("\nGood for 'which' or selection type question\n"))
        for key,value in sorted(answer_results['scope'].iteritems(), key=lambda (k,v): (v,k), reverse=True):
            print(crayons.red(key +":"+ str(value)))

    
    if sum(answer_results['tfscore'].itervalues()) > 0:
        print(crayons.yellow("\nTerm Frequency excluding question prompt search (cleared the celebrity effect)\n"))
        for key,value in sorted(answer_results['tfscore'].iteritems(), key=lambda (k,v): (v,k), reverse=True):
            print(crayons.yellow(key +":"+ str(value)))

    print(crayons.blue("\nNEGATION_FLAG" if negation_flag == 1 else ""))

    if not DEBUG:
        os.rename(file_path, file_path.replace("Screen Shot", "Done"))
'''
    List rooms of the Webex Team Bot
'''
import requests
import json
from crayons import green

BOT_ACCESS_TOKEN = 'PUT HERE THE WEBEX TEAM BOT BEARER TOKEN'

URL = f'https://webexapis.com/v1/rooms'
headers = {'Authorization': 'Bearer ' + BOT_ACCESS_TOKEN,
           'Content-type': 'application/json;charset=utf-8'}
response = requests.get(URL, headers=headers)
#print(type(response))
if response.status_code == 200:
    print(json.dumps(response.json(),sort_keys=True,indent=4, separators=(',', ': ')))
    #result=json.dumps(response.json())
    result=response.json()
    the_id=result['items'][0]['id']
    print(green(the_id))
else:
    # Oops something went wrong...  Better do something about it.
    print(response.status_code, response.text)
Exemplo n.º 31
0
def report_templating(source_file, destination_file):
    print(
        MESSAGE_TEMPLATING.format(crayons.yellow(source_file),
                                  crayons.green(destination_file)))
Exemplo n.º 32
0
    def go(self):

        while not self.queue.empty():
            try:
                job: LocalJob = self.queue.get()
                oinput = job.profile.input_options.as_shell_params()
                ooutput = job.profile.output_options.as_shell_params()

                fls = False
                if is_mounted(job.inpath) and self.config.fls_path():
                    # lets write output to local storage, for efficiency
                    outpath = PurePath(
                        self.config.fls_path(),
                        job.inpath.with_suffix(job.profile.extension).name)
                    fls = True
                else:
                    outpath = job.inpath.with_suffix(job.profile.extension +
                                                     '.tmp')

                #
                # check if we need to exclude any streams
                #
                if job.info.is_multistream(
                ) and self.config.automap and job.profile.automap:
                    ooutput = ooutput + job.info.ffmpeg_streams(job.profile)
                cli = [
                    '-y', *oinput, '-i',
                    str(job.inpath), *ooutput,
                    str(outpath)
                ]

                #
                # display useful information
                #
                self.lock.acquire(
                )  # used to synchronize threads so multiple threads don't create a jumble of output
                try:
                    print('-' * 40)
                    print('Filename : ' +
                          crayons.green(os.path.basename(str(job.inpath))))
                    print(f'Profile  : {job.profile.name}')
                    print('ffmpeg   : ' + ' '.join(cli) + '\n')
                finally:
                    self.lock.release()

                if pytranscoder.dry_run:
                    continue

                basename = job.inpath.name

                def log_callback(stats):
                    pct_done, pct_comp = calculate_progress(job.info, stats)
                    self.log(
                        f'{basename}: speed: {stats["speed"]}x, comp: {pct_comp}%, done: {pct_done:3}%'
                    )
                    if job.profile.threshold_check < 100:
                        if pct_done >= job.profile.threshold_check and pct_comp < job.profile.threshold:
                            # compression goal (threshold) not met, kill the job and waste no more time...
                            self.log(
                                f'Encoding of {basename} cancelled and skipped due to threshold not met'
                            )
                            return True
                    # continue
                    return False

                job_start = datetime.datetime.now()
                code = self.ffmpeg.run(cli, log_callback)
                job_stop = datetime.datetime.now()
                elapsed = job_stop - job_start

                if code == 0:
                    if not filter_threshold(job.profile, str(job.inpath),
                                            outpath):
                        # oops, this transcode didn't do so well, lets keep the original and scrap this attempt
                        self.log(
                            f'Transcoded file {job.inpath} did not meet minimum savings threshold, skipped'
                        )
                        self.complete(job.inpath,
                                      (job_stop - job_start).seconds)
                        os.unlink(str(outpath))
                        continue

                    self.complete(job.inpath, elapsed.seconds)
                    if not pytranscoder.keep_source:
                        if pytranscoder.verbose:
                            self.log(f'replacing {job.inpath} with {outpath}')
                        job.inpath.unlink()

                        if fls:
                            shutil.move(
                                outpath,
                                job.inpath.with_suffix(job.profile.extension))
                        else:
                            outpath.rename(
                                job.inpath.with_suffix(job.profile.extension))

                        self.log(crayons.green(f'Finished {job.inpath}'))
                    else:
                        self.log(
                            crayons.yellow(
                                f'Finished {outpath}, original file unchanged')
                        )
                elif code is not None:
                    self.log(
                        f' Did not complete normally: {self.ffmpeg.last_command}'
                    )
                    self.log(f'Output can be found in {self.ffmpeg.log_path}')
                    try:
                        outpath.unlink()
                    except:
                        pass
            finally:
                self.queue.task_done()
Exemplo n.º 33
0
def report_partial_run(file_count, total):
    figure = crayons.green(str(file_count), bold=True)
    total_figure = crayons.yellow(str(total), bold=True)
    message = MESSAGE_REPORT.format(figure, total_figure)
    print(_format_single(message, total))
Exemplo n.º 34
0
from __future__ import absolute_import

import os
import sys
import time
import crayons

STREAM = sys.stderr

MILL_TEMPLATE = '%s %s %i/%i\r'

DOTS_CHAR = '.'

if os.name != 'nt':
    BAR_FILLED_CHAR = str(crayons.green('▉', bold=True))
    BAR_EMPTY_CHAR = str(crayons.black('▉'))
else:
    BAR_FILLED_CHAR = '='
    BAR_EMPTY_CHAR = '-'

if (sys.version_info[0] >= 3) and (os.name != 'nt'):
    BAR_TEMPLATE = u'  %s%s%s %i/%i — {0}\r'.format(crayons.black('%s'))
else:
    if os.name == 'nt':
        BAR_TEMPLATE = '  %s%s%s %i/%i - %s\r'
    else:
        BAR_TEMPLATE = '  %s%s%s %i/%i — %s\r'

MILL_CHARS = ['|', '/', '-', '\\']
Exemplo n.º 35
0
def report_up_to_date():
    print(crayons.green(MESSAGE_UP_TO_DATE, bold=True))
Exemplo n.º 36
0
# print 'red string' in red
print(crayons.red('red string'))

# Red White and Blue text
print('{} white {}'.format(crayons.red('red'), crayons.blue('blue')))

crayons.disable()  # disables the crayons package
print('{} white {}'.format(crayons.red('red'), crayons.blue('blue')))

crayons.DISABLE_COLOR = False  # enable the crayons package

# This line will print in color because color is enabled
print('{} white {}'.format(crayons.red('red'), crayons.blue('blue')))

# print 'red string' in red
print(crayons.red('red string', bold=True))

# print 'yellow string' in yellow
print(crayons.yellow('yellow string', bold=True))

# print 'magenta string' in magenta
print(crayons.magenta('magenta string', bold=True))

# print 'white string' in white
print(crayons.white('white string', bold=True))

# print my name in two colors
print(
    crayons.green('Jeremiah ', bold=True) + crayons.blue('McAtee', bold=True))
Exemplo n.º 37
0
def report_git_clone(repo):
    colored_repo = crayons.green(repo, bold=True)
    print(MESSAGE_CLONING_REPO.format(colored_repo))
import sys
import time

import crayons

from .environments import PIPENV_COLORBLIND, PIPENV_HIDE_EMOJIS

STREAM = sys.stderr
MILL_TEMPLATE = "%s %s %i/%i\r"
DOTS_CHAR = "."
if PIPENV_HIDE_EMOJIS:
    if PIPENV_COLORBLIND:
        BAR_FILLED_CHAR = "="
        BAR_EMPTY_CHAR = "-"
    else:
        BAR_FILLED_CHAR = str(crayons.green("=", bold=True))
        BAR_EMPTY_CHAR = str(crayons.black("-"))
else:
    if PIPENV_COLORBLIND:
        BAR_FILLED_CHAR = "▉"
        BAR_EMPTY_CHAR = " "
    else:
        BAR_FILLED_CHAR = str(crayons.green("▉", bold=True))
        BAR_EMPTY_CHAR = str(crayons.black("▉"))

if (sys.version_info[0] >= 3) and (os.name != "nt"):
    BAR_TEMPLATE = u"  %s%s%s %i/%i — {0}\r".format(crayons.black("%s"))
else:
    if os.name == "nt":
        BAR_TEMPLATE = "  %s%s%s %i/%i - %s\r"
    else:
Exemplo n.º 39
0
securityzones = fmc_get("object/securityzones")
for item in securityzones['items']:
    if item['name'] == 'INSIDE':
        IN_zone_id = item['id']


print(json.dumps(securityzones,indent=4, sort_keys=True))

for item in securityzones['items']:
    if item['name'] == 'OUTSIDE':
        OU_zone_id = item['id']
        print(OU_zone_id)

print(
    green('Policy Created:'),
    pformat(access_policy),
    sep="\n",
)
# Create an Access Rule in the new policy
print(blue("\n==> Creating an Access Rule in the new policy"))
access_rule = {
  "sourceZones": {
    "objects": [
      {
        "name": "INSIDE",
        "id": IN_zone_id, #"037f5838-6412-11e8-a51d-e68d36fe956d",
        "type": "SecurityZone"
      }
    ]
  },
Exemplo n.º 40
0
def add(package_line, editable=False, dev=False, dont_install=False):
    # create requirements
    # init()
    if editable:
        click.secho("Installing {0} in editable mode...".format(
            crayons.yellow(package_line)))
    else:
        click.secho("Installing {0}...".format(crayons.yellow(package_line)))

    could_be_github = parse.parse("{:w}/{:w}#{:w}",
                                  package_line) or parse.parse(
                                      "{:w}/{:w}", package_line)
    if could_be_github:
        git_url = resolve_git_shortcut(package_line)
        click.secho("{0} resolved as {1}".format(crayons.yellow(package_line),
                                                 crayons.green(git_url)))
        package_line = git_url

    # req = Req.parse(package_line)
    # logger.debug("{}".format(req.__dict__))

    # if editable:
    #     req = Requirement.parse_editable(package_line)
    # else:
    #     req = Requirement.parse_line(package_line)

    if editable:
        req = overrides.SmartRequirement.from_editable(package_line)
    else:
        req = overrides.SmartRequirement.from_line(package_line)

    # click.echo(req.__dict__)

    logger.debug("Requirement parsed: {}".format(req.__dict__))

    has_specs = len(req.specs) > 0
    is_vcs = req.vcs
    is_local_file = req.local_file
    is_editable = req.editable

    if is_vcs:
        is_editable = True

    # if is_vcs and (not is_editable):
    #     # print("Make sure ")
    #     req.editable = True
    #     package_line = "-e {0}".format(package_line)

    if is_vcs and (not req.name):
        click.secho("Make sure to add #egg=<name> to your url", fg="red")
        return

    with click_spinner.spinner():
        c = pip_install(package_line,
                        editable=is_editable,
                        allow_global=False,
                        block=True)

    # counter = 0
    # with click.progressbar(length=10) as bar:
    #     while time.sleep(0.5):
    #         counter = max(counter + 1, 10)
    #         bar.update(counter)
    #         if not (c.blocking == None):
    #             click.echo("Return code is:" + c.return_code)
    #             bar.update(10)
    #             break
    # result = parse.search("Successfully installed {} \n", c.out)

    if not (c.return_code == 0):
        click.secho(c.err, fg="red")
        click.echo(
            crayons.red("Failed to install ") + crayons.yellow(req.name) +
            crayons.red(" ✗")
            # "Package {0} removed ✓".format(req.name), fg="green"
        )
        sys.exit()
    else:
        click.secho(c.out.rstrip(), fg="blue")

        click.echo(
            crayons.green("Package ") + crayons.yellow(req.name) +
            crayons.green(" installed ✓")
            # crayons.green("Package {0} installed ✓".format(crayons.yellow(req.name)))
        )

    result = parse.search("Successfully installed {}\n", c.out)
    succesfully_installed = result.fixed[0].split() if result else []
    succesfully_installed = [
        item.rsplit('-', 1)[0] for item in succesfully_installed
    ]
    existing_packages = [
        result.fixed[0] for result in parse.findall(
            "Requirement already satisfied: {} in", c.out)
    ]

    all_pkgs = succesfully_installed + existing_packages
    all_pkgs = [Req.parse(pkg).unsafe_name for pkg in all_pkgs]

    # click.secho("Locking requirements...")

    frozen_deps = pip_freeze()
    frozen_dep = next(
        filter(lambda x: x.name.lower() == req.name.lower(), frozen_deps),
        None)
    project.update_frozen_dependencies_in_piper_lock(frozen_deps)

    dependency = {
        "name": frozen_dep.name,
        # "line": req.line if ((not req.vcs) and (not req.local_file) and req.specs) else frozen_dep.line.replace("==",">="),
        "line": frozen_dep.line.replace("==", ">="),
        "specs": frozen_dep.specs,
        "dependencies":
        [pkg for pkg in all_pkgs if not (pkg == frozen_dep.name)]
    }
    project.add_dependency_to_piper_lock(dependency, dev=dev)
    project.update_requirement_files_from_piper_lock()

    click.secho("Requirements locked ✓", fg="green")

    # click.echo("All pkgs: {}".format(all_pkgs))

    # click.secho("Updating requirement files...")

    # if (not req.vcs) and (not req.local_file) and req.specs:
    #     add_to_requirements_file(req, os.path.join(".", "requirements", "dev.txt"))
    # else:
    #     add_to_requirements_file(frozen_dep, os.path.join(".", "requirements", "dev.txt"))
    # add_to_requirements_lockfile(frozen_deps, os.path.join(".", "requirements", "base-locked.txt"))

    click.secho("Requirements updated ✓", fg="green")
    # compile_requirements(os.path.join(".", "requirements", "base.txt"), os.path.join(".", "requirements", "base-locked.txt"))

    # print(req.__dict__)

    click.echo(
        crayons.green(
            emoji.emojize("\n:sparkles:  Adding package complete",
                          use_aliases=True)))
Exemplo n.º 41
0
Arquivo: cli.py Projeto: sseg/pipenv
def install(package_name=False,
            more_packages=False,
            dev=False,
            three=False,
            python=False,
            system=False,
            lock=False,
            no_hashes=False,
            ignore_hashes=False,
            ignore_pipfile=False):

    # Ensure that virtualenv is available.
    ensure_project(three=three, python=python)

    # Allow more than one package to be provided.
    package_names = (package_name, ) + more_packages

    # Install all dependencies, if none was provided.
    if package_name is False:
        click.echo(crayons.yellow(
            'No package provided, installing all dependencies.'),
                   err=True)
        do_init(dev=dev,
                allow_global=system,
                ignore_hashes=ignore_hashes,
                ignore_pipfile=ignore_pipfile)
        sys.exit(0)

    for package_name in package_names:
        click.echo('Installing {0}...'.format(crayons.green(package_name)))

        # pip install:
        with spinner():
            c = pip_install(package_name,
                            ignore_hashes=True,
                            allow_global=system)

        click.echo(crayons.blue(format_pip_output(c.out)))

        # TODO: This
        # Ensure that package was successfully installed.
        try:
            assert c.return_code == 0
        except AssertionError:
            click.echo('{0} An error occurred while installing {1}!'.format(
                crayons.red('Error: '), crayons.green(package_name)))
            click.echo(crayons.blue(format_pip_error(c.err)))
            sys.exit(1)

        if dev:
            click.echo('Adding {0} to Pipfile\'s {1}...'.format(
                crayons.green(package_name), crayons.red('[dev-packages]')))
        else:
            click.echo('Adding {0} to Pipfile\'s {1}...'.format(
                crayons.green(package_name), crayons.red('[packages]')))

        # Add the package to the Pipfile.
        try:
            project.add_package_to_pipfile(package_name, dev)
        except ValueError as e:
            click.echo('{0} {1}'.format(
                crayons.red('ERROR (PACKAGE NOT INSTALLED):'), e))

        # Ego boost.
        easter_egg(package_name)

    if lock:
        do_lock(no_hashes=no_hashes)
Exemplo n.º 42
0
def install(dev=False, force_lockfile=False):
    # should run project setup

    virtualenv_exists = project.virtualenv_dir.exists()
    piper_lock_exists = project.piper_lock_dir.exists()
    piper_file_exists = project.piper_file_dir.exists()
    dev_locked_txt_exists = project.requirements_file(
        "dev-locked.txt").exists()
    base_locked_txt_exists = project.requirements_file(
        "base-locked.txt").exists()
    dev_txt_exists = project.requirements_file("dev.txt").exists()
    base_txt_exists = project.requirements_file("base.txt").exists()

    project.setup(noinput=True)

    # first choice piper.json
    # second choice requirements

    packages = None

    if piper_lock_exists:
        click.echo("Installing from the piper lock file")
        packages = [
            item[1]["line"]
            for item in project.piper_lock["frozen_deps"].items()
        ]
    else:
        click.secho("Piper lock doesn't exist. Using next best option...",
                    fg="yellow")

    if piper_file_exists and (packages == None):
        click.echo("Installing from the piper file piper.json")
        packages = [x[1] for x in project.piper_file["dependencies"].items()]
        if dev:
            packages += [
                x[1] for x in project.piper_file["dev_dependencies"].items()
            ]

    elif (packages == None):
        click.secho("No piper.json file. Using next best option...",
                    fg="yellow")

    if dev:
        if dev_locked_txt_exists and (packages == None):
            click.echo("Installing from requirements/dev-locked.txt")
            packages = [
                item.line for item in get_packages_from_requirements_file(
                    project.requirements_file("dev-locked.txt"))
            ]
        if dev_txt_exists and (packages == None):
            click.echo("Installing from requirements/dev.txt")
            packages = [
                item.line for item in get_packages_from_requirements_file(
                    project.requirements_file("dev.txt"))
            ]

    if base_locked_txt_exists and (packages == None):
        click.echo("Installing from requirements/base-locked.txt")
        packages = [
            item.line for item in get_packages_from_requirements_file(
                project.requirements_file("base-locked.txt"))
        ]
    if base_txt_exists and (packages == None):
        click.echo("Installing from requirements/base.txt")
        packages = [
            item.line for item in get_packages_from_requirements_file(
                project.requirements_file("base.txt"))
        ]

    if packages == []:
        click.secho("No installable packages found", fg="red")
        sys.exit(0)

    if packages == None:
        click.echo(
            crayons.red(
                "No available files to install packages from. Please run ") +
            crayons.yellow("piper init"))
        sys.exit()

    # if dev:
    #     packages = get_packages_from_requirements_file(project.requirements_file("dev-locked.txt"))
    # else:
    #     packages = get_packages_from_requirements_file(project.requirements_file("base-locked.txt"))

    c = pip_install_list(packages)
    click.secho(c.out, fg="blue")

    tree = get_dependency_tree()

    if piper_lock_exists:
        pass
    elif piper_file_exists:
        project.update_piper_lock_from_piper_file_and_tree(tree)
        frozen_deps = pip_freeze()
        # frozen_dep = next(filter(lambda x: x.name.lower() == req.name.lower(), frozen_deps), None)
        project.update_frozen_dependencies_in_piper_lock(frozen_deps)
    else:
        # for node in tree:
        #     if node["package"]["package_name"].lower() in packages:
        #         project.add_dependency_to_piper_lock({
        #             "dependencies": [dep["package_name"] for dep in node["dependencies"]],
        #             "line":
        #         })
        for package_line in packages:
            editable = False
            if package_line.startswith("-e "):
                editable = True
                package_line.replace("-e ", "")

            if editable:
                req = overrides.SmartRequirement.from_editable(package_line)
            else:
                req = overrides.SmartRequirement.from_line(package_line)

            found = [
                node["dependencies"] for node in tree if
                (node["package"]["package_name"].lower() == req.name.lower())
            ]
            if not found:
                continue

            found = found[0]
            dependency = {
                "name": req.name,
                "line": req.line,
                "dependencies":
                [item["package_name"].lower() for item in found]
            }
            project.add_dependency_to_piper_lock(dependency, dev=False)

    # cmds = pip_install_list(packages)
    # for cmd in cmds:
    #     click.echo(cmd.out + cmd.err)
    click.secho("Install completed ✓", fg="green")

    click.echo(
        crayons.green(
            emoji.emojize("\n:sparkles:  Install complete", use_aliases=True)))
Exemplo n.º 43
0
def do_lock(dev=False):
    """Executes the freeze functionality."""

    click.echo(
        crayons.yellow(
            'Assuring all dependencies from Pipfile are installed...'))

    # Purge the virtualenv, for development dependencies.
    do_purge(bare=True)

    click.echo(
        crayons.yellow('Locking {0} dependencies...'.format(
            crayons.red('[dev-packages]'))))

    # Install only development dependencies.
    do_install_dependencies(dev=True, only=True, bare=True)

    # Load the Pipfile and generate a lockfile.
    p = pipfile.load(project.pipfile_location)
    lockfile = json.loads(p.freeze())

    # Pip freeze development dependencies.
    c = delegator.run('{0} freeze'.format(which_pip()))

    # Add Development dependencies to lockfile.
    for dep in c.out.split('\n'):
        if dep:
            lockfile['develop'].update(convert_deps_from_pip(dep))

    # Purge the virtualenv.
    do_purge(bare=True)

    click.echo(
        crayons.yellow('Locking {0} dependencies...'.format(
            crayons.red('[packages]'))))

    # Install only development dependencies.
    do_install_dependencies(bare=True)

    # Pip freeze default dependencies.
    c = delegator.run('{0} freeze'.format(which_pip()))

    # Add default dependencies to lockfile.
    for dep in c.out.split('\n'):
        if dep:
            lockfile['default'].update(convert_deps_from_pip(dep))

    # Write out lockfile.
    with open(project.lockfile_location, 'w') as f:
        f.write(json.dumps(lockfile, indent=4, separators=(',', ': ')))

    # Provide instructions for dev depenciencies.
    if not dev:
        click.echo(
            crayons.yellow('Note: ') +
            'your project now has only default {0} installed.'.format(
                crayons.red('[packages]')))
        click.echo('To keep {0} next time, run: $ {1}'.format(
            crayons.red('[dev-packages]'), crayons.green('pipenv lock --dev')))
    else:
        # Install only development dependencies.
        do_install_dependencies(dev=True, only=True, bare=True)
Exemplo n.º 44
0
def upgrade(package_line, upgrade_level="latest", noinput=False):
    # get current version

    req = Requirement.parse(package_line)
    click.secho("Installing {0}...".format(crayons.yellow(req.name)))

    logger.debug(req.__dict__)

    is_flag_latest = upgrade_level in ["major", "latest"]

    dep_type = project.detect_type_of_dependency(req.name)
    dev = dep_type == "dev"
    if dep_type == "dev":
        local_package = get_package_from_requirement_file(
            req.name, project.requirements_file("dev-locked.txt"))
    else:
        local_package = get_package_from_requirement_file(
            req.name, project.requirements_file("base-locked.txt"))

    if not local_package:
        click.secho("Package is not installed", fg="red")
        sys.exit(1)

    if local_package.vcs or local_package.editable:
        click.secho("Skipped. Editable sources not supported at the moment")
        return

    if (not is_flag_latest) and (local_package.vcs):
        click.secho(
            "Can't do patch or minor upgrade for packages installed via version control. Please use --latest"
        )

    from pip._vendor.distlib.version import NormalizedVersion
    local_version = local_package.specs[0][1]
    norm = NormalizedVersion(local_version)
    clause = [str(item) for item in norm._release_clause]
    if len(clause) < 2:
        clause.extend(["0", "0"])
    elif len(clause) < 3:
        clause.append("0")

    upgrade_specifier = ""
    if upgrade_level == "patch":
        upgrade_specifier = "~={0}".format(".".join(clause))
    elif upgrade_level == "minor":
        del clause[2]
        upgrade_specifier = "~={0}".format(".".join(clause))

    if not noinput:
        original_versions = pip_versions(local_package.name)
        original_versions.reverse()
        if not original_versions:
            logger.error("Possible error {}".format(original_versions))

        # coerced_versions = [_item for _item in map(lambda x: overrides.Version.coerce(x, partial=True), original_versions)]
        # # versions = list(map(lambda x: overrides.Version.coerce(x, partial=True), original_versions))
        # if not coerced_versions:
        #     logger.error("Possible error 2 {0} {1}".format(original_versions, coerced_versions))
        # coerced_versions.reverse()

        try:
            logger.debug("req:{}".format(req.__dict__))
            # current_version = overrides.Version.coerce(req.specs[0][1], partial=True)
            try:
                dep = project.piper_lock["frozen_deps"][req.name.lower()]
            except:
                click.secho(
                    crayons.red("Package not found. Please use ") +
                    crayons.yellow("piper add {}".format(package_line)) +
                    crayons.red("instead"))
                sys.exit(1)

            current_version = overrides.Version.coerce(dep["specs"][0][1])

            coerced_versions = [
                _item for _item in map(
                    lambda x: overrides.Version.coerce(x, partial=True),
                    original_versions)
            ]
            # version_mapping = map(lambda index, x: (x.__str__(), versions[index] ), enumerate(coerced_versions))

            spec = None
            if upgrade_specifier:
                spec = overrides.Spec(upgrade_specifier)
            elif req.specs:
                spec_line = ",".join(["".join(x) for x in req.specs])
                # logger.debug("specs {0} {1}".format(spec_line, req.specs))
                spec = overrides.Spec(spec_line)
                # spec = [_item for _item in map(lambda x: overrides.Spec("".join(x) ), req.specs)]
                # logger.error("Investigate")
            else:
                spec = overrides.Spec(">={}".format(
                    current_version.original_version))

            # if dep["specifier"]:
            #     spec = next(map(lambda x: semantic_version.Spec("".join(x) ), dep["specs"]))
            # click.echo("{} {} {}".format(versions, spec, upgrade_specifier))
            if spec:
                valid_versions = [
                    _item for _item in spec.filter(coerced_versions)
                ]
                wanted_version = spec.select(valid_versions).original_version
            else:
                valid_versions = [_item for _item in coerced_versions]
                wanted_version = valid_versions[0]
            patch_version = semantic_version.Spec("~={}".format(
                current_version.major, current_version.minor,
                current_version.patch)).select(valid_versions).original_version
            minor_version = semantic_version.Spec("~={}".format(
                current_version.major, current_version.minor,
                current_version.patch)).select(valid_versions).original_version

        except ValueError as err:
            logger.debug("ValueError for {0} with {1}".format(
                dep["name"], err))
            current_version = dep["specs"][0][1]
            # click.echo(err)
            wanted_version = "not semantic"
            patch_version = ""
            minor_version = ""

        # click.echo("{} {} {}".format(versions, spec, upgrade_specifier))
        # valid_versions = list(spec.filter(coerced_versions))
        # wanted_version = spec.select(coerced_versions)

        echo_list = crayons.white("")
        for index, version in enumerate(valid_versions):
            echo_list = echo_list + crayons.yellow(
                "[{}] ".format(index + 1)) + crayons.white(
                    "{} ".format(version))

        chosen_index = click.prompt(
            "Select one of the following versions: {}".format(echo_list),
            default=1)
        chosen_version = valid_versions[chosen_index - 1]

        package_line = req.name + "==" + chosen_version.__str__()
    else:
        package_line = req.name + upgrade_specifier

    c = pip_install(package_line, allow_global=False, upgrade=True)
    # result = parse.search("Successfully installed {} \n", c.out)

    if not (c.return_code == 0):
        click.secho(c.err, fg="red")
        click.echo(
            crayons.red("Failed to install ") + crayons.yellow(req.name) +
            crayons.red(" ✗")
            # "Package {0} removed ✓".format(req.name), fg="green"
        )
        sys.exit()
    else:
        click.secho(c.out.rstrip(), fg="blue")

        click.echo(
            crayons.green("Package ") + crayons.yellow(req.name) +
            crayons.green(" installed ✓")
            # crayons.green("Package {0} installed ✓".format(crayons.yellow(req.name)))
        )

    result = parse.search("Successfully installed {}\n", c.out)
    succesfully_installed = result.fixed[0].split() if result else []
    succesfully_installed = [
        item.rsplit('-', 1)[0] for item in succesfully_installed
    ]
    existing_packages = [
        result.fixed[0] for result in parse.findall(
            "Requirement already satisfied: {} in", c.out)
    ]

    all_pkgs = succesfully_installed + existing_packages
    all_pkgs = [Req.parse(pkg).unsafe_name for pkg in all_pkgs]

    # click.secho("Locking requirements...")

    frozen_deps = pip_freeze()
    frozen_dep = next(
        filter(lambda x: x.name.lower() == req.name.lower(), frozen_deps),
        None)
    project.update_frozen_dependencies_in_piper_lock(frozen_deps)

    dependency = {
        "name": frozen_dep.name,
        "line": frozen_dep.line,
        "specs": frozen_dep.specs,
        "dependencies":
        [pkg for pkg in all_pkgs if not (pkg == frozen_dep.name)]
    }
    project.add_dependency_to_piper_lock(dependency, dev=dev)
    project.update_requirement_files_from_piper_lock()

    click.secho("Requirements locked ✓", fg="green")

    # click.echo("All pkgs: {}".format(all_pkgs))

    # click.secho("Updating requirement files...")

    # if (not req.vcs) and (not req.local_file) and req.specs:
    #     add_to_requirements_file(req, os.path.join(".", "requirements", "base.txt"))
    # else:
    #     add_to_requirements_file(frozen_dep, os.path.join(".", "requirements", "base.txt"))
    # add_to_requirements_lockfile(frozen_deps, os.path.join(".", "requirements", "base-locked.txt"))

    click.secho("Requirements updated ✓", fg="green")
    # compile_requirements(os.path.join(".", "requirements", "base.txt"), os.path.join(".", "requirements", "base-locked.txt"))

    # print(req.__dict__)

    click.echo(
        crayons.green(
            emoji.emojize("\n:sparkles:  Upgrade complete", use_aliases=True)))
Exemplo n.º 45
0
def cli(ctx,
        state,
        where=False,
        venv=False,
        rm=False,
        bare=False,
        three=False,
        python=False,
        help=False,
        py=False,
        site_packages=False,
        envs=False,
        man=False,
        completion=False,
        pypi_mirror=None,
        support=None,
        clear=False,
        **kwargs):
    # Handle this ASAP to make shell startup fast.
    if completion:
        from .. import shells

        try:
            shell = shells.detect_info()[0]
        except shells.ShellDetectionFailure:
            echo(
                "Fail to detect shell. Please provide the {0} environment "
                "variable.".format(crayons.normal("PIPENV_SHELL", bold=True)),
                err=True,
            )
            ctx.abort()
        print(click_completion.get_code(shell=shell, prog_name="pipenv"))
        return 0

    from ..core import (
        system_which,
        do_py,
        warn_in_virtualenv,
        do_where,
        project,
        cleanup_virtualenv,
        ensure_project,
        format_help,
        do_clear,
    )
    from ..utils import create_spinner

    if man:
        if system_which("man"):
            path = os.sep.join([os.path.dirname(__file__), "pipenv.1"])
            os.execle(system_which("man"), "man", path, os.environ)
            return 0
        else:
            secho("man does not appear to be available on your system.",
                  fg="yellow",
                  bold=True,
                  err=True)
            return 1
    if envs:
        echo(
            "The following environment variables can be set, to do various things:\n"
        )
        for key in environments.__dict__:
            if key.startswith("PIPENV"):
                echo("  - {0}".format(crayons.normal(key, bold=True)))
        echo("\nYou can learn more at:\n   {0}".format(
            crayons.green(
                "http://docs.pipenv.org/advanced/#configuration-with-environment-variables"
            )))
        return 0
    warn_in_virtualenv()
    if ctx.invoked_subcommand is None:
        # --where was passed…
        if where:
            do_where(bare=True)
            return 0
        elif py:
            do_py()
            return 0
        # --support was passed…
        elif support:
            from ..help import get_pipenv_diagnostics

            get_pipenv_diagnostics()
            return 0
        # --clear was passed…
        elif clear:
            do_clear()
            return 0

        # --venv was passed…
        elif venv:
            # There is no virtualenv yet.
            if not project.virtualenv_exists:
                echo(
                    crayons.red(
                        "No virtualenv has been created for this project yet!"
                    ),
                    err=True,
                )
                ctx.abort()
            else:
                echo(project.virtualenv_location)
                return 0
        # --rm was passed…
        elif rm:
            # Abort if --system (or running in a virtualenv).
            if environments.PIPENV_USE_SYSTEM:
                echo(
                    crayons.red(
                        "You are attempting to remove a virtualenv that "
                        "Pipenv did not create. Aborting."))
                ctx.abort()
            if project.virtualenv_exists:
                loc = project.virtualenv_location
                echo(
                    crayons.normal(u"{0} ({1})…".format(
                        crayons.normal("Removing virtualenv", bold=True),
                        crayons.green(loc),
                    )))
                with create_spinner(text="Running..."):
                    # Remove the virtualenv.
                    cleanup_virtualenv(bare=True)
                return 0
            else:
                echo(
                    crayons.red(
                        "No virtualenv has been created for this project yet!",
                        bold=True,
                    ),
                    err=True,
                )
                ctx.abort()
    # --two / --three was passed…
    if (state.python or state.three is not None) or site_packages:
        ensure_project(
            three=state.three,
            python=state.python,
            warn=True,
            site_packages=state.site_packages,
            pypi_mirror=state.pypi_mirror,
            clear=state.clear,
        )
    # Check this again before exiting for empty ``pipenv`` command.
    elif ctx.invoked_subcommand is None:
        # Display help to user, if no commands were passed.
        echo(format_help(ctx.get_help()))
Exemplo n.º 46
0
    if(request_post.status_code == 202):
        print("\n")
        print(f"SUCCESS: {domdata} BLOCKED!!")
        print("\n")
    # error handling
    else:
        print("An error has ocurred with the following code %(error)s, please consult the following link: https://docs.umbrella.com/investigate-api/" %
                          {'error': request_post.status_code})


if __name__ == "__main__":
    # Save the MAC addresses of the endpoints where malware executed to a JSON
    # file.  In the ISE Mission we will read this file and quarantine these
    # endpoints.sha256-list.json
    domainlist_path = repository_root / "mission-data/domainlist.json"

    # TODO: Mission call the function to handle domains
    MISSION(domainlist_path)

    #TODO: initialize the teams object with the webexteamssdk using your access token and the ROOM_ID
    
    teams.MISSION(
        roomId=MISSION
        markdown=f"**Umberlla Mission completed!!!** \n\n"
                 f"I checked the status of the domains generated by ThreatGrid using Umbrella Investigate! \n\n"
                 f"I also blocked DNS lookup using Umbrella Enforcement API for Malicious and Risky Domains"

    )

    print(green("Umbrella Mission Completed!!!"))
Exemplo n.º 47
0
    def enqueue_files(self, files: list):
        """Add requested files to the appropriate queue

        :param files: list of (path,profile) tuples
        :return:
        """

        for path, forced_profile in files:
            #
            # do some prechecks...
            #
            if forced_profile is not None and not self.configfile.has_profile(
                    forced_profile):
                print(
                    f'profile "{forced_profile}" referenced from command line not found'
                )
                sys.exit(1)

            if len(path) == 0:
                continue

            if not os.path.isfile(path):
                print(crayons.red('file not found, skipping: ' + path))
                continue

            media_info = self.ffmpeg.fetch_details(path)
            if media_info is None:
                print(crayons.red(f'File not found: {path}'))
                continue
            if media_info.valid:

                if pytranscoder.verbose:
                    print(str(media_info))

                if forced_profile is None:
                    the_profile = None
                    rule = self.configfile.match_rule(media_info)
                    if rule is None:
                        print(
                            crayons.yellow(
                                f'No matching profile found - skipped'))
                        continue
                    if rule.is_skip():
                        print(crayons.green(os.path.basename(path)),
                              f'SKIPPED ({rule.name})')
                        self.complete.append((path, 0))
                        continue
                    profile_name = rule.profile
                    the_profile = self.configfile.get_profile(profile_name)
                else:
                    #
                    # looks good, add this file to the thread queue
                    #
                    the_profile = self.configfile.get_profile(forced_profile)
                    profile_name = forced_profile

                qname = the_profile.queue_name
                if pytranscoder.verbose:
                    print('Matched with profile {profile_name}')
                if qname is not None:
                    if not self.configfile.has_queue(the_profile.queue_name):
                        print(
                            crayons.red(
                                f'Profile "{profile_name}" indicated queue "{qname}" that has not been defined'
                            ))
                        sys.exit(1)
                    else:
                        self.queues[qname].put(
                            LocalJob(path, the_profile, media_info))
                        if pytranscoder.verbose:
                            print('Added to queue {qname}')
                else:
                    self.queues['_default_'].put(
                        LocalJob(path, the_profile, media_info))
Exemplo n.º 48
0
    client = get_spec_json()
    domain_list = []
    clean_domains = []
    #Read the domain file created by ThreatGrid
    domainlist_path = repository_root / "mission-data/riskydomains.json"
    domain_list = readdomains_file(domainlist_path)
    #TODO Mission make sure there no duplicate domains
   env_lab.print_missing_mission_warn(env_lab.get_line()) 

    url_objects = []
    for doms in clean_domains:
        url_objects.append(create_url_object(client, doms))

    #TODO Mission create a url group using the url_objects created in the above steps :
    #Pass these 3 values to the proper function client, "your_picked_name_for_URL_Object", url objects create in above for loop
    env_lab.print_missing_mission_warn(env_lab.get_line())

    #TODO Mission Create Access Rule to the block the URL object created above ... which will block all the risky domains
    env_lab.print_missing_mission_warn(env_lab.get_line())

    #post Message to WebEx Teams!
    print(blue("\n==> Posting message to Webex Teams"))
    teams = webexteamssdk.WebexTeamsAPI(WEBEX_TEAMS_ACCESS_TOKEN)
    teams.messages.create(
        roomId=WEBEX_TEAMS_ROOM_ID,
        markdown=f"**Firepower - FDM Mission completed!!!** \n\n"
                 f"I was able to block domains from the file"

    )
    print(green("Firepower - FDM: Mission Completed!!!"))
Exemplo n.º 49
0
import os
import sys
import time
import crayons
from .environments import PIPENV_COLORBLIND, PIPENV_HIDE_EMOJIS

STREAM = sys.stderr
MILL_TEMPLATE = "%s %s %i/%i\r"
DOTS_CHAR = "."
if os.name != "nt":
    if PIPENV_HIDE_EMOJIS:
        if PIPENV_COLORBLIND:
            BAR_FILLED_CHAR = "="
            BAR_EMPTY_CHAR = "-"
        else:
            BAR_FILLED_CHAR = str(crayons.green("=", bold=True))
            BAR_EMPTY_CHAR = str(crayons.black("-"))
    else:
        if PIPENV_COLORBLIND:
            BAR_FILLED_CHAR = "▉"
            BAR_EMPTY_CHAR = " "
        else:
            BAR_FILLED_CHAR = str(crayons.green("▉", bold=True))
            BAR_EMPTY_CHAR = str(crayons.black("▉"))

else:
    BAR_FILLED_CHAR = "="
    BAR_EMPTY_CHAR = "-"

if (sys.version_info[0] >= 3) and (os.name != "nt"):
    BAR_TEMPLATE = u"  %s%s%s %i/%i — {0}\r".format(crayons.black("%s"))
Exemplo n.º 50
0
                brd.DC((50, 50)),
                libraryfile=argsd["library"],
                partname=part,
                debug=argsd["verbose"],
            )
        except ValueError:
            print(
                crayons.red("Part ")
                + part
                + crayons.red(" was not found in ")
                + argsd["library"]
            )
            exit()
        if argsd["svg"]:
            print("Exporting %s in %s..." % (part, argsd["library"]))
            b = []
            for layer in ["GTO", "GTL", "GTS", "GTP"]:
                obj = brd.layers[layer].preview()
                b.append(obj.bounds)
            bounds = max_bounds(b, min_bound=SVG_BOUNDARY)
            g = sg.box(*bounds)
            brd.layers["GML"].add(g)
            svg_write(brd, part + ".svg")
            print(crayons.green("%s exported to %s.svg" % (part, part)))
    else:
        print(
            "Package list of Eagle library " + crayons.green("%s:" % (argsd["library"]))
        )
        n = list_lbr_packages(argsd["library"])
        print(crayons.green("%d packages found in %s" % (n, argsd["library"])))