Uninstall unwanted packages
766616
def uninstall_packages():
    
    p = server_state('packages_installed')
    if p: installed = set(p)
    else: return
    env.uninstalled_packages[env.host] = []
    #first uninstall any that have been taken off the list
    packages = set(get_packages())
    uninstall = installed - packages
    if uninstall and env.verbosity:
        print env.host,'UNINSTALLING HOST PACKAGES'
    for p in uninstall:
        if env.verbosity:
            print ' - uninstalling',p
        uninstall_package(p)
        env.uninstalled_packages[env.host].append(p)
    set_server_state('packages_installed',get_packages())
    return
541873
def remove(pkg):
    '''
    
    '''
    ret = {'result': None, 'output': ""}
    try:
        ret['output'] = subprocess.check_output([SNAP_BINARY_NAME, 'remove', pkg])
        ret['result'] = True
    except subprocess.CalledProcessError as e:
        ret['output'] = e.output
        ret['result'] = False
218445
def filter_installed_packages(packages):
    """"""
    cache = apt_cache()
    _pkgs = []
    for package in packages:
        try:
            p = cache[package]
            p.current_ver or _pkgs.append(package)
        except KeyError:
            log('Package {} has no installation candidate.'.format(package),
                level='WARNING')
            _pkgs.append(package)
    return _pkgs
329285
public function uninstall_cleanup() {
        global $CFG;
        require_once($CFG->dirroot.'/repository/lib.php');

        $repo = \repository::get_type_by_typename($this->name);
        if ($repo) {
            $repo->delete(true);
        }

        parent::uninstall_cleanup();
    }
360618
def cleanup():
        """"""
        for install_dir in linters.INSTALL_DIRS:
            try:
                shutil.rmtree(install_dir, ignore_errors=True)
            except Exception:
                print(
                    "{0}\nFailed to delete {1}".format(
                        traceback.format_exc(), install_dir
                    )
                )
                sys.stdout.flush()
1024627
def remove_package(identifier)
      removed = @packages.delete_if { |p| p[:id] == identifier || p[:name] == identifier }
      @need_to_update = true if removed
      removed
    end
808868
function cleanInstallFolder(rushCommonFolder, packageInstallFolder) {
    try {
        const flagFile = path.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME);
        if (fs.existsSync(flagFile)) {
            fs.unlinkSync(flagFile);
        }
        const packageLockFile = path.resolve(packageInstallFolder, 'package-lock.json');
        if (fs.existsSync(packageLockFile)) {
            fs.unlinkSync(packageLockFile);
        }
        const nodeModulesFolder = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME);
        if (fs.existsSync(nodeModulesFolder)) {
            const rushRecyclerFolder = ensureAndJoinPath(rushCommonFolder, 'temp', 'rush-recycler', `install-run-${Date.now().toString()}`);
            fs.renameSync(nodeModulesFolder, rushRecyclerFolder);
        }
    }
    catch (e) {
        throw new Error(`Error cleaning the package install folder (${packageInstallFolder}): ${e}`);
    }
}
1018484
def remove_package(self, team, user, package):
        
        self.check_name(team, user, package)

        path = self.package_path(team, user, package)
        remove_objs = set()
        # TODO: do we really want to delete invisible dirs?
        if os.path.isdir(path):
            # Collect objects from all instances for potential cleanup
            contents_path = os.path.join(path, PackageStore.CONTENTS_DIR)
            for instance in os.listdir(contents_path):
                pkg = self.get_package(team, user, package, pkghash=instance)
                remove_objs.update(find_object_hashes(pkg))
            # Remove package manifests
            rmtree(path)

        return self.prune(remove_objs)
1192446
def uninstall(self, package: str) -> None:
        ''''''
        if package not in self.view_packgets_list():
            raise NoSuchPackageException(
                f'There is no such package {package!r}.')
        self._execute('-s', self.device_sn, 'uninstall', package)
