Update conda packages in a conda env

    Attributes
    ----------
        packages: list of packages comma delimited
193528
def update(packages, env=None, user=None):
    
    packages = ' '.join(packages.split(','))
    cmd = _create_conda_cmd('update', args=[packages, '--yes', '-q'], env=env, user=user)
    return _execcmd(cmd, user=user)
1064956
def split_package(package):
    
    name = ver = arch = build = []
    split = package.split("-")
    if len(split) > 2:
        build = split[-1]
        build_a, build_b = "", ""
        build_a = build[:1]
        if build[1:2].isdigit():
            build_b = build[1:2]
        build = build_a + build_b
        arch = split[-2]
        ver = split[-3]
        name = "-".join(split[:-3])
    return [name, ver, arch, build]
1290586
def patched_packing_env(env):
  """"""
  old_env = pkg_resources.packaging.markers.default_environment
  new_env = lambda: env
  pkg_resources._vendor.packaging.markers.default_environment = new_env
  try:
    yield
  finally:
    pkg_resources._vendor.packaging.markers.default_environment = old_env
379031
def env_updated(cls, app, env):
        
        if cls.ABORT_AFTER_READ:
            config = {n: getattr(app.config, n) for n in (a for a in dir(app.config) if a.startswith('scv_'))}
            config['found_docs'] = tuple(str(d) for d in env.found_docs)
            config['master_doc'] = str(app.config.master_doc)
            cls.ABORT_AFTER_READ.put(config)
            sys.exit(0)
288076
def prep_shell_environment(nova_env, nova_creds):
    
    new_env = {}

    for key, value in prep_nova_creds(nova_env, nova_creds):
        if type(value) == six.binary_type:
            value = value.decode()
        new_env[key] = value

    return new_env
661959
def update(self, conf_dict):
        '''
        
        '''

        if isinstance(conf_dict, dict):
            iterator = six.iteritems(conf_dict)
        else:
            iterator = iter(conf_dict)

        for k, v in iterator:
            if not IDENTIFIER.match(k):
                raise ValueError('\'%s\' is not a valid indentifier' % k)

            cur_val = self.__values__.get(k)

            if isinstance(cur_val, Config):
                cur_val.update(conf_dict[k])
            else:
                self[k] = conf_dict[k]
551566
def clone_environment(self, clone, name=None, prefix=None, **kwargs):
        """"""
        cmd_list = ['create', '--json']

        if (name and prefix) or not (name or prefix):
            raise TypeError("conda clone_environment: exactly one of `name` "
                            "or `path` required")

        if name:
            cmd_list.extend(['--name', name])

        if prefix:
            cmd_list.extend(['--prefix', prefix])

        cmd_list.extend(['--clone', clone])

        cmd_list.extend(
            self._setup_install_commands_from_kwargs(
                kwargs,
                ('dry_run', 'unknown', 'use_index_cache', 'use_local',
                 'no_pin', 'force', 'all', 'channel', 'override_channels',
                 'no_default_packages')))

        return self._call_and_parse(cmd_list, abspath=kwargs.get('abspath',
                                                                 True))
1348948
def pipupdate():
    

    packages = [d for d in pkg_resources.working_set]
    subprocess.call('pip install --upgrade ' + ' '.join(packages))
211498
def install_packages():
    

    if env.verbosity:
        print env.host, "INSTALLING & CONFIGURING NODE PACKAGES:"
    #Get a list of installed packages
    p = run("dpkg -l | awk '/ii/ {print $2}'").split('\n')
    
    #Remove apparmor - TODO we may enable this later
    if env.overwrite or not server_state('apparmor-disabled') and 'apparmor' in p:
        with settings(warn_only=True):
            sudo('/etc/init.d/apparmor stop')
            sudo('update-rc.d -f apparmor remove')
            set_server_state('apparmor-disabled')

    #The principle we will use is to only install configurations and packages
    #if they do not already exist (ie not manually installed or other method)
    env.installed_packages[env.host] = []
    role = env.role_lookup[env.host_string]
    packages = get_packages()
    for package in packages:
        if not package in p:
            install_package(package)
            if env.verbosity:
                print ' * installed',package
            env.installed_packages[env.host].append(package)
    if env.overwrite or env.installed_packages[env.host]: #always store the latest complete list
        set_server_state('packages_installed', packages)
        env.installed_packages[env.host] = packages

    if env.overwrite and 'apache2' in env.installed_packages[env.host]: 
            #some sensible defaults -might move to putting this config in a template
            sudo("rm -f /etc/apache2/sites-enabled/000-default")
            sed('/etc/apache2/apache2.conf',before='KeepAlive On',after='KeepAlive Off',use_sudo=True, backup='')
            sed('/etc/apache2/apache2.conf',before='StartServers          2', after='StartServers          1', use_sudo=True, backup='')
            sed('/etc/apache2/apache2.conf',before='MaxClients          150', after='MaxClients          100', use_sudo=True, backup='')
            for module in env.APACHE_DISABLE_MODULES:
                sudo('rm -f /etc/apache2/mods-enabled/%s*'% module)
    #Install base python packages
    #We'll use easy_install at this stage since it doesn't download if the package
    #is current whereas pip always downloads.
    #Once both these packages mature we'll move to using the standard Ubuntu packages
    if (env.overwrite or not server_state('pip-venv-wrapper-installed')) and 'python-setuptools' in packages:
        sudo("easy_install virtualenv")
        sudo("easy_install pip")
        sudo("easy_install virtualenvwrapper")
        if env.verbosity:
            print " * easy installed pip, virtualenv, virtualenvwrapper"
        set_server_state('pip-venv-wrapper-installed')
    if not contains("/home/%s/.profile"% env.user,"source /usr/local/bin/virtualenvwrapper.sh"):
        append("/home/%s/.profile"% env.user, "export WORKON_HOME=$HOME/env")
        append("/home/%s/.profile"% env.user, "source /usr/local/bin/virtualenvwrapper.sh")

    #cleanup after easy_install
    sudo("rm -rf build")
