jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/400190 )
Change subject: [doc] Show new features in HISTORY.rst
......................................................................
[doc] Show new features in HISTORY.rst
Change-Id: Idb525810ce7b17bd4e7615dc8e17d8f5dae8e121
---
M HISTORY.rst
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index ab4bc4d..71052a5 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,8 @@
Current release
---------------
+* Maintenance script to download Wikimedia database dump
+* Option to auto-create accounts when logging in
* Ship wikimania family file
* Drop battlestarwiki family file
* Bugfixes and improvements
--
To view, visit https://gerrit.wikimedia.org/r/400190
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idb525810ce7b17bd4e7615dc8e17d8f5dae8e121
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/399555 )
Change subject: replaceCategoryLinks: prevent failing on dewiki with {{Personendaten}}
......................................................................
replaceCategoryLinks: prevent failing on dewiki with {{Personendaten}}
The script involving replaceCategoryLinks should not break
but instead should skip the page on German Wikipedia with
{{Personendaten}} template
Bug: T151541
Change-Id: I7033d6ab781fcadc7bf1a77a1b51f313b1c62092
---
M pywikibot/textlib.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index ebb72a9..cedb30d 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1227,11 +1227,12 @@
if site is None:
site = pywikibot.Site()
if site.sitename == 'wikipedia:de' and '{{Personendaten' in oldtext:
- raise pywikibot.Error(
+ pywikibot.error(
'The Pywikibot is no longer allowed to touch categories on the '
'German\nWikipedia on pages that contain the Personendaten '
'template because of the\nnon-standard placement of that template.\n'
'See https://de.wikipedia.org/wiki/Hilfe:Personendaten#Kopiervorlage')
+ return oldtext
separator = site.family.category_text_separator
iseparator = site.family.interwiki_text_separator
separatorstripped = separator.strip()
--
To view, visit https://gerrit.wikimedia.org/r/399555
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7033d6ab781fcadc7bf1a77a1b51f313b1c62092
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Eflyjason <eflyjason(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/399625 )
Change subject: Add option to auto-create accounts when logging in
......................................................................
Add option to auto-create accounts when logging in
Bug: T183466
Change-Id: I781e57dfb4d04e7900686b90b17eee502f599094
---
M pywikibot/login.py
M pywikibot/site.py
M scripts/login.py
3 files changed, 28 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/login.py b/pywikibot/login.py
index dafcb84..d3b4f93 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -283,19 +283,24 @@
else:
warn('Invalid password format', _PasswordFileWarning)
- def login(self, retry=False):
+ def login(self, retry=False, autocreate=False):
"""
Attempt to log into the server.
@param retry: infinitely retry if the API returns an unknown error
@type retry: bool
+ @param autocreate: if true, allow auto-creation of the account
+ using unified login
+ @type autocreate: bool
+
@raises NoUsername: Username is not recognised by the site.
"""
if not self.password:
# First check that the username exists,
# to avoid asking for a password that will not work.
- self.check_user_exists()
+ if not autocreate:
+ self.check_user_exists()
# As we don't want the password to appear on the screen, we set
# password = True
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 9b82484..9794b6e 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2038,10 +2038,18 @@
auth_token = get_authentication(self.base_url(''))
return auth_token is not None and len(auth_token) == 4
- def login(self, sysop=False):
+ def login(self, sysop=False, autocreate=False):
"""
Log the user in if not already logged in.
+ @param sysop: if true, log in with the sysop account.
+ @type sysop: bool
+
+ @param autocreate: if true, allow auto-creation of the account
+ using unified login
+ @type autocreate: bool
+
+ @raises NoUsername: Username is not recognised by the site.
U{https://www.mediawiki.org/wiki/API:Login}
"""
# TODO: this should include an assert that loginstatus
@@ -2075,6 +2083,10 @@
# May occur if you are not logged in (no API read permissions).
except api.APIError:
pass
+ except NoUsername as e:
+ if not autocreate:
+ raise e
+
if self.is_oauth_token_available():
if sysop:
raise NoUsername('No sysop is permitted with OAuth')
@@ -2088,7 +2100,7 @@
raise NoUsername('Logging in on %s via OAuth failed' % self)
loginMan = api.LoginManager(site=self, sysop=sysop,
user=self._username[sysop])
- if loginMan.login(retry=True):
+ if loginMan.login(retry=True, autocreate=autocreate):
self._username[sysop] = loginMan.username
self.getuserinfo(force=True)
self._loginstatus = (LoginStatus.AS_SYSOP
diff --git a/scripts/login.py b/scripts/login.py
index 2adaf33..0868cce 100755
--- a/scripts/login.py
+++ b/scripts/login.py
@@ -40,6 +40,9 @@
manually. -logout, -pass, -force, -pass:XXXX and -sysop are not
compatible with -oauth.
+ -autocreate Auto-create an account using unified login when necessary.
+ Note: the global account must exist already before using this.
+
If not given as parameter, the script will ask for your username and
password (password entry will be hidden), log in to your home wiki using
this combination, and store the resulting cookies (containing your password
@@ -120,6 +123,7 @@
logall = False
logout = False
oauth = False
+ autocreate = False
unknown_args = []
for arg in pywikibot.handle_args(args):
if arg.startswith("-pass"):
@@ -141,6 +145,8 @@
logout = True
elif arg == '-oauth':
oauth = True
+ elif arg == '-autocreate':
+ autocreate = True
else:
unknown_args += [arg]
@@ -170,7 +176,7 @@
if logout:
site.logout()
else:
- site.login(sysop)
+ site.login(sysop, autocreate=autocreate)
user = site.user()
if user:
pywikibot.output(
--
To view, visit https://gerrit.wikimedia.org/r/399625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I781e57dfb4d04e7900686b90b17eee502f599094
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Whym <whym(a)whym.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Whym <whym(a)whym.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>