[llvm-commits] [zorg] r146403 - in /zorg/trunk/lnt/lnt: lnttool/import_data.py server/config.py server/ui/app.py viewer/Config.py
Daniel Dunbar
daniel at zuster.org
Mon Dec 12 11:31:28 PST 2011
Author: ddunbar
Date: Mon Dec 12 13:31:28 2011
New Revision: 146403
URL: http://llvm.org/viewvc/llvm-project?rev=146403&view=rev
Log:
lnt: Move Config module into server package.
Added:
zorg/trunk/lnt/lnt/server/config.py
- copied, changed from r146402, zorg/trunk/lnt/lnt/viewer/Config.py
Removed:
zorg/trunk/lnt/lnt/viewer/Config.py
Modified:
zorg/trunk/lnt/lnt/lnttool/import_data.py
zorg/trunk/lnt/lnt/server/ui/app.py
Modified: zorg/trunk/lnt/lnt/lnttool/import_data.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/import_data.py?rev=146403&r1=146402&r2=146403&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/lnttool/import_data.py (original)
+++ zorg/trunk/lnt/lnt/lnttool/import_data.py Mon Dec 12 13:31:28 2011
@@ -2,7 +2,7 @@
import lnt.db.perfdb
from lnt import formats
-from lnt.viewer import Config
+import lnt.server.config
from lnt.util import ImportData
def action_import(name, args):
@@ -45,7 +45,7 @@
# Load the config file.
config_data = {}
exec open(config) in config_data
- config = Config.Config.fromData(config, config_data)
+ config = lnt.server.config.Config.fromData(config, config_data)
# Get the database entry to use.
db_entry = config.databases.get(opts.database)
Copied: zorg/trunk/lnt/lnt/server/config.py (from r146402, zorg/trunk/lnt/lnt/viewer/Config.py)
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/config.py?p2=zorg/trunk/lnt/lnt/server/config.py&p1=zorg/trunk/lnt/lnt/viewer/Config.py&r1=146402&r2=146403&rev=146403&view=diff
==============================================================================
(empty)
Modified: zorg/trunk/lnt/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=146403&r1=146402&r2=146403&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/app.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/app.py Mon Dec 12 13:31:28 2011
@@ -9,11 +9,10 @@
from flask import url_for
import lnt
+import lnt.server.config
import lnt.server.ui.filters
import lnt.server.ui.views
-# FIXME: Redesign this.
-import lnt.viewer.Config
from lnt.db import perfdbsummary
from lnt.db import perfdb
@@ -101,7 +100,7 @@
config_data = {}
exec open(config_path) in config_data
- self.old_config = lnt.viewer.Config.Config.fromData(
+ self.old_config = lnt.server.config.Config.fromData(
config_path, config_data)
self.jinja_env.globals.update(
Removed: zorg/trunk/lnt/lnt/viewer/Config.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/Config.py?rev=146402&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/Config.py (original)
+++ zorg/trunk/lnt/lnt/viewer/Config.py (removed)
@@ -1,94 +0,0 @@
-"""
-LNT Config object for tracking user-configurable installation parameters.
-"""
-
-import os
-import re
-
-class EmailConfig:
- @staticmethod
- def fromData(data):
- # The email to field can either be a string, or a list of tuples of
- # the form [(accept-regexp-pattern, to-address)].
- to_address = data.get('to')
- if not isinstance(to_address, str):
- to_address = [(str(a),str(b)) for a,b in to_address]
- return EmailConfig(bool(data.get('enabled')), str(data.get('host')),
- str(data.get('from')), to_address)
-
- def __init__(self, enabled, host, from_address, to_address):
- self.enabled = enabled
- self.host = host
- self.from_address = from_address
- self.to_address = to_address
-
- def get_to_address(self, machine_name):
- # The email to_address field can either be a string, or a list of tuples
- # of the form [(accept-regexp-pattern, to-address)].
- if isinstance(self.to_address, str):
- return self.to_address
-
- for pattern,addr in self.to_address:
- if re.match(pattern, machine_name):
- return addr
-
-class DBInfo:
- @staticmethod
- def fromData(baseDir, dict, default_email_config):
- dbPath = dict.get('path')
- if '://' not in dbPath:
- dbPath = os.path.join(baseDir, dbPath)
-
- # Support per-database email configurations.
- email_config = default_email_config
- if 'emailer' in dict:
- email_config = EmailConfig.fromData(dict['emailer'])
-
- return DBInfo(dbPath,
- bool(dict.get('showNightlytest')),
- bool(dict.get('showGeneral')),
- bool(dict.get('showSimple')),
- email_config)
-
- def __init__(self, path, showNightlytest, showGeneral, showSimple,
- email_config):
- self.path = path
- self.showGeneral = showGeneral
- self.showNightlytest = showNightlytest
- self.showSimple = showSimple
- self.email_config = email_config
-
-class Config:
- @staticmethod
- def fromData(path, data):
- # Paths are resolved relative to the absolute real path of the
- # config file.
- baseDir = os.path.dirname(os.path.abspath(path))
-
- # Get the default email config.
- emailer = data.get('nt_emailer')
- if emailer:
- default_email_config = EmailConfig.fromData(emailer)
- else:
- default_email_config = EmailConfig(False, '', '', [])
-
- dbDir = data.get('db_dir', '.')
- dbDirPath = os.path.join(baseDir, dbDir)
-
- # FIXME: Remove this default.
- tempDir = data.get('tmp_dir', 'viewer/resources/graphs')
-
- return Config(data.get('name', 'LNT'), data['zorgURL'],
- dbDir, os.path.join(baseDir, tempDir),
- dict([(k,DBInfo.fromData(dbDirPath, v,
- default_email_config))
- for k,v in data['databases'].items()]))
-
- def __init__(self, name, zorgURL, dbDir, tempDir, databases):
- self.name = name
- self.zorgURL = zorgURL
- self.dbDir = dbDir
- self.tempDir = tempDir
- while self.zorgURL.endswith('/'):
- self.zorgURL = zorgURL[:-1]
- self.databases = databases
More information about the llvm-commits
mailing list