]> git.donarmstrong.com Git - dak.git/blobdiff - dak/add_user.py
stop using deprecated python-apt functions
[dak.git] / dak / add_user.py
index f087849c8bd507653af2c7af8c357bc1fc767bb8..aaab5c8028fa9f6949b57be6965f59eb7b4cf4cd 100755 (executable)
@@ -22,7 +22,7 @@ import sys
 import apt_pkg
 
 from daklib import utils
-from daklib.dbconn import DBConn, get_or_set_uid
+from daklib.dbconn import DBConn, get_or_set_uid, get_active_keyring_paths
 from daklib.regexes import re_gpg_fingerprint_colon, re_user_address, re_user_mails, re_user_name
 
 ################################################################################
@@ -66,7 +66,7 @@ def HashPass(Password):
         Salt = Salt + SaltVals[ord(Rand.read(1)[0]) % len(SaltVals)]
     Pass = crypt.crypt(Password,Salt)
     if len(Pass) < 14:
-        raise "Password Error", "MD5 password hashing failed, not changing the password!"
+        raise RuntimeError("MD5 password hashing failed, not changing the password!")
     return Pass
 
 ################################################################################
@@ -115,16 +115,16 @@ def main():
         if not Cnf.has_key("Add-User::Options::%s" % (i)):
             Cnf["Add-User::Options::%s" % (i)] = ""
 
-    apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
+    apt_pkg.parse_commandline(Cnf, Arguments, sys.argv)
 
-    Options = Cnf.SubTree("Add-User::Options")
+    Options = Cnf.subtree("Add-User::Options")
     if Options["help"]:
         usage()
 
     session = DBConn().session()
 
     if not keyrings:
-        keyrings = Cnf.ValueList("Dinstall::GPGKeyring")
+        keyrings = get_active_keyring_paths()
 
     cmd = "gpg --with-colons --no-secmem-warning --no-auto-check-trustdb --no-default-keyring %s --with-fingerprint --list-key %s" \
            % (utils.gpg_keyring_args(keyrings),
@@ -187,7 +187,7 @@ def main():
                      name, primary_key)
 
         # Should we send mail to the newly added user?
-        if Cnf.FindB("Add-User::SendEmail"):
+        if Cnf.find_b("Add-User::SendEmail"):
             mail = name + "<" + emails[0] +">"
             Subst = {}
             Subst["__NEW_MAINTAINER__"] = mail