r96394 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96393‎ | r96394 | r96395 >
Date:01:18, 7 September 2011
Author:laner
Status:deferred
Tags:
Comment:
Switch to using mwclient to log into wiki. Add missing libraries. Fix script paths.
Modified paths:
  • /trunk/tools/subversion/user-management/add-labs-user (modified) (history)

Diff [purge]

Index: trunk/tools/subversion/user-management/add-labs-user
@@ -1,5 +1,5 @@
22 #!/usr/bin/python
3 -import sys, subprocess, ldapsupportlib
 3+import sys, subprocess, ldapsupportlib, scriptconfig, mwclient
44 from optparse import OptionParser
55
66 def main():
@@ -19,25 +19,18 @@
2020 username = args[0]
2121
2222 # Set a random password for the user
23 - passwdargs = ['/usr/local/bin/change-ldap-passwd', '--random', username]
 23+ passwdargs = ['/usr/local/sbin/change-ldap-passwd', '--random', username]
2424 passwd = subprocess.Popen(passwdargs, stdout=subprocess.PIPE).communicate()[0]
2525
2626 # Set the user's CN and email address
27 - passwdargs = ['/usr/local/bin/modify-ldap-user', '--cn=' + options.wikiname, '--mail=' + options.mail, username]
 27+ passwdargs = ['/usr/local/sbin/modify-ldap-user', '--cn=' + options.wikiname, '--mail=' + options.mail, username]
2828 ignore = subprocess.Popen(passwdargs, stdout=subprocess.PIPE).communicate()[0]
2929
3030 # Do an initial log in as the user, which will cause the wiki to create an account
3131 # for the user.
32 - data = {'action': 'login',
33 - 'lgname': username,
34 - 'lgpassword': passwd,
35 - 'lgdomain': scriptconfig.domain
36 - }
37 - postdata = urllib.urlencode(data)
38 - resp = urllib.urlopen(scriptconfig.controllerapiurl, data=postdata)
39 - if resp.code != 200:
40 - print resp.read()
41 - resp.close()
 32+ url = urlparse.urlparse(scriptconfig.controllerapiurl)
 33+ site = mwclient.Site((url.scheme, url.hostname))
 34+ site.login(username, passwd, domain=scriptconfig.domain)
4235
4336 if __name__ == "__main__":
4437 main()

Status & tagging log