[llvm-commits] [zorg] r125929 - in /zorg/trunk/llvmlab/llvmlab: llvmlabtool/lab.cfg.sample llvmlabtool/main.py ui/app.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:44:20 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:44:20 2011
New Revision: 125929
URL: http://llvm.org/viewvc/llvm-project?rev=125929&view=rev
Log:
llvmlab: Update config to only point to install directory (instead of individual
files in it).
Modified:
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/llvmlabtool/lab.cfg.sample
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample?rev=125929&r1=125928&r2=125929&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample (original)
+++ zorg/trunk/llvmlab/llvmlab/llvmlabtool/lab.cfg.sample Fri Feb 18 10:44:20 2011
@@ -20,11 +20,6 @@
# Secret key for this server instance.
SECRET_KEY = %(secret_key)r
-# Path to the managed data file.
-DATA_PATH = %(data_path)r
-
-# Path to the buildbot status file.
-STATUS_PATH = %(status_path)r
-
-# Path to the error log.
-ERROR_LOG_PATH = %(error_log_path)r
+# Path to the installation directory (which stores data files, status, logs,
+# etc.).
+INSTALL_PATH = %(install_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=125929&r1=125928&r2=125929&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py (original)
+++ zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py Fri Feb 18 10:44:20 2011
@@ -36,8 +36,6 @@
import llvmlab
from optparse import OptionParser, OptionGroup
parser = OptionParser("%%prog %s [options] <path>" % name)
- parser.add_option("-f", "--force", dest="force", action="store_true",
- help="overwrite existing files")
group = OptionGroup(parser, "CONFIG OPTIONS")
group.add_option("", "--admin-login", dest="admin_login",
@@ -64,28 +62,17 @@
if len(args) != 1:
parser.error("invalid number of arguments")
- basepath, = args
- 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')
- error_log_path = os.path.join(basepath, 'error.log')
-
- if not os.path.exists(basepath):
- try:
- os.mkdir(basepath)
- except:
- parser.error("unable to create directory: %r" % basepath)
- elif not os.path.isdir(basepath):
- parser.error("%r exists but is not a directory" % basepath)
-
- if not opts.force:
- if os.path.exists(cfg_path):
- 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)
+ install_path, = args
+ install_path = os.path.abspath(install_path)
+ cfg_path = os.path.join(install_path, 'lab.cfg')
+
+ # Create the install directory.
+ if os.path.exists(install_path):
+ parser.error("refusing to install: %r exists" % install_path)
+ try:
+ os.mkdir(install_path)
+ except:
+ parser.error("unable to create directory: %r" % install_path)
# Construct the config file.
sample_cfg_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
@@ -100,9 +87,7 @@
cfg_options['admin_passhash'] = hashlib.sha256(
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_options['error_log_path'] = error_log_path
+ cfg_options['install_path'] = install_path
cfg_data = sample_cfg_data % cfg_options
# Write the initial config file.
Modified: zorg/trunk/llvmlab/llvmlab/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/app.py?rev=125929&r1=125928&r2=125929&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ui/app.py (original)
+++ zorg/trunk/llvmlab/llvmlab/ui/app.py Fri Feb 18 10:44:20 2011
@@ -27,9 +27,12 @@
app.load_config(config, config_path)
# Configure error logging.
- handler = logging.FileHandler(app.config['ERROR_LOG_PATH'])
- handler.setLevel(logging.WARNING)
- app.logger.addHandler(handler)
+ install_path = app.config["INSTALL_PATH"]
+ if install_path:
+ error_log_path = os.path.join(install_path, "error.log")
+ handler = logging.FileHandler(error_log_path)
+ handler.setLevel(logging.WARNING)
+ app.logger.addHandler(handler)
# Configure error emails, if requested.
if app.config['MAIL_ERRORS']:
@@ -78,8 +81,7 @@
"EMAIL_RELAY_SERVER" : "localhost",
"MAIL_ERRORS" : False,
"SECRET_KEY" : secret_key,
- "DATA_PATH" : None,
- "STATUS_PATH" : None }
+ "INSTALL_PATH" : None }
# Construct an empty test database.
data = llvmlab.data.Data(users = [], machines = [])
@@ -111,7 +113,8 @@
def load_data(self, data = None):
if data is None:
- data_path = self.config["DATA_PATH"]
+ install_path = self.config["INSTALL_PATH"]
+ data_path = os.path.join(install_path, "lab-data.json")
data_file = open(data_path, "rb")
data_object = flask.json.load(data_file)
data_file.close()
@@ -130,14 +133,17 @@
self.config.data = data
def save_data(self):
- file = open(self.config["DATA_PATH"], 'w')
+ install_path = self.config["INSTALL_PATH"]
+ data_path = os.path.join(install_path, "lab-data.json")
+ file = open(data_path, 'w')
flask.json.dump(self.config.data.todata(), file, indent=2)
print >>file
file.close()
def load_status(self, status = None):
if status is None:
- data_path = self.config["STATUS_PATH"]
+ install_path = self.config["INSTALL_PATH"]
+ data_path = os.path.join(install_path, "lab-status.json")
data_file = open(data_path, "rb")
data_object = flask.json.load(data_file)
data_file.close()
@@ -148,7 +154,9 @@
self.config.status = status
def save_status(self):
- file = open(self.config["STATUS_PATH"], 'w')
+ install_path = self.config["INSTALL_PATH"]
+ data_path = os.path.join(install_path, "lab-status.json")
+ file = open(data_path, 'w')
flask.json.dump(self.config.status.todata(), file, indent=2)
print >>file
file.close()
More information about the llvm-commits
mailing list