diff dogdish/dispatcher.py @ 12:234c2427e52b

beginnings of a scan function
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 17 Oct 2012 10:29:33 -0700
parents 5babc2ae6c27
children 71f9f68986b5
line wrap: on
line diff
--- a/dogdish/dispatcher.py	Wed Oct 17 10:18:28 2012 -0700
+++ b/dogdish/dispatcher.py	Wed Oct 17 10:29:33 2012 -0700
@@ -5,6 +5,7 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=800118
 """
 
+import fnmatch
 import os
 import sys
 from urlparse import urlparse
@@ -68,7 +69,7 @@
         query = {}
         dogfood_id = self.request.GET.get('dogfood_id')
         if dogfood_id:
-            query['dogfood_id'] = dogfood_id
+            query['dogfooding_prerelease_id'] = dogfood_id
 
         # build query string
         if query:
@@ -76,8 +77,11 @@
         else:
             query = ''
 
+        # template variables
+        variables = dict(query=query)
+
         return Response(content_type='text/xml',
-                        body=body % query)
+                        body=body % variables)
 
 class Dispatcher(object):
     """web application"""
@@ -113,8 +117,13 @@
 
     def scan(self):
         """scan the directory for updates"""
-        contents = os.listdir(self.directory)
-
+        contents = [i for i in os.listdir(self.directory)
+                    if i.startswith('b2g_update_') and i.endswith('.mar')]
+        contents = set(contents)
+        new = contents.difference(self.updates.keys())
+        if not new:
+            # directory contents unchanged from cached values
+            return
 
 def main(args=sys.argv[1:]):
     """CLI entry point"""