http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11342
Revision: 11342 Author: valhallasw Date: 2013-04-05 18:42:57 +0000 (Fri, 05 Apr 2013) Log Message: ----------- Bugfix: actually login users that run login.py
Users were only logged in when they explicitly called -force, while calling -force did not actually ask users that were logged in to re-authenticate.
Calling login.py *without* -force now asks the user to log in (or displays a message when this is already the case). Calling login.py *with* -force displays a warning message with a description of how to logout (by deleting the cookie file).
Modified Paths: -------------- branches/rewrite/scripts/login.py
Modified: branches/rewrite/scripts/login.py =================================================================== --- branches/rewrite/scripts/login.py 2013-04-05 16:23:21 UTC (rev 11341) +++ branches/rewrite/scripts/login.py 2013-04-05 18:42:57 UTC (rev 11342) @@ -55,7 +55,6 @@ password = None sysop = False logall = False - forceLogin = False for arg in pywikibot.handleArgs(*args): if arg.startswith("-pass"): if len(arg) == 5: @@ -68,7 +67,8 @@ elif arg == "-all": logall = True elif arg == "-force": - forceLogin = True + pywikibot.output(u"To force a re-login, please delete the revelant lines from '%s' (or the entire file) and try again." % + os.path.join(config.base_dir, 'pywikibot.lwp')) else: pywikibot.showHelp('login') return @@ -84,11 +84,11 @@ for lang in namedict[familyName]: try: site = pywikibot.getSite(code=lang, fam=familyName) - if forceLogin: - site.login() - if site.logged_in(sysop) \ - and site.user() == site.username(sysop): - pywikibot.output(u"Login successful on %(site)s." % locals()) + site.login() + + user = site.user() + if user: + pywikibot.output(u"Logged in on %(site)s as %(user)s." % locals()) else: pywikibot.output(u"Not logged in on %(site)s." % locals()) except NoSuchSite:
pywikipedia-svn@lists.wikimedia.org