def run(self): """ Execute a set of operations to perform the Task. """ entry = pakit.conf.IDB.get(self.recipe.name, None) if entry: msg = '{name}: Already Installed{nl}Repo: {repo}' msg += '{nl}Hash: {hash}{nl}Date: {date}' msg = msg.format(name=self.recipe.name, repo=entry['repo'], hash=entry['hash'], date=entry['date'], nl=PREFIX) logging.debug(msg) print(msg) return try: USER.info('%s: Downloading: %s', self.recipe.name, str(self.recipe.repo)) with self.recipe.repo: USER.info('%s: Building Source', self.recipe.name) self.recipe.build() USER.info('%s: Symlinking Program', self.recipe.name) walk_and_link(self.recipe.install_dir, self.recipe.link_dir) USER.info('%s: Verifying Program', self.recipe.name) self.recipe.verify() pakit.conf.IDB.add(self.recipe) except Exception as exc: # pylint: disable=broad-except self.rollback(exc) raise
def restore_old_install(self): """ The update failed, reverse the actions of save_old_install. """ USER.info('%s: Restoring Old Install', self.recipe.name) shutil.move(self.back_dir, self.recipe.install_dir) pakit.conf.IDB[self.recipe.name] = self.old_entry walk_and_link(self.recipe.install_dir, self.recipe.link_dir)
def test_walk_and_unlink(self): walk_and_link(self.src, self.dst) walk_and_unlink(self.src, self.dst) 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)
def test_walk_and_unlink_mkdirs(self): link_file = os.path.join(self.dst, "NotSymLink") with open(link_file, "w") as fout: fout.write("Hello") assert os.path.exists(link_file) walk_and_link(self.src, self.dst) walk_and_unlink(self.src, self.dst) assert os.path.exists(self.dst) assert os.path.exists(link_file)
def test_walk_and_unlink_mkdirs(self): link_file = os.path.join(self.dst, 'NotSymLink') with open(link_file, 'w') as fout: fout.write('Hello') assert os.path.exists(link_file) walk_and_link(self.src, self.dst) walk_and_unlink(self.src, self.dst) assert os.path.exists(self.dst) assert os.path.exists(link_file)
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)
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)
def test_walk_and_link_raises(self): walk_and_link(self.src, self.dst) with pytest.raises(PakitLinkError): walk_and_link(self.src, self.dst)
def test_walk_and_link_works(self): walk_and_link(self.src, self.dst) for fname in self.dst_fnames: assert os.path.islink(fname) assert os.readlink(fname) == fname.replace(self.dst, self.src)