/[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.3 - (hide annotations) (download)
Mon Nov 25 21:39:03 2002 UTC (10 years, 6 months ago) by tbm
Branch: MAIN
Changes since 1.2: +5 -2 lines
Actually check if there is such a user
1 tbm 1.1 #!/usr/bin/python
2    
3     # Remove a user (and associated place entries) from the database
4     # Copyright (C) 2002 Martin Michlmayr <tbm@cyrius.com>
5 tbm 1.3 # $Id: gpg_remove_user,v 1.2 2002/11/25 21:13:51 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    
41     removals = apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
42    
43     if Cnf["RemoveUsers::Options::Help"]:
44     help()
45     if not removals: # not user given
46     print "No user given!"
47     help()
48     return removals
49    
50     # Remove one user and its places and (optionall) send mail
51     def remove_user(db, email):
52     print "Removing user with the email address %s..." % email
53     db.query("DELETE FROM places WHERE who IN (SELECT id FROM people WHERE email = '%s')" % email)
54     db.query("DELETE FROM people WHERE email = '%s'" % email)
55    
56    
57     # main
58    
59     removals = parse_args()
60     db = pg.connect(Cnf["MyDB"])
61     for email in removals:
62 tbm 1.3 if gpg_utils.find_email(db, email):
63     remove_user(db, email)
64     else:
65     print "No user with the email address %s" % email
66 tbm 1.1
67     # vim:set ts=4:
68     # vim:set expandtab:
69     # vim:set shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.5