rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame^] | 1 | # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import autoupdate |
| 6 | import buildutil |
| 7 | import os |
| 8 | import web |
| 9 | |
| 10 | app_id = "87efface-864d-49a5-9bb3-4b050a7c227a" |
| 11 | root_dir = "/usr/local/google/home/rtc/chromeos/trunk/src" |
| 12 | scripts_dir = "%s/scripts" % root_dir |
| 13 | app_dir = os.popen("pwd").read().strip() |
| 14 | static_dir = "%s/static" % app_dir |
| 15 | web.debug("Serving images from %s/static" % app_dir) |
| 16 | |
| 17 | urls = ('/', 'index', |
| 18 | '/update', 'update') |
| 19 | |
| 20 | app = web.application(urls, globals()) |
| 21 | render = web.template.render('templates/') |
| 22 | |
| 23 | |
| 24 | class index: |
| 25 | def GET(self): |
| 26 | pkgs = buildutil.GetPackages() |
| 27 | return render.index(pkgs) |
| 28 | |
| 29 | class update: |
| 30 | """ |
| 31 | Processes updates from the client machine. If an update is found, the url |
| 32 | references a static link that can be served automagically from web.py. |
| 33 | """ |
| 34 | def POST(self): |
| 35 | return autoupdate.HandleUpdatePing(web.data()) |
| 36 | |
| 37 | if __name__ == "__main__": |
| 38 | web.debug("Setting up the static repo") |
| 39 | os.system("mkdir -p %s" % static_dir) |
| 40 | app.run() |
| 41 | |