/[webwml]/newmaint/bin/gpg_remove_user
ViewVC logotype

Diff of /newmaint/bin/gpg_remove_user

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by tbm, Mon Nov 25 20:55:22 2002 UTC revision 1.5 by tbm, Sat Dec 27 19:06:46 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/python  #!/usr/bin/python
2    
3  # Remove a user (and associated place entries) from the database  # Remove a user (and associated place entries) from the database
4  # Copyright (C) 2002  Martin Michlmayr <tbm@cyrius.com>  # Copyright (C) 2002, 2003  Martin Michlmayr <tbm@cyrius.com>
5  # $Id$  # $Id$
6    
7  # This program is free software; you can redistribute it and/or modify  # This program is free software; you can redistribute it and/or modify
# Line 20  Line 20 
20    
21    
22  import pg, sys  import pg, sys
23  import utils, gpg_utils  import gpg_utils
24  import apt_pkg  import apt_pkg
25    
26  def help():  def help():
# Line 37  def parse_args(): Line 37  def parse_args():
37      apt_pkg.ReadConfigFileISC(Cnf, "gpg.conf")      apt_pkg.ReadConfigFileISC(Cnf, "gpg.conf")
38    
39      Arguments = [("h", "help", "RemoveUsers::Options::Help")]      Arguments = [("h", "help", "RemoveUsers::Options::Help")]
40        for i in ["Help"]:
41            if not Cnf.has_key("RemoveUsers::Options::%s" % i):
42                Cnf["RemoveUsers::Options::%s" % i] = ""
43    
44      removals = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)      removals = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
45    
# Line 47  def parse_args(): Line 50  def parse_args():
50          help()          help()
51      return removals      return removals
52    
53  # Remove one user and its places and (optionall) send mail  # Remove one user and its places and (optionally) send mail
54  def remove_user(db, email):  def remove_user(db, email):
55      print "Removing user with the email address %s..." % email      print "Removing user with the email address %s..." % email
56      db.query("DELETE FROM places WHERE who IN (SELECT id FROM people WHERE email = '%s')" % email)      db.query("DELETE FROM places WHERE who IN (SELECT id FROM people WHERE email = '%s')" % email)
# Line 59  def remove_user(db, email): Line 62  def remove_user(db, email):
62  removals = parse_args()  removals = parse_args()
63  db = pg.connect(Cnf["MyDB"])  db = pg.connect(Cnf["MyDB"])
64  for email in removals:  for email in removals:
65      remove_user(db, email)      if gpg_utils.find_email(db, email):
66            remove_user(db, email)
67        else:
68            print "No user with the email address %s" % email
69    
70  # vim:set ts=4:  # vim:set ts=4:
71  # vim:set expandtab:  # vim:set expandtab:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.5