r86021 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86020‎ | r86021 | r86022 >
Date:04:48, 14 April 2011
Author:tstarling
Status:deferred
Tags:
Comment:
Fixed indenting to use only tabs, was a random mixture of tabs and spaces. It's important that python programs are consistent in their indenting style.
Modified paths:
  • /trunk/tools/subversion/user-management/add-ldap-group (modified) (history)
  • /trunk/tools/subversion/user-management/change-ldap-passwd (modified) (history)
  • /trunk/tools/subversion/user-management/delete-ldap-group (modified) (history)
  • /trunk/tools/subversion/user-management/delete-ldap-user (modified) (history)
  • /trunk/tools/subversion/user-management/homedirectorymanager.py (modified) (history)
  • /trunk/tools/subversion/user-management/ldaplist (modified) (history)
  • /trunk/tools/subversion/user-management/ldapsupportlib.py (modified) (history)
  • /trunk/tools/subversion/user-management/modify-ldap-group (modified) (history)
  • /trunk/tools/subversion/user-management/netgroup-mod (modified) (history)

Diff [purge]

Index: trunk/tools/subversion/user-management/homedirectorymanager.py
@@ -4,24 +4,24 @@
55 from cStringIO import StringIO
66
77 try:
8 - import ldap
 8+ import ldap
99 import ldap.modlist
1010 except ImportError:
11 - sys.stderr.write("Unable to import LDAP library.\n")
12 - sys.exit(1)
 11+ sys.stderr.write("Unable to import LDAP library.\n")
 12+ sys.exit(1)
1313
1414 class HomeDirectoryManager:
1515
16 - def __init__(self):
 16+ def __init__(self):
1717 ###################################################
1818 # Configuration options #
1919 ###################################################
2020
2121 # Change this if we change the home directory location!
22 - self.basedir = '/home/'
 22+ self.basedir = '/home/'
2323
2424 # Directory to move deleted user's home directories
25 - self.savedir = self.basedir + 'SAVE/'
 25+ self.savedir = self.basedir + 'SAVE/'
2626
2727 # Add to this array if we add LDAP accounts that shouldn't
2828 # have NFS mounted home directories.
@@ -63,8 +63,8 @@
6464 ds = ldapSupportLib.connect()
6565 self.logDebug("Connected")
6666
67 - # w00t We're in!
68 - try:
 67+ # w00t We're in!
 68+ try:
6969 # get all user's uids
7070 UsersData = ldapSupportLib.getUsers(ds, '*')
7171 self.logDebug("Pulled the user information")
@@ -93,19 +93,19 @@
9494 self.createHomeDir(AllUsers)
9595
9696 except ldap.UNWILLING_TO_PERFORM, msg:
97 - sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"])
 97+ sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"])
9898 ds.unbind()
9999 sys.exit(1)
100 - except Exception:
 100+ except Exception:
101101 try:
102 - sys.stderr.write("There was a general error, please contact an administrator via the helpdesk. Please include the following stack trace with your report:\n")
 102+ sys.stderr.write("There was a general error, please contact an administrator via the helpdesk. Please include the following stack trace with your report:\n")
103103 traceback.print_exc(file=sys.stderr)
104104 ds.unbind()
105105 except Exception:
106106 pass
107107 sys.exit(1)
108108
109 - ds.unbind()
 109+ ds.unbind()
110110 sys.exit(0)
111111
112112 # Creates home directories for new users. Will not create home directories
@@ -163,7 +163,7 @@
164164
165165 def uniqueKeys(self, keys):
166166 uniqueKeys = []
167 - [uniqueKeys.append(i) for i in keys if not uniqueKeys.count(i)]
 167+ [uniqueKeys.append(i) for i in keys if not uniqueKeys.count(i)]
168168
169169 return uniqueKeys
170170
Index: trunk/tools/subversion/user-management/modify-ldap-group
@@ -3,14 +3,14 @@
44 from optparse import OptionParser
55
66 try:
7 - import ldap
 7+ import ldap
88 import ldap.modlist
99 except ImportError:
10 - sys.stderr.write("Unable to import LDAP library.\n")
11 - sys.exit(1)
 10+ sys.stderr.write("Unable to import LDAP library.\n")
 11+ sys.exit(1)
