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

Contents of /newmaint/bin/gpg_remove_user

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Sat Dec 27 20:32:10 2003 UTC (9 years, 4 months ago) by tbm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +2 -4 lines
Update vim modeline.
1 tbm 1.1 #!/usr/bin/python
2    
3     # Remove a user (and associated place entries) from the database
4 tbm 1.5 # Copyright (C) 2002, 2003 Martin Michlmayr <tbm@cyrius.com>
5 tbm 1.6 # $Id: gpg_remove_user,v 1.5 2003/12/27 19:06:46 tbm Exp $
6 tbm 1.1
7     # This program is free software; you can redistribute it and/or modify
8     # it under the terms of the GNU General Public License as published by
9     # the Free Software Foundation; either version 2 of the License, or
10     # (at your option) any later version.
11    
12     # This program is distributed in the hope that it will be useful,
13     # but WITHOUT ANY WARRANTY; without even the implied warranty of
14     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     # GNU General Public License for more details.
16    
17     # You should have received a copy of the GNU General Public License
18     # along with this program; if not, write to the Free Software
19     # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20    
21    
22     import pg, sys
23 tbm 1.2 import gpg_utils
24 tbm 1.1 import apt_pkg
25    
26     def help():
27     print """Usage: gpg_remove_user [OPTION] EMAIL...
28     Remove a user (and associated places) from the database
29     """
30     sys.exit(1)
31    
32     def parse_args():
33     global Cnf
34    
35     apt_pkg.init()
36     Cnf = apt_pkg.newConfiguration()
37     apt_pkg.ReadConfigFileISC(Cnf, "gpg.conf")
38    
39     Arguments = [("h", "help", "RemoveUsers::Options::Help")]
40 tbm 1.5 for i in ["Help"]:
41     if not Cnf.has_key("RemoveUsers::Options::%s" % i):
42     Cnf["RemoveUsers::Options::%s" % i] = ""
43 tbm 1.1
44     removals = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
45    
46     if Cnf["RemoveUsers::Options::Help"]:
47     help()
48     if not removals: # not user given
49     print "No user given!"
50     help()
51     return removals
52    
53 tbm 1.4 # Remove one user and its places and (optionally) send mail
54 tbm 1.1 def remove_user(db, email):
55     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)
57     db.query("DELETE FROM people WHERE email = '%s'" % email)
58    
59    
60     # main
61    
62     removals = parse_args()
63     db = pg.connect(Cnf["MyDB"])
64     for email in removals:
65 tbm 1.3 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 tbm 1.1
70 tbm 1.6 # vim: ts=4:expandtab:shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.5