comparison dogdish/dispatcher.py @ 17:427a94428f04

have a different class for stable updates
author jhammel
date Fri, 26 Oct 2012 15:04:47 +0000
parents 31898fb3b7d9
children 6ffbad8cc31f
comparison
equal deleted inserted replaced
16:31898fb3b7d9 17:427a94428f04
74 if not self._hash: 74 if not self._hash:
75 # compute the hash 75 # compute the hash
76 with file(self.path) as f: 76 with file(self.path) as f:
77 self._hash = hashlib.sha512(f.read()).hexdigest() 77 self._hash = hashlib.sha512(f.read()).hexdigest()
78 return self._hash 78 return self._hash
79
80 class UpdateStable(Update):
81 prefix = 'b2g_stable_update_'
82
79 83
80 ### request handlers 84 ### request handlers
81 85
82 class Handler(object): 86 class Handler(object):
83 """abstract handler object for a request""" 87 """abstract handler object for a request"""
149 class Dispatcher(object): 153 class Dispatcher(object):
150 """web application""" 154 """web application"""
151 155
152 156
153 ### class level variables 157 ### class level variables
154 defaults = {'directory': here} 158 defaults = {'directory': here,
159 'update_class': Update}
155 160
156 def __init__(self, **kw): 161 def __init__(self, **kw):
157 162
158 # set defaults 163 # set defaults
159 for key in self.defaults: 164 for key in self.defaults:
188 scan the directory for updates 193 scan the directory for updates
189 returns True if new updates are found, False otherwise 194 returns True if new updates are found, False otherwise
190 """ 195 """
191 196
192 # check for new updates 197 # check for new updates
193 contents = Update.updates(self.directory) 198 contents = self.update_class.updates(self.directory)
194 new = contents.difference(self.updates.keys()) 199 new = contents.difference(self.updates.keys())
195 if not new: 200 if not new:
196 # directory contents unchanged from cached values 201 # directory contents unchanged from cached values
197 return False 202 return False
198 203
199 for update in new: 204 for update in new:
200 self.updates[update] = Update(self.directory, update) 205 self.updates[update] = self.update_class(self.directory, update)
201 if self.current_update: 206 if self.current_update:
202 if self.updates[update].stamp > self.current_update.stamp: 207 if self.updates[update].stamp > self.current_update.stamp:
203 self.current_update = self.updates[update] 208 self.current_update = self.updates[update]
204 else: 209 else:
205 self.current_update = self.updates[update] 210 self.current_update = self.updates[update]