1212
1313 def main():
14 - parser = OptionParser(conflict_handler="resolve")
 14+ parser = OptionParser(conflict_handler="resolve")
1515 parser.set_usage('modify-ldap-group [options] <groupname> [--rename <newusergroup>]\nexample: modify-ldap-group --gid=501 wikidev')
1616
1717 ldapSupportLib = ldapsupportlib.LDAPSupportLib()
@@ -35,8 +35,8 @@
3636
3737 ds = ldapSupportLib.connect()
3838
39 - # w00t We're in!
40 - try:
 39+ # w00t We're in!
 40+ try:
4141 groupname = args[0]
4242 PosixData = ds.search_s("ou=group," + base,ldap.SCOPE_SUBTREE,"(&(objectclass=posixGroup)(cn=" + groupname + "))")
4343 if not PosixData:
@@ -70,13 +70,13 @@
7171 # uniqueMember expects DNs
7272 if 'uniqueMember' in NewPosixData.keys():
7373 if membertoadd in NewPosixData['uniqueMember']:
74 - sys.stderr.write(raw_member + " is already a member of the group, skipping.\n")
 74+ sys.stderr.write(raw_member + " is already a member of the group, skipping.\n")
7575 else:
7676 NewPosixData['uniqueMember'].append(membertoadd)
7777 else:
7878 NewPosixData['uniqueMember'] = [ membertoadd ]
7979 except KeyError:
80 - sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n")
 80+ sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n")
8181 elif options.deleteMembers:
8282 raw_members = options.deleteMembers.split(',')
8383 for raw_member in raw_members:
@@ -85,21 +85,21 @@
8686 if membertoremove in NewPosixData['uniqueMember']:
8787 NewPosixData['uniqueMember'].remove(membertoremove)
8888 else:
89 - sys.stderr.write(raw_member + " isn't a member of the group, skipping.\n")
 89+ sys.stderr.write(raw_member + " isn't a member of the group, skipping.\n")
9090 else:
91 - sys.stderr.write("This group contains no members.\n")
 91+ sys.stderr.write("This group contains no members.\n")
9292
9393 if PosixData == NewPosixData:
94 - sys.stderr.write("No changes to make; exiting.\n")
 94+ sys.stderr.write("No changes to make; exiting.\n")
9595 else:
9696 modlist = ldap.modlist.modifyModlist(PosixData,NewPosixData)
9797 ds.modify_s(dn, modlist)
9898 except ldap.UNWILLING_TO_PERFORM, msg:
99 - sys.stderr.write("LDAP was unwilling to modify the group. Error was: %s\n" % msg[0]["info"])
 99+ sys.stderr.write("LDAP was unwilling to modify the group. Error was: %s\n" % msg[0]["info"])
100100 ds.unbind()
101101 sys.exit(1)
102102 except ldap.NO_SUCH_OBJECT:
103 - sys.stderr.write("The group you are trying to modify doesn't exist.\n")
 103+ sys.stderr.write("The group you are trying to modify doesn't exist.\n")
104104 ds.unbind()
105105 sys.exit(1)
106106 except ldap.TYPE_OR_VALUE_EXISTS:
@@ -111,17 +111,17 @@
112112 traceback.print_exc(file=sys.stderr)
113113 ds.unbind()
114114 sys.exit(1)
115 - except Exception:
 115+ except Exception:
116116 try:
117 - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
 117+ sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
118118 traceback.print_exc(file=sys.stderr)
119119 ds.unbind()
120120 except Exception:
121 - sys.stderr.write("Also failed to unbind.\n")
 121+ sys.stderr.write("Also failed to unbind.\n")
122122 traceback.print_exc(file=sys.stderr)
123123 sys.exit(1)
124124
125 - ds.unbind()
 125+ ds.unbind()
126126 sys.exit(0)
127127
128128 if __name__ == "__main__":
Index: trunk/tools/subversion/user-management/add-ldap-group
@@ -3,14 +3,14 @@
44 from optparse import OptionParser
55
66 try:
7 - import ldap
 7+ import ldap