193563
def cli(parser):
    '''
    
    '''
    parser.add_argument('packages', nargs='*', default=local_packages(),
        help='Packages to upgrade (defaults to all installed packages)')
    parser.add_argument('-n', '--dry-run', action='store_true',
        help='Print upgrade actions without running')
    opts = parser.parse_args()

    for package in opts.packages:
        upgrade(package, execute=not opts.dry_run)
573694
def update_deps(self):
        
        for dep in self.dependencies:
            deps = Utils().dimensional_list(Dependencies(
                self.repo, self.blacklist).binary(
                    dep, self.flag))
            self.deps_dict[dep] = deps
1288575
def merge_env(self, env):
        
        # convert to dict to allow update
        current_env = dict(item.split('=') for item in self._env)

        # do validation and set new values.
        self.env = env

        # convert to dict to allow update
        new_env = dict(item.split('=') for item in self._env)

        # update old with new
        current_env.update(new_env)

        # apply updated values
        self.env = current_env
523208
def packages(ciprcfg, env, opts, console):
    
    for name, source in ciprcfg.packages.items():
        console.normal('- %s' % name)

        if opts.long_details:
            console.normal('  - directory: %s' % path.join(env.package_dir, name))
            console.normal('  - source: %s' % source)
383808
def require_debian_packages(packages: List[str]) -> None:
    
    present = are_debian_packages_installed(packages)
    missing_packages = [k for k, v in present.items() if not v]
    if missing_packages:
        missing_packages.sort()
        msg = (
            "Debian packages are missing, as follows. Suggest:\n\n"
            "sudo apt install {}".format(" ".join(missing_packages))
        )
        log.critical(msg)
        raise ValueError(msg)
1261181
def get_package_versions(package):
    
    list_command = ListCommand()
    options, args = list_command.parse_args([])
    packages = [get_dist(package)]
    dists = list_command.iter_packages_latest_infos(packages, options)
    try:
        dist = next(dists)
        return dist.parsed_version, dist.latest_version
    except StopIteration:
        return None, None
161658
def _normalize_merge_diff_incr(diff):
        
        new_diff = []

        changes_found = False
        for line in diff.splitlines():
            if re.search(r"order-dependent line.*re-ordered", line):
                changes_found = True
            elif "No changes were found" in line:
                # IOS in the re-order case still claims "No changes were found"
                if not changes_found:
                    return ""
                else:
                    continue

            if line.strip() == "end":
                continue
            elif "List of Commands" in line:
                continue
            # Filter blank lines and prepend +sign
            elif line.strip():
                if re.search(r"^no\s+", line.strip()):
                    new_diff.append("-" + line)
                else:
                    new_diff.append("+" + line)
        return "\n".join(new_diff)
478587
def _pip_cmd(self, name=None, prefix=None):
        """"""
        if (name and prefix) or not (name or prefix):
            raise TypeError("conda pip: exactly one of 'name' ""or 'prefix' "
                            "required.")

        if name and self.environment_exists(name=name):
            prefix = self.get_prefix_envname(name)

        if sys.platform == 'win32':
            python = join(prefix, 'python.exe')  # FIXME:
            pip = join(prefix, 'pip.exe')        # FIXME:
        else:
            python = join(prefix, 'bin/python')
            pip = join(prefix, 'bin/pip')

        cmd_list = [python, pip]

        return cmd_list