]> git.decadent.org.uk Git - dak.git/blobdiff - alyson
Add new scripts; remove old ones.
[dak.git] / alyson
diff --git a/alyson b/alyson
new file mode 100755 (executable)
index 0000000..5e602ec
--- /dev/null
+++ b/alyson
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+# Sync the ISC configuartion file and the SQL database
+# Copyright (C) 2000  James Troup <james@nocrew.org>
+# $Id: alyson,v 1.1 2001-01-10 05:58:26 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+################################################################################
+
+import pg, sys
+import utils, db_access
+import apt_pkg;
+
+################################################################################
+
+Cnf = None;
+projectB = None;
+
+################################################################################
+
+def main ():
+    global Cnf, projectB;
+
+    apt_pkg.init();
+    
+    Cnf = apt_pkg.newConfiguration();
+    apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file());
+    Arguments = [('D',"debug","Alyson::Options::Debug", "IntVal"),
+                 ('h',"help","Alyson::Options::Help"),
+                 ('v',"version","Alyson::Options::Version")];
+    apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv);
+
+    projectB = pg.connect('projectb', 'localhost');
+    db_access.init(Cnf, projectB);
+
+    # Quick hack to populate section, priority and bin_type; the rest todo later
+
+    projectB.query("BEGIN WORK");
+    projectB.query("DELETE FROM override_type");
+    for type in Cnf.SubTree("OverrideType").List():
+        projectB.query("INSERT INTO override_type (type) VALUES ('%s')" % (type));
+    projectB.query("COMMIT WORK");
+    
+    projectB.query("BEGIN WORK");
+    projectB.query("DELETE FROM priority");
+    for priority in Cnf.SubTree("Priority").List():
+        projectB.query("INSERT INTO priority (priority, level) VALUES ('%s', %s)" % (priority, Cnf["Priority::%s" % (priority)]));
+    projectB.query("COMMIT WORK");
+
+    projectB.query("BEGIN WORK");
+    projectB.query("DELETE FROM section");
+    for component in Cnf.SubTree("Component").List():
+        if component != 'main':
+            prefix = component + '/';
+        else:
+            prefix = "";
+        for section in Cnf.SubTree("Section").List():
+            projectB.query("INSERT INTO section (section) VALUES ('%s%s')" % (prefix, section));
+    projectB.query("COMMIT WORK");
+
+
+
+#######################################################################################
+
+if __name__ == '__main__':
+    main()
+