+def __suite_list(d, args):
+ s = d.session()
+ for j in s.query(Suite).order_by('suite_name').all():
+ print j.suite_name
+
+def __suite_show(d, args):
+ if len(args) < 2:
+ die("E: showing an suite entry requires a suite")
+
+ s = d.session()
+ su = get_suite(args[2].lower())
+ if su is None:
+ die("E: can't find suite entry for %s" % (args[2].lower()))
+
+ 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()
+ d = DBConn()
+
+ die_arglen(args, 2, "E: suite needs at least a command")
+
+ mode = args[1].lower()
+
+ if mode == 'list':
+ __suite_list(d, args)
+ elif mode == 'show':
+ __suite_show(d, args)
+ elif mode == 'add':
+ __suite_add(d, args)
+ else:
+ die("E: suite command unknown")
+
+dispatch['suite'] = suite
+dispatch['s'] = suite
+
+################################################################################
+
+def __suite_architecture_list(d, args):
+ s = d.session()
+ for j in s.query(Suite).order_by('suite_name').all():
+ print j.suite_name + ' ' + \
+ ','.join([a.architecture.arch_string for a in j.suitearchitectures])
+