88 import ldap.modlist
99 except ImportError:
10 - sys.stderr.write("Unable to import LDAP library.\n")
11 - sys.exit(1)
 10+ sys.stderr.write("Unable to import LDAP library.\n")
 11+ sys.exit(1)
1212
1313 def main():
14 - parser = OptionParser(conflict_handler="resolve")
 14+ parser = OptionParser(conflict_handler="resolve")
1515 parser.set_usage('add-ldap-group [options] <groupname>\nexample: add-ldap-group wikidev')
1616
1717 ldapSupportLib = ldapsupportlib.LDAPSupportLib()
@@ -30,8 +30,8 @@
3131
3232 ds = ldapSupportLib.connect()
3333
34 - # w00t We're in!
35 - try:
 34+ # w00t We're in!
 35+ try:
3636 groupname = args[0]
3737
3838 dn = 'cn=' + groupname + ',ou=group,' + base
@@ -67,7 +67,7 @@
6868 # uniqueMember expects DNs
6969 members.append('uid=' + raw_member + ',ou=people,' + base)
7070 except KeyError:
71 - sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n")
 71+ sys.stderr.write(raw_member + " doesn't exist, and won't be added to the group.\n")
7272
7373 groupEntry = {}
7474 groupEntry['objectclass'] = objectClasses
@@ -79,11 +79,11 @@
8080 modlist = ldap.modlist.addModlist(groupEntry)
8181 ds.add_s(dn, modlist)
8282 except ldap.UNWILLING_TO_PERFORM, msg:
83 - sys.stderr.write("LDAP was unwilling to create the group. Error was: %s\n" % msg[0]["info"])
 83+ sys.stderr.write("LDAP was unwilling to create the group. Error was: %s\n" % msg[0]["info"])
8484 ds.unbind()
8585 sys.exit(1)
8686 except ldap.TYPE_OR_VALUE_EXISTS:
87 - sys.stderr.write("The group or gid you are trying to add already exists.\n")
 87+ sys.stderr.write("The group or gid you are trying to add already exists.\n")
8888 traceback.print_exc(file=sys.stderr)
8989 ds.unbind()
9090 sys.exit(1)
@@ -92,17 +92,17 @@
9393 traceback.print_exc(file=sys.stderr)
9494 ds.unbind()
9595 sys.exit(1)
96 - except Exception:
 96+ except Exception:
9797 try:
98 - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
 98+ sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
9999 traceback.print_exc(file=sys.stderr)
100100 ds.unbind()
101101 except Exception:
102 - sys.stderr.write("Also failed to unbind.\n")
 102+ sys.stderr.write("Also failed to unbind.\n")
103103 traceback.print_exc(file=sys.stderr)
104104 sys.exit(1)
105105
106 - ds.unbind()
 106+ ds.unbind()
107107 sys.exit(0)
108108
109109 if __name__ == "__main__":
Index: trunk/tools/subversion/user-management/netgroup-mod
@@ -3,14 +3,14 @@
44 from optparse import OptionParser
55
66 try:
7 - import ldap
 7+ import ldap
88 import ldap.modlist
99 except ImportError:
10 - sys.stderr.write("Unable to import LDAP library.\n")
11 - sys.exit(1)
 10+ sys.stderr.write("Unable to import LDAP library.\n")
 11+ sys.exit(1)
1212
1313 def main():
14 - parser = OptionParser(conflict_handler="resolve")
 14+ parser = OptionParser(conflict_handler="resolve")
1515 parser.set_usage('netgroup-mod [options] netgroup-name [host|-u user] [-f|--file filename]\n\nexample: netgroup-mod "test-ng" "fenari.wikimedia.org"\nexample: netgroup-mod "test-ng" -f test.file')
1616
1717 ldapSupportLib = ldapsupportlib.LDAPSupportLib()
@@ -35,8 +35,8 @@
3636
3737 ds = ldapSupportLib.connect()
3838
39 - # w00t We're in!
40 - try:
 39+ # w00t We're in!
 40+ try:
4141 if options.hosts:
4242 PosixData = ds.search_s("ou=hosts," + base,ldap.SCOPE_SUBTREE,"(&(objectclass=iphost)(cn=*))")
4343 elif options.netgroups:
@@ -152,58 +152,58 @@
153153 ds.unbind()
154154 sys.exit(1)
155155 except ldap.UNWILLING_TO_PERFORM, msg:
156 - sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"])
 156+ sys.stderr.write("The search returned an error. Error was: %s\n" % msg[0]["info"])
