X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=alyson;h=a64c59dc39fd889bc1c677bf47500e2d94e8f92a;hb=6cc79b7b093af0c68c9d80c61d5aa7cfe72c9188;hp=c26273f64d09082796ae8ba3ed57079efb6d6909;hpb=9a89f745ed13e05507dd5297fa4a860c4fdc2b2e;p=dak.git diff --git a/alyson b/alyson index c26273f6..a64c59dc 100755 --- a/alyson +++ b/alyson @@ -2,7 +2,7 @@ # Sync the ISC configuartion file and the SQL database # Copyright (C) 2000, 2001, 2002 James Troup -# $Id: alyson,v 1.9 2002-05-14 15:28:53 troup Exp $ +# $Id: alyson,v 1.11 2003-01-02 18:10:02 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,8 +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); - apt_pkg.ParseCommandLine(Cnf,[],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); @@ -74,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"; @@ -110,7 +127,7 @@ 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)); + % (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: @@ -147,7 +164,7 @@ def main (): prefix = ""; else: prefix = ""; - component = string.replace(component, "non-US/", ""); + component = component.replace("non-US/", ""); if component != 'main': suffix = '/' + component; else: @@ -156,7 +173,7 @@ def main (): projectB.query("INSERT INTO section (section) VALUES ('%s%s%s')" % (prefix, section, suffix)); projectB.query("COMMIT WORK"); -####################################################################################### +################################################################################ if __name__ == '__main__': main()