提交 ce828cf5 编写于 作者: J Joerg Jaspert

Merge remote branch 'mario/master' into merge

* mario/master:
  init_db.py: fix for `do_priority'
  init_db.py: `Cnf.get' fix for `do_priority'
  init_db.py: fixes for `do_suite'
  init_db.py: typo fix for `do_suite' comment.
  admin.py: added command to add suites
Signed-off-by: NJoerg Jaspert <joerg@debian.org>
......@@ -67,6 +67,10 @@ Perform administrative work on the dak database.
suite / s:
s list show a list of suites
s show SUITE show config details for a suite
s add SUITE VERSION [ label=LABEL ] [ description=DESCRIPTION ]
[ origin=ORIGIN ] [ codename=CODENAME ]
add suite SUITE, version VERSION. label,
description, origin and codename are optional.
suite-architecture / s-a:
s-a list-suite ARCH show the suites an ARCH is in
......@@ -170,6 +174,37 @@ def __suite_show(d, args):
print su.details()
def __suite_add(d, args):
die_arglen(args, 4, "E: adding a suite requires at least a name and a version")
suite_name = args[2].lower()
version = args[3]
rest = args[3:]
def get_field(field):
for varval in args:
if varval.startswith(field + '='):
return varval.split('=')[1]
return None
print "Adding suite %s" % suite_name
if not dryrun:
try:
s = d.session()
suite = Suite()
suite.suite_name = suite_name
suite.version = version
suite.label = get_field('label')
suite.description = get_field('description')
suite.origin = get_field('origin')
suite.codename = get_field('codename')
s.add(suite)
s.commit()
except IntegrityError, e:
die("E: Integrity error adding suite %s (it probably already exists)" % suite_name)
except SQLAlchemyError, e:
die("E: Error adding suite %s (%s)" % (suite_name, e))
print "Suite %s added" % (suite_name)
def suite(command):
args = [str(x) for x in command]
Cnf = utils.get_conf()
......@@ -183,6 +218,8 @@ def suite(command):
__suite_list(d, args)
elif mode == 'show':
__suite_show(d, args)
elif mode == 'add':
__suite_add(d, args)
else:
die("E: suite command unknown")
......
......@@ -127,13 +127,15 @@ class InitDB(object):
s.commit()
def do_suite(self):
"""Initalize the suite table."""
"""Initialize the suite table."""
s = self.projectB.session()
s.query(Suite).delete()
for suite in self.Cnf.SubTree("Suite").List():
suite = suite.lower()
su = Suite()
su.suite_name = suite
su.version = self.Cnf.get("Suite::%s::Version" % suite, "-")
su.origin = self.Cnf.get("Suite::%s::Origin" % suite, "")
su.description = self.Cnf.get("Suite::%s::Description" % suite, "")
......@@ -141,11 +143,11 @@ class InitDB(object):
for architecture in self.Cnf.ValueList("Suite::%s::Architectures" % (suite)):
sa = SuiteArchitecture()
sa.suite_id = su.suite_id
a = s.query(Architecture).filter_by(arch_string=architecture)
if a.count() < 1:
utils.fubar("E: Architecture %s not found for suite %s" % (architecture, suite))
sa.arch_id = a.one().arch_id
sa.suite_id = su.suite_id
s.add(sa)
s.commit()
......@@ -172,7 +174,7 @@ class InitDB(object):
for priority in self.Cnf.SubTree("Priority").List():
p = Priority()
p.priority = priority
p.level = self.Cnf.get("Priority::%s", 0)
p.level = self.Cnf.get("Priority::" + priority, "0")
s.add(p)
s.commit()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册