Exemplo n.º 1
0
def test_unlink_man_pages():
    try:
        link_dir = os.path.join(tc.STAGING, 'links')
        src = os.path.join(os.path.dirname(os.path.dirname(__file__)),
                           'pakit', 'extra')
        fake_man = os.path.join(src, 'test_man.1')

        try:
            os.makedirs(os.path.dirname(fake_man))
        except OSError:
            pass
        with open(fake_man, 'w') as fout:
            fout.write('hello')

        link_man_pages(link_dir)
        unlink_man_pages(link_dir)

        expected_man = os.path.join(link_dir, 'share', 'man', 'man1',
                                    os.path.basename(fake_man))
        assert not os.path.exists(expected_man)
        assert not os.path.exists(os.path.dirname(expected_man))
        assert os.path.isdir(link_dir)
    finally:
        tc.delete_it(fake_man)
        tc.delete_it(link_dir)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
def test_unlink_man_pages():
    try:
        link_dir = os.path.join(tc.STAGING, "links")
        src = os.path.join(os.path.dirname(os.path.dirname(__file__)), "pakit", "extra")
        fake_man = os.path.join(src, "test_man.1")

        try:
            os.makedirs(os.path.dirname(fake_man))
        except OSError:
            pass
        with open(fake_man, "w") as fout:
            fout.write("hello")

        link_man_pages(link_dir)
        unlink_man_pages(link_dir)

        expected_man = os.path.join(link_dir, "share", "man", "man1", os.path.basename(fake_man))
        assert not os.path.exists(expected_man)
        assert not os.path.exists(os.path.dirname(expected_man))
        assert os.path.isdir(link_dir)
    finally:
        tc.delete_it(fake_man)
        tc.delete_it(link_dir)