[llvm-commits] [zorg] r125904 - in /zorg/trunk/llvmlab/llvmlab: ci/status.py llvmlabtool/lab.cfg.sample llvmlabtool/main.py ui/app.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:42:53 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:42:53 2011
New Revision: 125904
URL: http://llvm.org/viewvc/llvm-project?rev=125904&view=rev
Log:
llvmlab: Add a status object to the application & config, for persisting the
sync'ed buildbot status.
Modified:
zorg/trunk/llvmlab/llvmlab/ci/status.py
zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample
zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py
zorg/trunk/llvmlab/llvmlab/ui/app.py
Modified: zorg/trunk/llvmlab/llvmlab/ci/status.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ci/status.py?rev=125904&r1=125903&r2=125904&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ci/status.py (original)
+++ zorg/trunk/llvmlab/llvmlab/ci/status.py Fri Feb 18 10:42:53 2011
@@ -39,13 +39,15 @@
if version != 0:
raise ValueError, "Unknown version"
- return Status([BuildStatus.fromdata(item)
- for item in data['builds']])
+ return Status(dict((name, [BuildStatus.fromdata(b)
+ for b in builds])
+ for name,builds in data['builders']))
def todata(self):
return { 'version' : 0,
- 'builds' : [item.todata()
- for item in self.builds] }
+ 'builders' : [(name, [b.todata()
+ for b in builds])
+ for name,builds in self.builders.items()] }
- def __init__(self, builds):
- self.builds = builds
+ def __init__(self, builders):
+ self.builders = builders
Modified: zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample?rev=125904&r1=125903&r2=125904&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample (original)
+++ zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample Fri Feb 18 10:42:53 2011
@@ -18,3 +18,6 @@
# Path to the managed data file.
DATA_PATH = %(data_path)r
+
+# Path to the buildbot status file.
+STATUS_PATH = %(status_path)r
Modified: zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py?rev=125904&r1=125903&r2=125904&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py (original)
+++ zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py Fri Feb 18 10:42:53 2011
@@ -9,6 +9,7 @@
import flask
import llvmlab.data
import llvmlab.user
+import llvmlab.ci.status
import llvmlab.ui.app
def note(message):
@@ -64,6 +65,7 @@
basepath = os.path.abspath(basepath)
cfg_path = os.path.join(basepath, 'lab.cfg')
data_path = os.path.join(basepath, 'lab-data.json')
+ status_path = os.path.join(basepath, 'lab-status.json')
if not os.path.exists(basepath):
try:
@@ -78,6 +80,8 @@
parser.error("%r exists (use --force to override)" % cfg_path)
if os.path.exists(data_path):
parser.error("%r exists (use --force to override)" % data_path)
+ if os.path.exists(status_path):
+ parser.error("%r exists (use --force to override)" % status_path)
# Construct the config file.
sample_cfg_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
@@ -93,21 +97,24 @@
opts.admin_password + secret_key).hexdigest()
cfg_options['secret_key'] = secret_key
cfg_options['data_path'] = data_path
+ cfg_options['status_path'] = status_path
cfg_data = sample_cfg_data % cfg_options
# Write the initial config file.
cfg_file = open(cfg_path, 'w')
cfg_file.write(cfg_data)
cfg_file.close()
-
- # Create the inital data file.
- data = llvmlab.data.Data(users = [])
-
- # Write the initial (empty) data file.
- data_file = open(data_path, 'w')
- flask.json.dump(data.todata(), data_file, indent=2)
- print >>data_file
- data_file.close()
+
+ # Construct the initial database and status files.
+ data = llvmlab.data.Data(users = [], machines = [])
+ status = llvmlab.ci.status.Status({})
+
+ # Construct an app instance, and save the data.
+ instance = llvmlab.ui.app.App.create_standalone(data = data,
+ status = status,
+ config_path = cfg_path)
+ instance.save_data()
+ instance.save_status()
def action_runserver(name, args):
"""run a llvmlab instance"""
Modified: zorg/trunk/llvmlab/llvmlab/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/app.py?rev=125904&r1=125903&r2=125904&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ui/app.py (original)
+++ zorg/trunk/llvmlab/llvmlab/ui/app.py Fri Feb 18 10:42:53 2011
@@ -5,15 +5,16 @@
import llvmlab.data
import llvmlab.user
+import llvmlab.ci.status
from llvmlab.ui.ci.views import ci as ci_views
from llvmlab.ui.frontend.views import frontend as frontend_views
class App(flask.Flask):
@staticmethod
- def create_standalone(config = None, data = None, config_path = None):
+ def create_standalone(config = None, data = None, status = None,
+ config_path = None):
if config_path is not None:
assert config is None
- assert data is None
# Construct the application.
app = App(__name__)
@@ -24,6 +25,9 @@
# Load the database.
app.load_data(data)
+ # Load the buildbot status.
+ app.load_status(status)
+
# Load the application routes.
app.register_module(ci_views)
app.register_module(frontend_views)
@@ -45,12 +49,16 @@
"ADMIN_EMAIL" : "admin at example.com",
"DEBUG" : True,
"SECRET_KEY" : secret_key,
- "DATA_PATH" : None }
+ "DATA_PATH" : None,
+ "STATUS_PATH" : None }
# Construct an empty test database.
- data = llvmlab.data.Data(users = [])
+ data = llvmlab.data.Data(users = [], machines = [])
+
+ # Construct an empty status file.
+ data = llvmlab.ci.status.Status({})
- return App.create_standalone(config, data)
+ return App.create_standalone(config, data, status)
def __init__(self, name):
super(App, self).__init__(name)
@@ -97,6 +105,24 @@
print >>file
file.close()
+ def load_status(self, status = None):
+ if status is None:
+ data_path = self.config["STATUS_PATH"]
+ data_file = open(data_path, "rb")
+ data_object = flask.json.load(data_file)
+ data_file.close()
+
+ # Create the internal Status object.
+ status = llvmlab.ci.status.Status.fromdata(data_object)
+
+ self.config.status = status
+
+ def save_status(self):
+ file = open(self.config["STATUS_PATH"], 'w')
+ flask.json.dump(self.config.status.todata(), file, indent=2)
+ print >>file
+ file.close()
+
def authenticate_login(self, username, password):
passhash = hashlib.sha256(
password + self.config["SECRET_KEY"]).hexdigest()
More information about the llvm-commits
mailing list