def __dump_search_completion_info(self, completion_list): cache_dir = self.__get_cache_dir() if not cache_dir: return texts = [] for text in completion_list: txt = {} txt["text"] = text[0] texts.append(txt) try: nongui_misc.dump_cache_file( os.path.join(cache_dir, ".__search__completion.cpl"), texts) except IOError: return
def __dump_updates_available(self, stuff_to_do): cache_dir = nongui_misc.get_cache_dir(self.api_obj) if not cache_dir: return publisher_list = {} for p in self.api_obj.get_publishers(): if p.disabled: continue publisher_list[p.prefix] = p.last_refreshed n_installs = 0 n_removes = 0 n_updates = 0 plan_desc = self.api_obj.describe() if plan_desc: plan = plan_desc.get_changes() for pkg_plan in plan: orig = pkg_plan[0] dest = pkg_plan[1] if orig and dest: n_updates += 1 elif not orig and dest: n_installs += 1 elif orig and not dest: n_removes += 1 dump_info = {} dump_info["version"] = CACHE_VERSION dump_info["os_release"] = os.uname()[2] dump_info["os_version"] = os.uname()[3] dump_info["updates_available"] = stuff_to_do dump_info["publishers"] = publisher_list dump_info["updates"] = n_updates dump_info["installs"] = n_installs dump_info["removes"] = n_removes try: nongui_misc.dump_cache_file( os.path.join(cache_dir, CACHE_NAME + '.cpl'), dump_info) except IOError, e: err = str(e) if debug: print >> sys.stderr, "Failed to dump cache: %s" % err logger.error(err)
def __dump_categories_expanded_dict(self, cat_exp_dict): #CED entry: {('opensolaris.org', (6,)): True} cache_dir = self.__get_cache_dir() if not cache_dir: return catexs = [] for key, val in cat_exp_dict.iteritems(): if not val: continue name, path = key path1 = -1 if len(path) > 0: path1 = path[0] catex = {} catex["name"] = name catex["path1"] = path1 catexs.append(catex) nongui_misc.dump_cache_file(os.path.join(cache_dir, "pm_cat_exp.cpl"), catexs)
def __dump_categories_active_dict(self, cat_ac_dict): cache_dir = self.__get_cache_dir() if not cache_dir: return catacs = [] for name, path in cat_ac_dict.iteritems(): path1 = -1 path2 = -1 if len(path) == 1: path1 = path[0] elif len(path) > 1: path1 = path[0] path2 = path[1] catac = {} catac["name"] = name catac["path1"] = path1 catac["path2"] = path2 catacs.append(catac) nongui_misc.dump_cache_file(os.path.join(cache_dir, "pm_cat_ac.cpl"), catacs)
def __dump_categories_expanded_dict(self, cat_exp_dict): #CED entry: {('opensolaris.org', (6,)): True} cache_dir = self.__get_cache_dir() if not cache_dir: return catexs = [] for key, val in cat_exp_dict.iteritems(): if not val: continue name, path = key path1 = -1 if len(path) > 0: path1 = path[0] catex = {} catex["name"] = name catex["path1"] = path1 catexs.append(catex) nongui_misc.dump_cache_file( os.path.join(cache_dir, "pm_cat_exp.cpl"), catexs)
def __dump_updates_available(self, stuff_to_do): """Record update information to the cache file.""" cache_dir = nongui_misc.get_cache_dir(self.api_obj) if not cache_dir: return publisher_list = {} for p in self.api_obj.get_publishers(): if p.disabled: continue publisher_list[p.prefix] = p.last_refreshed n_installs = 0 n_removes = 0 n_updates = 0 plan_desc = self.api_obj.describe() if plan_desc: plan = plan_desc.get_changes() for (orig, dest) in plan: if orig and dest: n_updates += 1 elif not orig and dest: n_installs += 1 elif orig and not dest: n_removes += 1 dump_info = {} dump_info["version"] = CACHE_VERSION # Non-portable API used; pylint: disable=E0901 dump_info["os_release"] = os.uname()[2] dump_info["os_version"] = os.uname()[3] dump_info["updates_available"] = stuff_to_do dump_info["publishers"] = publisher_list dump_info["updates"] = n_updates dump_info["installs"] = n_installs dump_info["removes"] = n_removes try: nongui_misc.dump_cache_file(os.path.join( cache_dir, CACHE_NAME + '.cpl'), dump_info) except IOError, e: logger.error("Failed to dump cache: %s" % e)
def __dump_categories_active_dict(self, cat_ac_dict): cache_dir = self.__get_cache_dir() if not cache_dir: return catacs = [] for name, path in cat_ac_dict.iteritems(): path1 = -1 path2 = -1 if len(path) == 1: path1 = path[0] elif len(path) > 1: path1 = path[0] path2 = path[1] catac = {} catac["name"] = name catac["path1"] = path1 catac["path2"] = path2 catacs.append(catac) nongui_misc.dump_cache_file( os.path.join(cache_dir, "pm_cat_ac.cpl"), catacs)