blob: ad6ece69b033a8a8d1718bc2f6c66f62dc2b1ad0 [file] [log] [blame]
[email protected]ded22402009-10-26 22:36:211# 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
5import autoupdate
[email protected]ded22402009-10-26 22:36:216import os
7import web
[email protected]4dc25812009-10-27 23:46:268import sys
[email protected]ded22402009-10-26 22:36:219
[email protected]21a5ca32009-11-04 18:23:2310global updater
11updater = None
[email protected]ded22402009-10-26 22:36:2112
[email protected]64244662009-11-12 00:52:0813global buildbot
14buildbot = None
15
[email protected]ded22402009-10-26 22:36:2116class index:
17 def GET(self):
[email protected]64244662009-11-12 00:52:0818 pkgs = buildbot.GetPackages()
[email protected]ded22402009-10-26 22:36:2119 return render.index(pkgs)
20
21class update:
22 """
23 Processes updates from the client machine. If an update is found, the url
24 references a static link that can be served automagically from web.py.
25 """
26 def POST(self):
[email protected]21a5ca32009-11-04 18:23:2327 return updater.HandleUpdatePing(web.data())
28
[email protected]64244662009-11-12 00:52:0829class build:
30 """
31 builds the package specified by the pkg parameter and returns the name
32 of the output file.
33 """
Ryan Cairnsdd1ceb82010-03-03 05:35:0134 def POST(self):
[email protected]64244662009-11-12 00:52:0835 input = web.input()
Ryan Cairnsdd1ceb82010-03-03 05:35:0136 web.debug("emerging %s " % 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)
[email protected]ded22402009-10-26 22:36:2141
[email protected]4dc25812009-10-27 23:46:2642if __name__ == "__main__":
[email protected]21a5ca32009-11-04 18:23:2343
44 root_dir = os.path.realpath("%s/../.." % os.path.dirname(os.path.abspath(sys.argv[0])))
[email protected]47660d82009-10-28 23:11:5145 static_dir = os.path.realpath("%s/static" % os.path.dirname(os.path.abspath(sys.argv[0])))
[email protected]21a5ca32009-11-04 18:23:2346 web.debug("dev root is %s" % root_dir)
[email protected]4dc25812009-10-27 23:46:2647 web.debug("Serving images from %s" % static_dir)
[email protected]ded22402009-10-26 22:36:2148 os.system("mkdir -p %s" % static_dir)
[email protected]21a5ca32009-11-04 18:23:2349
50 updater = autoupdate.Autoupdate(root_dir=root_dir, static_dir=static_dir)
51
52 urls = ('/', 'index',
[email protected]64244662009-11-12 00:52:0853 '/update', 'update',
54 '/webbuild', 'webbuild',
55 '/build', 'build')
56
[email protected]21a5ca32009-11-04 18:23:2357 app = web.application(urls, globals())
58 render = web.template.render('templates/')
59
[email protected]ded22402009-10-26 22:36:2160 app.run()