comparison 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
comparison
equal deleted inserted replaced
11:5babc2ae6c27 12:234c2427e52b
3 """ 3 """
4 dogdish 4 dogdish
5 https://bugzilla.mozilla.org/show_bug.cgi?id=800118 5 https://bugzilla.mozilla.org/show_bug.cgi?id=800118
6 """ 6 """
7 7
8 import fnmatch
8 import os 9 import os
9 import sys 10 import sys
10 from urlparse import urlparse 11 from urlparse import urlparse
11 from webob import Request 12 from webob import Request
12 from webob import Response, exc 13 from webob import Response, exc
66 def __call__(self): 67 def __call__(self):
67 body = self.body 68 body = self.body
68 query = {} 69 query = {}
69 dogfood_id = self.request.GET.get('dogfood_id') 70 dogfood_id = self.request.GET.get('dogfood_id')
70 if dogfood_id: 71 if dogfood_id:
71 query['dogfood_id'] = dogfood_id 72 query['dogfooding_prerelease_id'] = dogfood_id
72 73
73 # build query string 74 # build query string
74 if query: 75 if query:
75 query = '?' + '&'.join(['%s=%s' % (key, value) for key, value in query.items()]) 76 query = '?' + '&'.join(['%s=%s' % (key, value) for key, value in query.items()])
76 else: 77 else:
77 query = '' 78 query = ''
78 79
80 # template variables
81 variables = dict(query=query)
82
79 return Response(content_type='text/xml', 83 return Response(content_type='text/xml',
80 body=body % query) 84 body=body % variables)
81 85
82 class Dispatcher(object): 86 class Dispatcher(object):
83 """web application""" 87 """web application"""
84 88
85 89
111 res = handler() 115 res = handler()
112 return res(environ, start_response) 116 return res(environ, start_response)
113 117
114 def scan(self): 118 def scan(self):
115 """scan the directory for updates""" 119 """scan the directory for updates"""
116 contents = os.listdir(self.directory) 120 contents = [i for i in os.listdir(self.directory)
117 121 if i.startswith('b2g_update_') and i.endswith('.mar')]
122 contents = set(contents)
123 new = contents.difference(self.updates.keys())
124 if not new:
125 # directory contents unchanged from cached values
126 return
118 127
119 def main(args=sys.argv[1:]): 128 def main(args=sys.argv[1:]):
120 """CLI entry point""" 129 """CLI entry point"""
121 130
122 # imports for CLI 131 # imports for CLI