| OLD | NEW |
| 1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import autoupdate | 5 import autoupdate |
| 6 import buildutil | |
| 7 import os | 6 import os |
| 8 import web | 7 import web |
| 9 import sys | 8 import sys |
| 10 | 9 |
| 11 global updater | 10 global updater |
| 12 updater = None | 11 updater = None |
| 13 | 12 |
| 14 global buildbot | 13 global buildbot |
| 15 buildbot = None | 14 buildbot = None |
| 16 | 15 |
| 17 class index: | 16 class index: |
| 18 def GET(self): | 17 def GET(self): |
| 19 pkgs = buildbot.GetPackages() | 18 pkgs = buildbot.GetPackages() |
| 20 return render.index(pkgs) | 19 return render.index(pkgs) |
| 21 | 20 |
| 22 class update: | 21 class update: |
| 23 """ | 22 """ |
| 24 Processes updates from the client machine. If an update is found, the url | 23 Processes updates from the client machine. If an update is found, the url |
| 25 references a static link that can be served automagically from web.py. | 24 references a static link that can be served automagically from web.py. |
| 26 """ | 25 """ |
| 27 def POST(self): | 26 def POST(self): |
| 28 return updater.HandleUpdatePing(web.data()) | 27 return updater.HandleUpdatePing(web.data()) |
| 29 | 28 |
| 30 class webbuild: | |
| 31 """ | |
| 32 builds the package specified by the pkg parameter. Then redirects to index | |
| 33 """ | |
| 34 def GET(self): | |
| 35 input = web.input() | |
| 36 web.debug("called %s " % input.pkg) | |
| 37 output = buildbot.BuildPackage(input.pkg) | |
| 38 web.debug("copied %s to static" % output) | |
| 39 raise web.seeother('/') | |
| 40 | |
| 41 class build: | 29 class build: |
| 42 """ | 30 """ |
| 43 builds the package specified by the pkg parameter and returns the name | 31 builds the package specified by the pkg parameter and returns the name |
| 44 of the output file. | 32 of the output file. |
| 45 """ | 33 """ |
| 46 def GET(self): | 34 def POST(self): |
| 47 input = web.input() | 35 input = web.input() |
| 48 web.debug("called %s " % input.pkg) | 36 web.debug("emerging %s " % input.pkg) |
| 49 return buildbot.BuildPackage(input.pkg) | 37 emerge_command = "emerge-%s %s" % (input.board, input.pkg) |
| 38 err = os.system(emerge_command) |
| 39 if err != 0: |
| 40 raise Exception("failed to execute %s" % emerge_command) |
| 50 | 41 |
| 51 if __name__ == "__main__": | 42 if __name__ == "__main__": |
| 52 | 43 |
| 53 root_dir = os.path.realpath("%s/../.." % os.path.dirname(os.path.abspath(sys.a
rgv[0]))) | 44 root_dir = os.path.realpath("%s/../.." % os.path.dirname(os.path.abspath(sys.a
rgv[0]))) |
| 54 static_dir = os.path.realpath("%s/static" % os.path.dirname(os.path.abspath(sy
s.argv[0]))) | 45 static_dir = os.path.realpath("%s/static" % os.path.dirname(os.path.abspath(sy
s.argv[0]))) |
| 55 web.debug("dev root is %s" % root_dir) | 46 web.debug("dev root is %s" % root_dir) |
| 56 web.debug("Serving images from %s" % static_dir) | 47 web.debug("Serving images from %s" % static_dir) |
| 57 os.system("mkdir -p %s" % static_dir) | 48 os.system("mkdir -p %s" % static_dir) |
| 58 | 49 |
| 59 updater = autoupdate.Autoupdate(root_dir=root_dir, static_dir=static_dir) | 50 updater = autoupdate.Autoupdate(root_dir=root_dir, static_dir=static_dir) |
| 60 buildbot = buildutil.BuildUtil(root_dir=root_dir, static_dir=static_dir) | |
| 61 | 51 |
| 62 urls = ('/', 'index', | 52 urls = ('/', 'index', |
| 63 '/update', 'update', | 53 '/update', 'update', |
| 64 '/webbuild', 'webbuild', | 54 '/webbuild', 'webbuild', |
| 65 '/build', 'build') | 55 '/build', 'build') |
| 66 | 56 |
| 67 app = web.application(urls, globals()) | 57 app = web.application(urls, globals()) |
| 68 render = web.template.render('templates/') | 58 render = web.template.render('templates/') |
| 69 | 59 |
| 70 app.run() | 60 app.run() |
| OLD | NEW |