Mercurial > mozilla > hg > dogfood
diff dogdish/dispatcher.py @ 13:71f9f68986b5
directory scanning + caching
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 17 Oct 2012 10:56:38 -0700 |
parents | 234c2427e52b |
children | cffb6f681b59 |
line wrap: on
line diff
--- a/dogdish/dispatcher.py Wed Oct 17 10:29:33 2012 -0700 +++ b/dogdish/dispatcher.py Wed Oct 17 10:56:38 2012 -0700 @@ -98,6 +98,7 @@ self.handlers = [ Get ] self.updates = {} self.current_update = None + self.current_stamp = '0000-00-00_000000' # scan directory self.scan() @@ -117,14 +118,26 @@ def scan(self): """scan the directory for updates""" + prefix = 'b2g_update_' + suffix = '.mar' contents = [i for i in os.listdir(self.directory) - if i.startswith('b2g_update_') and i.endswith('.mar')] + if i.startswith(prefix) and i.endswith(suffix)] contents = set(contents) new = contents.difference(self.updates.keys()) if not new: # directory contents unchanged from cached values return + for update in new: + stamp = update[len(prefix):-len(suffix)] + application_ini = 'application_%s.ini' % stamp + application_ini = os.path.join(self.directory, application_ini) + assert os.path.exists(application_ini) + self.updates[update] = Application(application_ini) + if stamp > self.current_stamp: + self.current_update = update + self.current_stamp = stamp + def main(args=sys.argv[1:]): """CLI entry point"""