33150
def _uninstall(action='remove', name=None, pkgs=None, **kwargs):
    '''
    
    '''
    try:
        pkg_params = __salt__['pkg_resource.parse_targets'](name, pkgs)[0]
    except MinionError as exc:
        raise CommandExecutionError(exc)

    old = list_pkgs()
    targets = [x for x in pkg_params if x in old]
    if not targets:
        return {}

    remove_arg = '-Rsc' if action == 'purge' else '-R'

    cmd = []
    if salt.utils.systemd.has_scope(__context__) \
            and __salt__['config.get']('systemd.scope', True):
        cmd.extend(['systemd-run', '--scope'])
    cmd.extend(['pacman', remove_arg, '--noprogressbar', '--noconfirm'])
    cmd.extend(targets)

    if 'root' in kwargs:
        cmd.extend(('-r', kwargs['root']))

    out = __salt__['cmd.run_all'](
        cmd,
        output_loglevel='trace',
        python_shell=False
    )

    if out['retcode'] != 0 and out['stderr']:
        errors = [out['stderr']]
    else:
        errors = []

    __context__.pop('pkg.list_pkgs', None)
    new = list_pkgs()
    ret = salt.utils.data.compare_dicts(old, new)

    if errors:
        raise CommandExecutionError(
            'Problem encountered removing package(s)',
            info={'errors': errors, 'changes': ret}
        )

    return ret
1235820
def remove(self, auto_confirm=False, verbose=False):
        """"""

        if not self.paths:
            logger.info(
                "Can't uninstall '%s'. No files were found to uninstall.",
                self.dist.project_name,
            )
            return

        dist_name_version = (
            self.dist.project_name + "-" + self.dist.version
        )
        logger.info('Uninstalling %s:', dist_name_version)

        with indent_log():
            if auto_confirm or self._allowed_to_proceed(verbose):
                moved = self._moved_paths

                for_rename = compress_for_rename(self.paths)

                for path in sorted(compact(for_rename)):
                    moved.stash(path)
                    logger.debug('Removing file or directory %s', path)

                for pth in self.pth.values():
                    pth.remove()

                logger.info('Successfully uninstalled %s', dist_name_version)
92523
def clean():
    ""
    src_dir = easy.options.setdefault("docs", {}).get('src_dir', None)
    if src_dir is None:
        src_dir = 'src' if easy.path('src').exists() else '.'

    with easy.pushd(src_dir):
        for pkg in set(easy.options.setup.packages) | set(("tests",)):
            for filename in glob.glob(pkg.replace('.', os.sep) + "/*.py[oc~]"):
                easy.path(filename).remove()
1054405
def app_uninstall(self, package_name, keep_data=False):
        
        if keep_data:
            return self.run_cmd('uninstall', '-k', package_name)
        else:
            return self.run_cmd('uninstall', package_name)
