]> git.decadent.org.uk Git - dak.git/blobdiff - dak/control_suite.py
import dak.lib.foo as foo for library modules.
[dak.git] / dak / control_suite.py
index fb3f5fcce3ef48dde9b5167cb0207ea8a0abebdd..64e82534200e98d36b7d23098fa004465c198d3a 100755 (executable)
@@ -1,8 +1,7 @@
 #!/usr/bin/env python
 
 # Manipulate suite tags
-# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005  James Troup <james@nocrew.org>
-# $Id: heidi,v 1.19 2005-11-15 09:50:32 ajt Exp $
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006  James Troup <james@nocrew.org>
 
 # 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
@@ -44,7 +43,9 @@
 
 import pg, sys
 import apt_pkg
-import utils, db_access, logging
+import dak.lib.database as database
+import dak.lib.logging as logging
+import dak.lib.utils as utils
 
 #######################################################################################
 
@@ -55,7 +56,7 @@ Logger = None
 ################################################################################
 
 def usage (exit_code=0):
-    print """Usage: heidi [OPTIONS] [FILE]
+    print """Usage: dak control-suite [OPTIONS] [FILE]
 Display or alter the contents of a suite using FILE(s), or stdin.
 
   -a, --add=SUITE            add to SUITE
@@ -144,7 +145,7 @@ def set_suite (file, suite_id):
 
 def process_file (file, suite, action):
 
-    suite_id = db_access.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
 
     if action == "set":
         set_suite (file, suite_id)
@@ -214,7 +215,7 @@ def process_file (file, suite, action):
 #######################################################################################
 
 def get_list (suite):
-    suite_id = db_access.get_suite_id(suite)
+    suite_id = database.get_suite_id(suite)
     # List binaries
     q = projectB.query("SELECT b.package, b.version, a.arch_string FROM binaries b, bin_associations ba, architecture a WHERE ba.suite = %s AND ba.bin = b.id AND b.architecture = a.id" % (suite_id))
     ql = q.getresult()
@@ -234,32 +235,32 @@ def main ():
 
     Cnf = utils.get_conf()
 
-    Arguments = [('a',"add","Heidi::Options::Add", "HasArg"),
-                 ('h',"help","Heidi::Options::Help"),
-                 ('l',"list","Heidi::Options::List","HasArg"),
-                 ('r',"remove", "Heidi::Options::Remove", "HasArg"),
-                 ('s',"set", "Heidi::Options::Set", "HasArg")]
+    Arguments = [('a',"add","Control-Suite::Options::Add", "HasArg"),
+                 ('h',"help","Control-Suite::Options::Help"),
+                 ('l',"list","Control-Suite::Options::List","HasArg"),
+                 ('r',"remove", "Control-Suite::Options::Remove", "HasArg"),
+                 ('s',"set", "Control-Suite::Options::Set", "HasArg")]
 
     for i in ["add", "help", "list", "remove", "set", "version" ]:
-       if not Cnf.has_key("Heidi::Options::%s" % (i)):
-           Cnf["Heidi::Options::%s" % (i)] = ""
+       if not Cnf.has_key("Control-Suite::Options::%s" % (i)):
+           Cnf["Control-Suite::Options::%s" % (i)] = ""
 
     file_list = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
-    Options = Cnf.SubTree("Heidi::Options")
+    Options = Cnf.SubTree("Control-Suite::Options")
 
     if Options["Help"]:
        usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"],int(Cnf["DB::Port"]))
 
-    db_access.init(Cnf, projectB)
+    database.init(Cnf, projectB)
 
     action = None
 
     for i in ("add", "list", "remove", "set"):
-        if Cnf["Heidi::Options::%s" % (i)] != "":
-            suite = Cnf["Heidi::Options::%s" % (i)]
-            if db_access.get_suite_id(suite) == -1:
+        if Cnf["Control-Suite::Options::%s" % (i)] != "":
+            suite = Cnf["Control-Suite::Options::%s" % (i)]
+            if database.get_suite_id(suite) == -1:
                 utils.fubar("Unknown suite '%s'." %(suite))
             else:
                 if action:
@@ -277,7 +278,7 @@ def main ():
     if action == "list":
         get_list(suite)
     else:
-        Logger = logging.Logger(Cnf, "heidi")
+        Logger = logging.Logger(Cnf, "control-suite")
         if file_list:
             for file in file_list:
                 process_file(utils.open_file(file), suite, action)