157157 ds.unbind()
158158 sys.exit(1)
159 - except ldap.NO_SUCH_OBJECT:
160 - sys.stderr.write("The netgroup provided cannot be found, please try again.\n")
 159+ except ldap.NO_SUCH_OBJECT:
 160+ sys.stderr.write("The netgroup provided cannot be found, please try again.\n")
161161 ds.unbind()
162162 sys.exit(1)
163163 except ldap.TYPE_OR_VALUE_EXISTS:
164 - sys.stderr.write("The host/user you are trying to add is already in the netgroup you provided.\n")
 164+ sys.stderr.write("The host/user you are trying to add is already in the netgroup you provided.\n")
165165 ds.unbind()
166166 sys.exit(1)
167167 except ldap.PROTOCOL_ERROR:
168168 if options.delete:
169 - sys.stderr.write("The host/user you are trying to remove is not in the netgroup you provided.\n")
 169+ sys.stderr.write("The host/user you are trying to remove is not in the netgroup you provided.\n")
170170 else:
171171 sys.stderr.write("There was an LDAP protocol error, please contact an administrator via the helpdesk.\n")
172172 ds.unbind()
173173 sys.exit(1)
174 - #except Exception:
 174+ #except Exception:
175175 # try:
176176 # ds.unbind()
177 - # sys.stderr.write("There was a general error, please contact an administrator via the helpdesk.\n")
 177+ # sys.stderr.write("There was a general error, please contact an administrator via the helpdesk.\n")
178178 # except Exception:
179179 # pass
180180 # sys.exit(1)
181181
182 - # /End of stolen stuff
 182+ # /End of stolen stuff
183183
184 - # PosixData is a list of lists where:
185 - # index 0 of PosixData[N]: contains the distinquished name
186 - # index 1 of PosixData[N]: contains a dictionary of lists hashed by the following keys:
187 - # telephoneNumber, departmentNumber, uid, objectClass, loginShell,
188 - # uidNumber, gidNumber, sn, homeDirectory, givenName, cn
 184+ # PosixData is a list of lists where:
 185+ # index 0 of PosixData[N]: contains the distinquished name
 186+ # index 1 of PosixData[N]: contains a dictionary of lists hashed by the following keys:
 187+ # telephoneNumber, departmentNumber, uid, objectClass, loginShell,
 188+ # uidNumber, gidNumber, sn, homeDirectory, givenName, cn
189189
190190 if options.hosts or options.netgroups:
191 - for i in range(len(PosixData)):
192 - if options.hosts:
193 - print "hostname: " + PosixData[i][1]["cn"][0]
194 - print " IP: " + PosixData[i][1]["ipHostNumber"][0]
195 - elif options.netgroups:
196 - if not (options.showhost or options.showshares or options.showuser):
197 - print "Netgroup Name: " + PosixData[i][1]["cn"][0]
198 - else:
199 - if options.showhost:
200 - if "ou=host" in PosixData[i][0]:
201 - print "Netgroup Name: " + PosixData[i][1]["cn"][0]
202 - if options.showshares:
203 - if "ou=shares" in PosixData[i][0]:
204 - print "Netgroup Name: " + PosixData[i][1]["cn"][0]
205 - if options.showuser:
206 - if "ou=user" in PosixData[i][0]:
207 - print "Netgroup Name: " + PosixData[i][1]["cn"][0]
 191+ for i in range(len(PosixData)):
 192+ if options.hosts:
 193+ print "hostname: " + PosixData[i][1]["cn"][0]
 194+ print " IP: " + PosixData[i][1]["ipHostNumber"][0]
 195+ elif options.netgroups:
 196+ if not (options.showhost or options.showshares or options.showuser):
 197+ print "Netgroup Name: " + PosixData[i][1]["cn"][0]
 198+ else:
 199+ if options.showhost:
 200+ if "ou=host" in PosixData[i][0]:
 201+ print "Netgroup Name: " + PosixData[i][1]["cn"][0]
 202+ if options.showshares:
 203+ if "ou=shares" in PosixData[i][0]:
 204+ print "Netgroup Name: " + PosixData[i][1]["cn"][0]
 205+ if options.showuser:
 206+ if "ou=user" in PosixData[i][0]:
 207+ print "Netgroup Name: " + PosixData[i][1]["cn"][0]
