X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=alyson;h=a1b75d34381f3ca66ba1c979dc86da5e1dbac9bb;hb=eef6d96ac51629f716291e81f07e54afe915ee8e;hp=007063f171d3540b81b62035a19d8ff36fef3ab4;hpb=2f5e692bfbbb6f8146f50d944f7fcc169a95a0a3;p=dak.git diff --git a/alyson b/alyson index 007063f1..a1b75d34 100755 --- a/alyson +++ b/alyson @@ -1,8 +1,8 @@ #!/usr/bin/env python # Sync the ISC configuartion file and the SQL database -# Copyright (C) 2000, 2001 James Troup -# $Id: alyson,v 1.6 2001-11-18 19:57:58 rmurray Exp $ +# Copyright (C) 2000, 2001, 2002, 2003 James Troup +# $Id: alyson,v 1.12 2003-09-07 13:52:07 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,8 +20,8 @@ ################################################################################ -import pg, sys, string -import utils, db_access +import pg, sys; +import utils, db_access; import apt_pkg; ################################################################################ @@ -31,6 +31,15 @@ projectB = None; ################################################################################ +def usage(exit_code=0): + print """Usage: alyson +Initalizes some tables in the projectB database based on the config file. + + -h, --help show this help and exit.""" + sys.exit(exit_code) + +################################################################################ + def get (c, i): if c.has_key(i): return "'%s'" % (c[i]); @@ -41,11 +50,16 @@ def main (): global Cnf, projectB; Cnf = utils.get_conf() + Arguments = [('h',"help","Alyson::Options::Help")]; + for i in [ "help" ]: + if not Cnf.has_key("Alyson::Options::%s" % (i)): + Cnf["Alyson::Options::%s" % (i)] = ""; + + apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv); - Arguments = [('D',"debug","Alyson::Options::Debug", "IntVal"), - ('h',"help","Alyson::Options::Help"), - ('v',"version","Alyson::Options::Version")]; - apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Alyson::Options") + if Options["Help"]: + usage(); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); @@ -77,7 +91,7 @@ def main (): for name in Cnf.SubTree("Component").List(): Component = Cnf.SubTree("Component::%s" % (name)); description = get(Component, "Description"); - if string.lower(Component.get("MeetsDFSG")) == "true": + if Component.get("MeetsDFSG").lower() == "true": meets_dfsg = "true"; else: meets_dfsg = "false"; @@ -113,8 +127,8 @@ def main (): origin = get(Suite, "Origin"); description = get(Suite, "Description"); projectB.query("INSERT INTO suite (suite_name, version, origin, description) VALUES ('%s', %s, %s, %s)" - % (string.lower(suite), version, origin, description)); - for architecture in Cnf.SubTree("Suite::%s::Architectures" % (suite)).List(): + % (suite.lower(), version, origin, description)); + for architecture in Cnf.ValueList("Suite::%s::Architectures" % (suite)): architecture_id = db_access.get_architecture_id (architecture); if architecture_id < 0: utils.fubar("architecture '%s' not found in architecture table for suite %s." % (architecture, suite)); @@ -125,7 +139,7 @@ def main (): projectB.query("BEGIN WORK"); projectB.query("DELETE FROM override_type"); - for type in Cnf.SubTree("OverrideType").List(): + for type in Cnf.ValueList("OverrideType"): projectB.query("INSERT INTO override_type (type) VALUES ('%s')" % (type)); projectB.query("COMMIT WORK"); @@ -144,22 +158,22 @@ def main (): for component in Cnf.SubTree("Component").List(): if Cnf["Natalie::ComponentPosition"] == "prefix": suffix = ""; - if component != 'main': + if component != "main": prefix = component + '/'; else: prefix = ""; else: prefix = ""; - component = string.replace(component, "non-US/", ""); - if component != 'main': + component = component.replace("non-US/", ""); + if component != "main": suffix = '/' + component; else: suffix = ""; - for section in Cnf.SubTree("Section").List(): + for section in Cnf.ValueList("Section"): projectB.query("INSERT INTO section (section) VALUES ('%s%s%s')" % (prefix, section, suffix)); projectB.query("COMMIT WORK"); -####################################################################################### +################################################################################ if __name__ == '__main__': main()