def _operation(self, job, install, remove): if install: try: pacman.refresh() prereqs = pacman.needs_for(install) upgr = (x["id"] for x in pacman.get_installed() if x.get("upgradable")) if sorted(upgr) == sorted(install): # Upgrade msg = "Performing system upgrade..." msg = Notification("info", "Packages", msg) nthread = NotificationThread(id=job.id, message=msg) pacman.upgrade() else: # Install title = "Installing {0} package(s)".format(len(prereqs)) msg = Notification("info", "Packages", ", ".join(prereqs)) nthread = NotificationThread(id=job.id, title=title, message=msg) pacman.install(install) for x in prereqs: try: info = process_info(pacman.get_info(x)) if "installed" not in info: info["installed"] = True push_record("package", info) except: pass except Exception as e: nthread.complete(Notification("error", "Packages", str(e))) return if remove: try: prereqs = pacman.depends_for(remove) title = "Removing {0} package(s)".format(len(prereqs)) msg = Notification("info", "Packages", ", ".join(prereqs)) nthread = NotificationThread(id=job.id, title=title, message=msg) pacman.remove(remove) for x in prereqs: try: info = process_info(pacman.get_info(x)) if "installed" not in info: info["installed"] = False push_record("package", info) except: pass except Exception as e: nthread.complete(Notification("error", "Packages", str(e))) return msg = "Operations completed successfully" nthread.complete(Notification("success", "Packages", msg))
def _get_package_info(self): """Get the needed package information.""" is_available = False for pcm_info in packages_in_offical_repositories: if pcm_info['id'] == self.name: is_available = True break if is_available: pkg_info = pacman.get_info(self.name) self.version = pkg_info['Version'] self.architecture = pkg_info['Architecture'] if 'Repository' in pkg_info: if pkg_info['Repository'] == PackageRepository.EXTRA: self.repository = PackageRepository.EXTRA elif pkg_info['Repository'] == PackageRepository.CORE: self.repository = PackageRepository.CORE elif pkg_info['Repository'] == PackageRepository.COMMUNITY: self.repository = PackageRepository.COMMUNITY elif pkg_info['Repository'] == PackageRepository.MULTILIB: self.repository = PackageRepository.MULTILIB else: self.repository = PackageRepository.EXTRA self.dependencies = pkg_info['Depends On'].split(' ') self.license = pkg_info['Licenses'] else: raise NoSuchPackageError( "No package with the name '{0}' exists in the official repositories".format(self.name))
def _get_package_info(self): """Get the needed package information.""" is_available = False for pcm_info in packages_in_offical_repositories: if pcm_info['id'] == self.name: is_available = True break if is_available: pkg_info = pacman.get_info(self.name) self.version = pkg_info['Version'] self.architecture = pkg_info['Architecture'] if 'Repository' in pkg_info: if pkg_info['Repository'] == PackageRepository.EXTRA: self.repository = PackageRepository.EXTRA elif pkg_info['Repository'] == PackageRepository.CORE: self.repository = PackageRepository.CORE elif pkg_info['Repository'] == PackageRepository.COMMUNITY: self.repository = PackageRepository.COMMUNITY elif pkg_info['Repository'] == PackageRepository.MULTILIB: self.repository = PackageRepository.MULTILIB else: self.repository = PackageRepository.EXTRA self.dependencies = pkg_info['Depends On'].split(' ') self.license = pkg_info['Licenses'] else: raise NoSuchPackageError( "No package with the name '{0}' exists in the official repositories" .format(self.name))
def get(self, id): if id: try: info = process_info(pacman.get_info(id)) return jsonify(package=info) except: abort(404) else: return jsonify(packages=pacman.get_all())
def get_installation_status(self): """Get the installation status of the package.""" if pacman.is_installed(self.name): pcm_info = pacman.get_info(self.name) if pcm_info['Version'] == self.version: self.installation_status = 1 else: self.installation_status = 2 else: self.installation_status = 0
def get(self, id): if request.args.get("refresh", False): pacman.refresh() if id: try: info = process_info(pacman.get_info(id)) return jsonify(package=info) except: abort(404) else: return jsonify(packages=pacman.get_all())
def _operation(self, install, remove): message = Message() if install: try: pacman.refresh() prereqs = pacman.needs_for(install) message.update("info", "Installing %s package(s): %s" % (len(prereqs), ', '.join(prereqs))) pacman.install(install) for x in prereqs: try: info = process_info(pacman.get_info(x)) if not "installed" in info: info["installed"] = True push_record("package", info) except: pass except Exception, e: message.complete("error", str(e)) return
def get_info(): package = request.get_json(force=True)['package'] return jsonify(pacman.get_info(package))