208208 else:
209209 if options.user:
210210 netgrouptype = "user"
@@ -214,15 +214,15 @@
215215 else:
216216 print "The " + netgrouptype + "(s) were successfully added."
217217
218 - ds.unbind()
 218+ ds.unbind()
219219 sys.exit(0)
220220
221221 def checkargs(options, args):
222222 if (len(args) < 2 or len(args) > 2):
223223 if options.file and len(args) == 1:
224224 return
225 - sys.stderr.write("Invalid syntax, please see \"netgroup-mod --help\"\n")
226 - sys.exit(1)
 225+ sys.stderr.write("Invalid syntax, please see \"netgroup-mod --help\"\n")
 226+ sys.exit(1)
227227
228228 def infofromfile(list, changetype, file, netgrouptype, PosixCheckData):
229229 f = open(file)
Index: trunk/tools/subversion/user-management/change-ldap-passwd
@@ -3,14 +3,14 @@
44 from optparse import OptionParser
55
66 try:
7 - import ldap
 7+ import ldap
88 import ldap.modlist
99 except ImportError:
10 - sys.stderr.write("Unable to import LDAP library.\n")
11 - sys.exit(1)
 10+ sys.stderr.write("Unable to import LDAP library.\n")
 11+ sys.exit(1)
1212
1313 def main():
14 - parser = OptionParser(conflict_handler="resolve")
 14+ parser = OptionParser(conflict_handler="resolve")
1515 parser.set_usage('change-ldap-passwd [options] <username>')
1616
1717 ldapSupportLib = ldapsupportlib.LDAPSupportLib()
@@ -28,8 +28,8 @@
2929
3030 ds = ldapSupportLib.connect()
3131
32 - # w00t We're in!
33 - try:
 32+ # w00t We're in!
 33+ try:
3434 username = args[0]
3535 dn = 'uid=' + username + ',ou=people,' + base
3636 while True:
@@ -42,11 +42,11 @@
4343 mod_attrs = [( ldap.MOD_REPLACE, 'userPassword', newpass )]
4444 ds.modify_s(dn, mod_attrs)
4545 except ldap.UNWILLING_TO_PERFORM, msg:
46 - sys.stderr.write("LDAP was unwilling to change the user's password. Error was: %s\n" % msg[0]["info"])
 46+ sys.stderr.write("LDAP was unwilling to change the user's password. Error was: %s\n" % msg[0]["info"])
4747 ds.unbind()
4848 sys.exit(1)
4949 except ldap.NO_SUCH_OBJECT:
50 - sys.stderr.write("The user you are trying to modify does not exists.\n")
 50+ sys.stderr.write("The user you are trying to modify does not exists.\n")
5151 ds.unbind()
5252 sys.exit(1)
5353 except ldap.PROTOCOL_ERROR:
@@ -54,17 +54,17 @@
5555 traceback.print_exc(file=sys.stderr)
5656 ds.unbind()
5757 sys.exit(1)
58 - except Exception:
 58+ except Exception:
5959 try:
60 - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
 60+ sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
6161 traceback.print_exc(file=sys.stderr)
6262 ds.unbind()
6363 except Exception:
64 - sys.stderr.write("Also failed to unbind.\n")
 64+ sys.stderr.write("Also failed to unbind.\n")
6565 traceback.print_exc(file=sys.stderr)
6666 sys.exit(1)
6767
68 - ds.unbind()
 68+ ds.unbind()
6969 sys.exit(0)
7070
7171 if __name__ == "__main__":
Index: trunk/tools/subversion/user-management/delete-ldap-group
@@ -3,14 +3,14 @@
44 from optparse import OptionParser
55
66 try:
7 - import ldap
 7+ import ldap
88 import ldap.modlist
99 except ImportError:
10 - sys.stderr.write("Unable to import LDAP library.\n")
11 - sys.exit(1)
 10+ sys.stderr.write("Unable to import LDAP library.\n")
 11+ sys.exit(1)
