コード例 #1
0
    def remove(self, auto_confirm=False):
        """Remove paths in ``self.paths`` with confirmation (unless
        ``auto_confirm`` is True)."""
        if not self._can_uninstall():
            return
        if not self.paths:
            logger.notify("Can't uninstall '%s'. No files were found to uninstall." % self.dist.project_name)
            return
        logger.notify("Uninstalling %s:" % self.dist.project_name)
        logger.indent += 2
        paths = sorted(self.compact(self.paths))
        try:
            if auto_confirm:
                response = "y"
            else:
                for path in paths:
                    logger.notify(path)
                response = ask("Proceed (y/n)? ", ("y", "n"))
            if self._refuse:
                logger.notify("Not removing or modifying (outside of prefix):")
                for path in self.compact(self._refuse):
                    logger.notify(path)
            if response == "y":
                self.save_dir = tempfile.mkdtemp(suffix="-uninstall", prefix="pip-")
                for path in paths:
                    new_path = self._stash(path)
                    logger.info("Removing file or directory %s" % path)
                    self._moved_paths.append(path)
                    renames(path, new_path)
                for pth in self.pth.values():
                    pth.remove()
                logger.notify("Successfully uninstalled %s" % self.dist.project_name)

        finally:
            logger.indent -= 2
コード例 #2
0
 def rollback(self):
     """Rollback the changes previously made by remove()."""
     if self.save_dir is None:
         logger.error("Can't roll back %s; was not uninstalled" % self.dist.project_name)
         return False
     logger.notify("Rolling back uninstall of %s" % self.dist.project_name)
     for path in self._moved_paths:
         tmp_path = self._stash(path)
         logger.info("Replacing %s" % path)
         renames(tmp_path, path)
     for pth in self.pth:
         pth.rollback()
コード例 #3
0
 def rollback(self):
     """Rollback the changes previously made by remove()."""
     if self.save_dir is None:
         logger.error("Can't roll back %s; was not uninstalled" %
                      self.dist.project_name)
         return False
     logger.notify('Rolling back uninstall of %s' % self.dist.project_name)
     for path in self._moved_paths:
         tmp_path = self._stash(path)
         logger.info('Replacing %s' % path)
         renames(tmp_path, path)
     for pth in self.pth.values():
         pth.rollback()
コード例 #4
0
    def remove(self, auto_confirm=False):
        """Remove paths in ``self.paths`` with confirmation (unless
        ``auto_confirm`` is True)."""
        if not self._can_uninstall():
            return
        if not self.paths:
            logger.notify(
                "Can't uninstall '%s'. No files were found to uninstall." %
                self.dist.project_name)
            return
        logger.notify('Uninstalling %s:' % self.dist.project_name)
        logger.indent += 2
        paths = sorted(self.compact(self.paths))
        try:
            if auto_confirm:
                response = 'y'
            else:
                for path in paths:
                    logger.notify(path)
                response = ask('Proceed (y/n)? ', ('y', 'n'))
            if self._refuse:
                logger.notify('Not removing or modifying (outside of prefix):')
                for path in self.compact(self._refuse):
                    logger.notify(path)
            if response == 'y':
                self.save_dir = tempfile.mkdtemp(suffix='-uninstall',
                                                 prefix='pip-')
                for path in paths:
                    new_path = self._stash(path)
                    logger.info('Removing file or directory %s' % path)
                    self._moved_paths.append(path)
                    renames(path, new_path)
                for pth in self.pth.values():
                    pth.remove()
                logger.notify('Successfully uninstalled %s' %
                              self.dist.project_name)

        finally:
            logger.indent -= 2