703353
function uninstall( $package, $installType, $parameters,
                        $name, $os, $filename, $subdirectory,
                        $content, &$installParameters,
                        &$installData )
    {
        $this->Package = $package;

        if ( isset( $installParameters['error']['error_code'] ) )
            $errorCode = $installParameters['error']['error_code'];
        else
            $errorCode = false;

        // Error codes reserverd for content object uninstallation
        if ( !$errorCode || ( $errorCode >= self::UNINSTALL_OBJECTS_ERROR_RANGE_FROM &&
                              $errorCode <= self::UNINSTALL_OBJECTS_ERROR_RANGE_TO ) )
        {
            $objectListNode = $content->getElementsByTagName( 'object-list' )->item( 0 );
            if ( $objectListNode )
            {
                $objectNodes = $objectListNode->getElementsByTagName( 'object' );
            }
            else
            {
                $objectListNode = $content->getElementsByTagName( 'object-files-list' )->item( 0 );
                $objectNodes = $objectListNode->getElementsByTagName( 'object-file' );
            }

            // loop intentionally from the last until the first
            // objects need to be uninstalled in reverse order of installation
            for ( $i = $objectNodes->length - 1; $i >=0; $i-- )
            {
                $objectNode = $objectNodes->item( $i );
                $realObjectNode = $this->getRealObjectNode( $objectNode );

                $objectRemoteID = $realObjectNode->getAttribute( 'remote_id' );
                $name = $realObjectNode->getAttribute( 'name' );

                if ( isset( $installParameters['error']['error_code'] ) &&
                     !$this->isErrorElement( $objectRemoteID, $installParameters ) )
                    continue;

                if ( isset( $object ) )
                {
                    eZContentObject::clearCache( $object->attribute( 'id' ) );
                    unset( $object );
                }
                $object = eZContentObject::fetchByRemoteID( $objectRemoteID );

                if ( $object !== null )
                {
                    $modified = $object->attribute( 'modified' );
                    $published = $object->attribute( 'published' );
                    if ( $modified > $published )
                    {
                        $choosenAction = $this->errorChoosenAction( eZContentObject::PACKAGE_ERROR_MODIFIED,
                                                                    $installParameters, false, $this->HandlerType );

                        if ( $choosenAction == eZContentObject::PACKAGE_KEEP )
                        {
                            continue;
                        }
                        if ( $choosenAction != eZContentObject::PACKAGE_DELETE )
                        {
                            $installParameters['error'] = array( 'error_code' => eZContentObject::PACKAGE_ERROR_MODIFIED,
                                                                 'element_id' => $objectRemoteID,
                                                                 'description' => ezpI18n::tr( 'kernel/package',
                                                                                          "Object '%objectname' has been modified since installation. Are you sure you want to remove it?",
                                                                                          false, array( '%objectname' => $name ) ),
                                                                 'actions' => array( eZContentObject::PACKAGE_DELETE => ezpI18n::tr( 'kernel/package', 'Remove' ),
                                                                                     eZContentObject::PACKAGE_KEEP => ezpI18n::tr( 'kernel/package', 'Keep object' ) ) );
                            return false;
                        }
                    }

                    $assignedNodes = $object->attribute( 'assigned_nodes' );
                    $assignedNodeIDArray = array();
                    foreach( $assignedNodes as $node )
                    {
                        $assignedNodeIDArray[] = $node->attribute( 'node_id' );
                    }
                    if ( count( $assignedNodeIDArray ) == 0 )
                        continue;
                    $info = eZContentObjectTreeNode::subtreeRemovalInformation( $assignedNodeIDArray );
                    $childrenCount = $info['total_child_count'];

                    if ( $childrenCount > 0 )
                    {
                        $choosenAction = $this->errorChoosenAction( eZContentObject::PACKAGE_ERROR_HAS_CHILDREN,
                                                                    $installParameters, false, $this->HandlerType );

                        if ( $choosenAction == eZContentObject::PACKAGE_KEEP )
                        {
                            continue;
                        }
                        if ( $choosenAction != eZContentObject::PACKAGE_DELETE )
                        {
                            $installParameters['error'] = array( 'error_code' => eZContentObject::PACKAGE_ERROR_HAS_CHILDREN,
                                                                 'element_id' => $objectRemoteID,
                                                                 'description' => ezpI18n::tr( 'kernel/package',
                                                                                          "Object '%objectname' has %childrencount sub-item(s) that will be removed.",
                                                                                          false, array( '%objectname' => $name,
                                                                                                        '%childrencount' => $childrenCount ) ),
                                                                 'actions' => array( eZContentObject::PACKAGE_DELETE => ezpI18n::tr( 'kernel/package', "Remove object and its sub-item(s)" ),
                                                                                     eZContentObject::PACKAGE_KEEP => ezpI18n::tr( 'kernel/package', 'Keep object' ) ) );
                            return false;
                        }
                    }

                    eZContentObjectTreeNode::removeSubtrees( $assignedNodeIDArray, false );

                    //eZContentObjectOperations::remove( $object->attribute( 'id' ) );
                }
                else
                {
                    eZDebug::writeNotice( "Can't uninstall object '$name': object not found", __METHOD__ );
                }

                unset( $realObjectNode );
            }
        }
        return true;
    }
803067
public static function uninstall() {
		$cptp = CPTP::get_instance();

		foreach ( $cptp->modules as $module ) {
			$module->uninstall_hook();
		}
	}
1362096
def bin_remove(self):
        
        packages = self.args[1:]
        options = [
            "-r",
            "--removepkg"
        ]
        additional_options = [
            "--deps",
            "--check-deps",
            "--tag",
            "--checklist"
        ]
        flag, extra = "", []
        flags = [
            "-warn",
            "-preserve",
            "-copy",
            "-keep"
        ]
        # merge --check-deps and --deps options
        if (additional_options[1] in self.args and
                additional_options[0] not in self.args):
            self.args.append(additional_options[0])
        if len(self.args) > 1 and self.args[0] in options:
            for additional in additional_options:
                if additional in self.args:
                    extra.append(additional)
                    self.args.remove(additional)
                packages = self.args[1:]
            for fl in flags:
                if fl in self.args:
                    flag = self.args[1]
                    packages = self.args[2:]
            PackageManager(packages).remove(flag, extra)
        else:
            usage("")
925650
def filter_installed_packages(packages):
    """"""
    yb = yum.YumBase()
    package_list = yb.doPackageLists()
    temp_cache = {p.base_package_name: 1 for p in package_list['installed']}

    _pkgs = [p for p in packages if not temp_cache.get(p, False)]
    return _pkgs