1212
1313 def main():
14 - parser = OptionParser(conflict_handler="resolve")
 14+ parser = OptionParser(conflict_handler="resolve")
1515 parser.set_usage('delete-ldap-group [options] <username>')
1616
1717 ldapSupportLib = ldapsupportlib.LDAPSupportLib()
@@ -28,17 +28,17 @@
2929
3030 ds = ldapSupportLib.connect()
3131
32 - # w00t We're in!
33 - try:
 32+ # w00t We're in!
 33+ try:
3434 groupname = args[0]
3535 dn = 'cn=' + groupname + ',ou=group,' + base
3636 ds.delete_s(dn)
3737 except ldap.UNWILLING_TO_PERFORM, msg:
38 - sys.stderr.write("LDAP was unwilling to delete the group. Error was: %s\n" % msg[0]["info"])
 38+ sys.stderr.write("LDAP was unwilling to delete the group. Error was: %s\n" % msg[0]["info"])
3939 ds.unbind()
4040 sys.exit(1)
4141 except ldap.NO_SUCH_OBJECT:
42 - sys.stderr.write("The group you are trying to delete does not exists.\n")
 42+ sys.stderr.write("The group you are trying to delete does not exists.\n")
4343 ds.unbind()
4444 sys.exit(1)
4545 except ldap.PROTOCOL_ERROR:
@@ -46,17 +46,17 @@
4747 traceback.print_exc(file=sys.stderr)
4848 ds.unbind()
4949 sys.exit(1)
50 - except Exception:
 50+ except Exception:
5151 try:
52 - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
 52+ sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
5353 traceback.print_exc(file=sys.stderr)
5454 ds.unbind()
5555 except Exception:
56 - sys.stderr.write("Also failed to unbind.\n")
 56+ sys.stderr.write("Also failed to unbind.\n")
5757 traceback.print_exc(file=sys.stderr)
5858 sys.exit(1)
5959
60 - ds.unbind()
 60+ ds.unbind()
6161 sys.exit(0)
6262
6363 if __name__ == "__main__":
Index: trunk/tools/subversion/user-management/ldapsupportlib.py
@@ -2,10 +2,10 @@
33 import os, traceback, getpass, sys
44
55 try:
6 - import ldap
 6+ import ldap
77 except ImportError:
8 - sys.stderr.write("Unable to import LDAP library.\n")
9 - sys.exit(1)
 8+ sys.stderr.write("Unable to import LDAP library.\n")
 9+ sys.exit(1)
1010
1111 class LDAPSupportLib:
1212
Index: trunk/tools/subversion/user-management/delete-ldap-user
@@ -3,14 +3,14 @@
44 from optparse import OptionParser
55
66 try:
7 - import ldap
 7+ import ldap
88 import ldap.modlist
99 except ImportError:
10 - sys.stderr.write("Unable to import LDAP library.\n")
11 - sys.exit(1)
 10+ sys.stderr.write("Unable to import LDAP library.\n")
 11+ sys.exit(1)
1212
1313 def main():
14 - parser = OptionParser(conflict_handler="resolve")
 14+ parser = OptionParser(conflict_handler="resolve")
1515 parser.set_usage('delete-ldap-user [options] <username>')
1616
1717 ldapSupportLib = ldapsupportlib.LDAPSupportLib()
@@ -29,8 +29,8 @@
3030
3131 ds = ldapSupportLib.connect()
3232
33 - # w00t We're in!
34 - try:
 33+ # w00t We're in!
 34+ try:
3535 username = args[0]
3636 dn = 'uid=' + username + ',ou=people,' + base
3737 ds.delete_s(dn)
@@ -39,11 +39,11 @@
4040 hdm = homedirectorymanager.HomeDirectoryManager()
4141 hdm.deleteUser(username)
4242 except ldap.UNWILLING_TO_PERFORM, msg:
43 - sys.stderr.write("LDAP was unwilling to delete the user. Error was: %s\n" % msg[0]["info"])
 43+ sys.stderr.write("LDAP was unwilling to delete the user. Error was: %s\n" % msg[0]["info"])
