| 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 _ 283024232 # is the list of repos changed? 33 cached = self.Cacher.pop(etpCache['repolist']) 34 if cached == None: 35 # invalidate matching cache 36 try: 37 self.repository_move_clear_cache() 38 except IOError: 39 pass 40 elif isinstance(cached,tuple): 41 difflist = [x for x in cached if x not in \ 42 self.SystemSettings['repositories']['order']] 43 for repoid in difflist: 44 try: self.repository_move_clear_cache(repoid) 45 except IOError: pass 46 self.store_repository_list_cache()4749 self.Cacher.push(etpCache['repolist'], 50 tuple(self.SystemSettings['repositories']['order']), 51 async = False)5253 - def generate_cache(self, depcache = True, configcache = True, 54 client_purge = True, install_queue = True):55 56 # clean first of all 57 self.purge_cache(client_purge = client_purge) 58 if depcache: 59 self.do_depcache(do_install_queue = install_queue) 60 if configcache: 61 self.do_configcache()6264 self.updateProgress( 65 darkred(_("Configuration files")), 66 importance = 2, 67 type = "warning" 68 ) 69 self.updateProgress( 70 red(_("Scanning hard disk")), 71 importance = 1, 72 type = "warning" 73 ) 74 self.FileUpdates.scanfs(dcache = False, quiet = True) 75 self.updateProgress( 76 darkred(_("Cache generation complete.")), 77 importance = 2, 78 type = "info" 79 )8082 83 self.updateProgress( 84 darkgreen(_("Resolving metadata")), 85 importance = 1, 86 type = "warning" 87 ) 88 # we can barely ignore any exception from here 89 # especially cases where client db does not exist 90 try: 91 update, remove, fine, spm_fine = self.calculate_world_updates() 92 del fine, spm_fine, remove 93 if do_install_queue: 94 self.get_install_queue(update, False, False) 95 self.calculate_available_packages() 96 except: 97 pass 98 99 self.updateProgress( 100 darkred(_("Dependencies cache filled.")), 101 importance = 2, 102 type = "warning" 103 )104106 if self.entropyTools.is_user_in_entropy_group(): 107 self.Cacher.stop() 108 try: 109 skip = set() 110 if not client_purge: 111 skip.add("/"+etpCache['dbMatch']+"/"+etpConst['clientdbid']) # it's ok this way 112 skip.add("/"+etpCache['dbSearch']+"/"+etpConst['clientdbid']) # it's ok this way 113 for key in etpCache: 114 if showProgress: 115 self.updateProgress( 116 darkred(_("Cleaning %s => dumps...")) % (etpCache[key],), 117 importance = 1, 118 type = "warning", 119 back = True 120 ) 121 self.clear_dump_cache(etpCache[key], skip = skip) 122 123 if showProgress: 124 self.updateProgress( 125 darkgreen(_("Cache is now empty.")), 126 importance = 2, 127 type = "info" 128 ) 129 finally: 130 self.Cacher.start()131 135137 if not self.UGC.is_repository_eapi3_aware(repository): 138 return None 139 status = True 140 141 votes_dict, err_msg = self.UGC.get_all_votes(repository) 142 if isinstance(votes_dict,dict): 143 self.UGC.UGCCache.save_vote_cache(repository, votes_dict) 144 else: 145 status = False 146 147 downloads_dict, err_msg = self.UGC.get_all_downloads(repository) 148 if isinstance(downloads_dict,dict): 149 self.UGC.UGCCache.save_downloads_cache(repository, downloads_dict) 150 else: 151 status = False 152 return status153155 return self.SystemSettings._clear_repository_cache(repoid = repoid)156158 # client digest not needed, cache is kept updated 159 return str(hash("%s|%s|%s" % ( 160 self.all_repositories_checksum(), 161 self.validRepositories, 162 # needed when users do bogus things like editing config files 163 # manually (branch setting) 164 self.SystemSettings['repositories']['branch'], 165 ) 166 ))167169 sum_hashes = '' 170 for repo in self.validRepositories: 171 try: 172 dbconn = self.open_repository(repo) 173 except (RepositoryError): 174 continue # repo not available 175 try: 176 sum_hashes += dbconn.database_checksum() 177 except self.dbapi2.OperationalError: 178 pass 179 return sum_hashes180182 if myhash == None: 183 myhash = self.get_available_packages_chash() 184 return self.Cacher.pop("%s%s" % (etpCache['world_available'], myhash))185187 188 misc_settings = self.SystemSettings[self.sys_settings_client_plugin_id]['misc'] 189 ignore_spm_downgrades = misc_settings['ignore_spm_downgrades'] 190 191 if self.xcache: 192 193 if db_digest == None: 194 db_digest = self.all_repositories_checksum() 195 196 c_hash = "%s%s" % (etpCache['world_update'], 197 self.get_world_update_cache_hash(db_digest, empty_deps, 198 ignore_spm_downgrades),) 199 200 disk_cache = self.Cacher.pop(c_hash) 201 if disk_cache != None: 202 try: 203 # workaround for old cache 204 if len(disk_cache['r']) == 4: 205 return disk_cache['r'] 206 except (KeyError, TypeError): 207 return None208211 212 return str(hash("%s|%s|%s|%s|%s|%s" % ( 213 db_digest, empty_deps, self.validRepositories, 214 self.SystemSettings['repositories']['order'], 215 ignore_spm_downgrades, 216 # needed when users do bogus things like editing config files 217 # manually (branch setting) 218 self.SystemSettings['repositories']['branch'], 219 )))220222 223 if self.xcache: 224 225 if db_digest == None: 226 db_digest = self.all_repositories_checksum() 227 228 c_hash = "%s%s" % (etpCache['critical_update'], 229 self.get_critical_update_cache_hash(db_digest),) 230 231 return self.Cacher.pop(c_hash)232234 235 return str(hash("%s|%s|%s|%s" % ( 236 db_digest, self.validRepositories, 237 self.SystemSettings['repositories']['order'], 238 # needed when users do bogus things like editing config files 239 # manually (branch setting) 240 self.SystemSettings['repositories']['branch'], 241 )))
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Jun 28 00:23:38 2009 | http://epydoc.sourceforge.net |