comparison dogdish/dispatcher.py @ 7:65d0a1153864

a stub that sorta does something
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 16 Oct 2012 15:42:14 -0700
parents 0a7bf7e70888
children ebb65758d725
comparison
equal deleted inserted replaced
6:0a7bf7e70888 7:65d0a1153864
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 """ 3 """
4 dogdish 4 dogdish
5 https://bugzilla.mozilla.org/show_bug.cgi?id=800118
5 """ 6 """
6 7
7 import sys 8 import sys
8 from urlparse import urlparse 9 from urlparse import urlparse
9 from webob import Request 10 from webob import Request
32 class Get(Handler): 33 class Get(Handler):
33 34
34 body = """<?xml version="1.0"?> 35 body = """<?xml version="1.0"?>
35 <updates> 36 <updates>
36 <update type="minor" appVersion="19.0a1" version="19.0a1" extensionVersion="19.0a1" buildID="20121010114416" licenseURL="http://www.mozilla.com/test/sample-eula.html" detailsURL="http://www.mozilla.com/test/sample-details.html"> 37 <update type="minor" appVersion="19.0a1" version="19.0a1" extensionVersion="19.0a1" buildID="20121010114416" licenseURL="http://www.mozilla.com/test/sample-eula.html" detailsURL="http://www.mozilla.com/test/sample-details.html">
37 <patch type="complete" URL="http://update.boot2gecko.org/nightly/b2g_update_2012-10-10_114416.mar" hashFunction="SHA512" hashValue="84edb1f53891cf983bc0f6066d31492f43e2d063aaceb05e1c51876f4fde81635afeb7ce3203dee6f65dd59be0cae5c73c49093b625c99acd4118000ad72dda8" size="42924805"/> 38 <patch type="complete" URL="http://update.boot2gecko.org/nightly/b2g_update_2012-10-10_114416.mar%s" hashFunction="SHA512" hashValue="84edb1f53891cf983bc0f6066d31492f43e2d063aaceb05e1c51876f4fde81635afeb7ce3203dee6f65dd59be0cae5c73c49093b625c99acd4118000ad72dda8" size="42924805"/>
38 </update> 39 </update>
39 </updates>""" 40 </updates>"""
40 41
41 @classmethod 42 @classmethod
42 def match(cls, request): 43 def match(cls, request):
43 return request.method == 'GET' 44 return request.method == 'GET'
44 45
45 def __call__(self): 46 def __call__(self):
47 body = self.body
48 query = {}
49 dogfood_id = self.request.GET.get('dogfood_id')
50 if dogfood_id:
51 query['dogfood_id'] = dogfood_id
52
53 # build query string
54 if query:
55 query = '?' + '&'.join(['%s=%s' % (key, value) for key, value in query.items()])
56 else:
57 query = ''
58
46 return Response(content_type='text/xml', 59 return Response(content_type='text/xml',
47 body=self.body) 60 body=body % query)
48 61
49 class Dispatcher(object): 62 class Dispatcher(object):
50 63
51 ### class level variables 64 ### class level variables
52 defaults = {} 65 defaults = {}
81 help="port to serve on") 94 help="port to serve on")
82 options, args = parser.parse_args() 95 options, args = parser.parse_args()
83 96
84 app = Dispatcher() 97 app = Dispatcher()
85 98
99 print "http://localhost:%s/" % options.port
86 server = simple_server.make_server(host='0.0.0.0', port=options.port, app=app) 100 server = simple_server.make_server(host='0.0.0.0', port=options.port, app=app)
87 server.serve_forever() 101 server.serve_forever()
88 102
89 if __name__ == '__main__': 103 if __name__ == '__main__':
90 main() 104 main()