4444 ds.unbind()
4545 sys.exit(1)
4646 except ldap.NO_SUCH_OBJECT:
47 - sys.stderr.write("The user you are trying to delete does not exists.\n")
 47+ sys.stderr.write("The user you are trying to delete does not exists.\n")
4848 ds.unbind()
4949 sys.exit(1)
5050 except ldap.PROTOCOL_ERROR:
@@ -51,17 +51,17 @@
5252 traceback.print_exc(file=sys.stderr)
5353 ds.unbind()
5454 sys.exit(1)
55 - except Exception:
 55+ except Exception:
5656 try:
57 - sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
 57+ sys.stderr.write("There was a general error, this is unexpected; see traceback.\n")
5858 traceback.print_exc(file=sys.stderr)
5959 ds.unbind()
6060 except Exception:
61 - sys.stderr.write("Also failed to unbind.\n")
 61+ sys.stderr.write("Also failed to unbind.\n")
6262 traceback.print_exc(file=sys.stderr)
6363 sys.exit(1)
6464
65 - ds.unbind()
 65+ ds.unbind()
6666 sys.exit(0)
6767
6868 if __name__ == "__main__":
Index: trunk/tools/subversion/user-management/ldaplist
@@ -3,10 +3,10 @@
44 from optparse import OptionParser
55
66 try:
7 - import ldap
 7+ import ldap
88 except ImportError:
9 - sys.stderr.write("Unable to import LDAP library.\n")
10 - sys.exit(1)
 9+ sys.stderr.write("Unable to import LDAP library.\n")
 10+ sys.exit(1)
1111
1212 def main():
1313 "An application that implements the functionality of Solaris's ldaplist."
@@ -105,23 +105,23 @@
106106 attributes = options.showattributes
107107 print "+++ database=" + database
108108 print "+++ filter=(&(objectclass=" + objectclass + ")(" + attribute + searchoperator + searchkey + ")) " + attributes
109 - PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(&(objectclass=" + objectclass + ")(" + attribute + searchoperator + searchkey + "))",attrlist)
 109+ PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(&(objectclass=" + objectclass + ")(" + attribute + searchoperator + searchkey + "))",attrlist)
110110 else:
111111 if options.verbose:
112112 print "(objectclass=" + objectclass + ")"
113 - PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(objectclass=" + objectclass + ")")
 113+ PosixData = ds.search_s(base,ldap.SCOPE_SUBTREE,"(objectclass=" + objectclass + ")")
114114 except ldap.NO_SUCH_OBJECT:
115 - sys.stderr.write("Object not found. If you are trying to use * in your search, make sure that you wrap your string in single quotes to avoid shell expansion.\n")
116 - ds.unbind()
117 - sys.exit(1)
 115+ sys.stderr.write("Object not found. If you are trying to use * in your search, make sure that you wrap your string in single quotes to avoid shell expansion.\n")
 116+ ds.unbind()
 117+ sys.exit(1)
118118 except ldap.PROTOCOL_ERROR:
119 - sys.stderr.write("The search returned a protocol error, this shouldn't ever happen, please submit a trouble ticket.\n")
120 - ds.unbind()
121 - sys.exit(1)
 119+ sys.stderr.write("The search returned a protocol error, this shouldn't ever happen, please submit a trouble ticket.\n")
 120+ ds.unbind()
 121+ sys.exit(1)
122122 except Exception:
123 - sys.stderr.write("The search returned an error.\n")
124 - ds.unbind()
125 - sys.exit(1)
 123+ sys.stderr.write("The search returned an error.\n")
 124+ ds.unbind()
 125+ sys.exit(1)
126126
127127 PosixData.sort()
128128 # /End of stolen stuff
@@ -156,9 +156,9 @@
157157 for i in range(len(PosixData)):
158158 print ""
159159 if not options.longlisting:
160 - print "dn: " + PosixData[i][0]
 160+ print "dn: " + PosixData[i][0]
161161 else:
162 - print "dn: " + PosixData[i][0]
 162+ print "dn: " + PosixData[i][0]
163163 for (k,v) in PosixData[i][1].items():
164164 if len(v) > 1:
165165 for v2 in v:

Status & tagging log