def __init__(self, frontend): ''' @param frontend: ''' transaction = YumexTransactionYum(self, frontend) YumexBackendBase.__init__(self, frontend, transaction) YumClient.__init__(self, frontend) self.dont_abort = False self.package_cache = PackageCache(self, frontend) self._running_as_root = True self.lock_is_progress_active = False
def search_prefix(self, prefix, show_newest_only, package_type, use_cache=True): ''' Search for packages with prefix @param prefix prefix to search for ''' pkgs = YumClient.search_prefix(self, prefix, show_newest_only, package_type) return self.package_cache.find_packages(pkgs)
def get_repositories(self): ''' get repositories @return: a list of repositories ''' repos = YumClient.get_repos(self) return repos
def setup(self, offline=False, repos=None, need_root=True): ''' Setup the backend''' if self.yum_backend_is_running: # Check if backend is already running if self._running_as_root == need_root or self._running_as_root: return self.debug('Restarting backend as root') self.reset() # stop the running backend self._close() # stop the running launcher process self._running_as_root = need_root or os.getuid()==0 self.frontend.info(_("Starting yum child process")) if repos: self.frontend.info(_("Using the following repositories :\n%s\n\n") % (','.join(repos))) plugins = self.frontend.settings.plugins yumdebuglevel = self.frontend.settings.yumdebuglevel proxy = self.frontend.settings.proxy.strip() yum_conf = self.frontend.settings.yum_conf filelog = False if 'show_backend' in self.frontend.debug_options: filelog = True self.debug('Initialize yum backend - BEGIN') rc = YumClient.setup(self, debuglevel=yumdebuglevel, plugins=plugins, filelog=filelog, offline=offline, repos=repos, proxy=proxy, yum_conf=yum_conf, need_root=need_root) self.debug('Initialize yum backend - END') return rc
def run_command(self, cmd, userlist, use_cache=True): ''' Search for packages with prefix @param prefix prefix to search for ''' pkgs = YumClient.run_command(self, cmd, userlist) self.frontend.get_progress().hide() return self.package_cache.find_packages(pkgs)
def get_groups(self): ''' get groups @return: a list of groups ''' self.frontend.debug('Getting Group information') grps = YumClient.get_groups(self) return grps
def get_packages_repo(self, repoid): ''' get packages based on repoid @param repoid: the repo id @return: a list of packages ''' pkgs = YumClient.get_packages_repo(self, repoid) return self.package_cache.find_packages(pkgs)
def get_packages_size(self, ndx): ''' get packages based on size ranges @param ndx: size range index @return: a list of packages ''' pkgs = YumClient.get_packages_size(self, ndx) return self.package_cache.find_packages(pkgs)
def search(self, keys, sch_filters, show_newest_only, package_type, use_cache=True ): ''' get packages matching keys @param keys: list of keys to search for @param sch_filters: list of search filter (Enum SEARCH) ''' self.frontend.debug('Seaching for %s in %s (%s)' % (keys, sch_filters, package_type)) pkgs = YumClient.search(self, keys, sch_filters, show_newest_only, package_type) return self.package_cache.find_packages(pkgs)
def get_group_packages(self, group, grp_filter=None): ''' get packages in a group @param group: group id to get packages from @param grp_filter: group filters (Enum GROUP) ''' self.frontend.debug('Getting packages in group : %s (FILTER = %s)' % (group, grp_filter)) pkgs = YumClient.get_group_packages(self, group, grp_filter) return self.package_cache.find_packages(pkgs)
def enable_repository(self, repoid, enabled=True): ''' set repository enable state @param repoid: repo id to change @param enabled: repo enable state ''' self.frontend.debug('Setting repository %s (Enabled = %s)' % (repoid, enabled)) repo = YumClient.enable_repo(self, repoid, enabled) return repo
def get_dependencies(self, po): reqs = YumClient.get_dependencies(self, po) rc = {} for req_tup, po in reqs: req = prco_tuple_to_string(req_tup) cpo = self.package_cache._add(po) if req in rc: rc[req].append(cpo) else: rc[req] = [cpo] return rc
def get_packages(self, pkg_filter, show_dupes=False, disable_cache=False): ''' get packages based on filter @param pkg_filer: package list filter @return: a list of packages ''' if str(pkg_filter) == 'all': filters = ['installed', 'available'] else: filters = [pkg_filter] rc = [] # Getting the packages for flt in filters: if not self.package_cache.is_populated(pkg_filter) or disable_cache: pkgs = YumClient.get_packages(self, flt, show_dupes, disable_cache) self.debug('got %i packages from yum backend' % (len(pkgs))) self.package_cache.populate(flt, pkgs) else: pkgs = self.package_cache._get_packages(pkg_filter) self.debug('got %i packages from cache' % (len(pkgs))) rc.extend(pkgs) self.info(_("%i packages returned") % len(rc)) return rc
def get_available_downgrades(self, po): pkgs = YumClient.get_available_downgrades(self, po) return self.package_cache.find_packages(pkgs)
def get_available_by_name(self, name): pkgs = YumClient.get_available_by_name(self, name) return self.package_cache.find_packages(pkgs)
def reset(self): ''' Reset the backend, so it can be setup again''' self.package_cache.reset() rc = YumClient.reset(self) if rc: self.frontend.info(_("yum backend process is ended"))