| Home | Trees | Indices | Help |
|
|---|
|
|
1 # -*- coding: utf-8 -*- 2 ''' 3 # DESCRIPTION: 4 # Entropy Object Oriented Interface 5 6 Copyright (C) 2007-2009 Fabio Erculiani 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 ''' 22 from __future__ import with_statement 23 import os 24 from entropy.const import * 25 from entropy.exceptions import * 26 from entropy.output import red, darkred, darkgreen 27 from entropy.i18n import _ 283023132 # is the list of repos changed? 33 cached = self.Cacher.pop(etpCache['repolist']) 34 if cached != self.SystemSettings['repositories']['order']: 35 # invalidate matching cache 36 try: 37 self.repository_move_clear_cache() 38 except IOError: 39 pass 40 self.store_repository_list_cache()4143 self.Cacher.push(etpCache['repolist'], 44 self.SystemSettings['repositories']['order'], 45 async = False)4647 - def generate_cache(self, depcache = True, configcache = True, 48 client_purge = True, install_queue = True):49 50 # clean first of all 51 self.purge_cache(client_purge = client_purge) 52 if depcache: 53 self.do_depcache(do_install_queue = install_queue) 54 if configcache: 55 self.do_configcache()5658 self.updateProgress( 59 darkred(_("Configuration files")), 60 importance = 2, 61 type = "warning" 62 ) 63 self.updateProgress( 64 red(_("Scanning hard disk")), 65 importance = 1, 66 type = "warning" 67 ) 68 self.FileUpdates.scanfs(dcache = False, quiet = True) 69 self.updateProgress( 70 darkred(_("Cache generation complete.")), 71 importance = 2, 72 type = "info" 73 )7476 77 self.updateProgress( 78 darkgreen(_("Resolving metadata")), 79 importance = 1, 80 type = "warning" 81 ) 82 # we can barely ignore any exception from here 83 # especially cases where client db does not exist 84 try: 85 update, remove, fine, spm_fine = self.calculate_world_updates() 86 del fine, spm_fine, remove 87 if do_install_queue: 88 self.get_install_queue(update, False, False) 89 self.calculate_available_packages() 90 except: # except SystemDatabaseError @ calculate_world_updates 91 pass 92 93 self.updateProgress( 94 darkred(_("Dependencies cache filled.")), 95 importance = 2, 96 type = "warning" 97 )98100 if self.entropyTools.is_user_in_entropy_group(): 101 self.Cacher.stop() 102 try: 103 skip = set() 104 if not client_purge: 105 skip.add("/"+etpCache['dbMatch']+"/"+etpConst['clientdbid']) # it's ok this way 106 skip.add("/"+etpCache['dbSearch']+"/"+etpConst['clientdbid']) # it's ok this way 107 for key in etpCache: 108 if showProgress: 109 self.updateProgress( 110 darkred(_("Cleaning %s => dumps...")) % (etpCache[key],), 111 importance = 1, 112 type = "warning", 113 back = True 114 ) 115 self.clear_dump_cache(etpCache[key], skip = skip) 116 117 if showProgress: 118 self.updateProgress( 119 darkgreen(_("Cache is now empty.")), 120 importance = 2, 121 type = "info" 122 ) 123 finally: 124 self.Cacher.start()125 129131 if not self.UGC.is_repository_eapi3_aware(repository): 132 return None 133 status = True 134 135 votes_dict, err_msg = self.UGC.get_all_votes(repository) 136 if isinstance(votes_dict,dict): 137 self.UGC.UGCCache.save_vote_cache(repository, votes_dict) 138 else: 139 status = False 140 141 downloads_dict, err_msg = self.UGC.get_all_downloads(repository) 142 if isinstance(downloads_dict,dict): 143 self.UGC.UGCCache.save_downloads_cache(repository, downloads_dict) 144 else: 145 status = False 146 return status147149 return self.SystemSettings._clear_repository_cache(repoid = repoid)150152 # client digest not needed, cache is kept updated 153 return str(hash("%s|%s|%s" % ( 154 self.all_repositories_checksum(), 155 self.validRepositories, 156 # needed when users do bogus things like editing config files 157 # manually (branch setting) 158 self.SystemSettings['repositories']['branch'], 159 ) 160 ))161163 sum_hashes = '' 164 for repo in self.validRepositories: 165 try: 166 dbconn = self.open_repository(repo) 167 except (RepositoryError): 168 continue # repo not available 169 try: 170 sum_hashes += dbconn.database_checksum() 171 except self.dbapi2.OperationalError: 172 pass 173 return sum_hashes174176 if myhash == None: 177 myhash = self.get_available_packages_chash() 178 return self.Cacher.pop("%s%s" % (etpCache['world_available'], myhash))179181 182 misc_settings = self.SystemSettings[self.sys_settings_client_plugin_id]['misc'] 183 ignore_spm_downgrades = misc_settings['ignore_spm_downgrades'] 184 185 if self.xcache: 186 187 if db_digest == None: 188 db_digest = self.all_repositories_checksum() 189 190 c_hash = "%s%s" % (etpCache['world_update'], 191 self.get_world_update_cache_hash(db_digest, empty_deps, 192 ignore_spm_downgrades),) 193 194 disk_cache = self.Cacher.pop(c_hash) 195 if isinstance(disk_cache, tuple): 196 return disk_cache197200 201 return str(hash("%s|%s|%s|%s|%s|%s" % ( 202 db_digest, empty_deps, self.validRepositories, 203 self.SystemSettings['repositories']['order'], 204 ignore_spm_downgrades, 205 # needed when users do bogus things like editing config files 206 # manually (branch setting) 207 self.SystemSettings['repositories']['branch'], 208 )))209211 212 if self.xcache: 213 214 if db_digest == None: 215 db_digest = self.all_repositories_checksum() 216 217 c_hash = "%s%s" % (etpCache['critical_update'], 218 self.get_critical_update_cache_hash(db_digest),) 219 220 return self.Cacher.pop(c_hash)221223 224 return str(hash("%s|%s|%s|%s" % ( 225 db_digest, self.validRepositories, 226 self.SystemSettings['repositories']['order'], 227 # needed when users do bogus things like editing config files 228 # manually (branch setting) 229 self.SystemSettings['repositories']['branch'], 230 )))
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Aug 5 16:59:09 2009 | http://epydoc.sourceforge.net |