예제 #1
0
파일: task.py 프로젝트: starcraftman/pakit
    def run(self):
        """
        Execute a set of operations to perform the Task.
        """
        logging.debug('Relinking All Programs')

        dst = pakit.conf.CONFIG.path_to('link')
        walk_and_unlink_all(dst, pakit.conf.CONFIG.path_to('prefix'))

        for _, recipe in pakit.recipe.RDB:
            walk_and_link(recipe.install_dir, dst)
예제 #2
0
파일: test_shell.py 프로젝트: kostyll/pakit
    def test_walk_and_unlink_all(self):
        walk_and_link(self.src, self.dst)

        not_link = os.path.join(self.dst, "notlink")
        with open(not_link, "w") as fout:
            fout.write("Hello")

        walk_and_unlink_all(self.dst, self.src)
        assert os.path.exists(not_link)
        for fname in self.dst_fnames:
            assert not os.path.exists(fname)
        assert not os.path.exists(self.subdir.replace(self.src, self.dst))
        for fname in self.fnames:
            assert os.path.exists(fname)
        assert os.path.exists(self.dst)
예제 #3
0
파일: task.py 프로젝트: starcraftman/pakit
    def run(self):
        """
        Execute a set of operations to perform the Task.
        """
        msg = """Remove most traces of pakit. You are warned!

        Will delete ...
        - all links from the link directory to pakit's programs.
        - all programs pakit built, including the source trees.
        - all downloaded recipes.
        - all logs and configs EXCEPT the pakit.yml file.
        OK? y/n  """
        if user_input(msg).strip().lower()[0] != 'y':
            USER.info('Aborted.')
            return

        USER.info('Removing all links made by pakit.')
        config = pakit.conf.CONFIG
        unlink_man_pages(config.path_to('link'))
        walk_and_unlink_all(config.path_to('link'), config.path_to('prefix'))

        uris_file = os.path.join(config.path_to('recipes'), 'uris.yml')
        ruri_db = pakit.conf.RecipeURIDB(uris_file)
        to_remove = [config.path_to('prefix'),
                     config.path_to('source'),
                     uris_file]
        to_remove += [ruri_db[uri]['path'] for uri in ruri_db
                      if ruri_db[uri]['is_vcs']]
        to_remove += glob.glob(config.get('pakit.log.file') + '*')

        for path in to_remove:
            try:
                USER.info('Deleting: %s', path)
                if os.path.isdir(path):
                    shutil.rmtree(path)
                else:
                    os.remove(path)
            except OSError:
                logging.error('Could not delete path: %s', path)