jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1157612?usp=email )
Change subject: IMPR: Add -cookies option to login script to login with cookies
files only
......................................................................
IMPR: Add -cookies option to login script to login with cookies files only
Change-Id: If38a806c9b222d39b50f7b464c3a4fb7b5985ab9
---
M pywikibot/scripts/login.py
1 file changed, 11 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/scripts/login.py b/pywikibot/scripts/login.py
index a940fca..74c1583 100755
--- a/pywikibot/scripts/login.py
+++ b/pywikibot/scripts/login.py
@@ -9,6 +9,8 @@
-all Try to log in on all sites where a username is defined in
user config file (user-config.py).
+-cookies Only login from cookies file, don't ask for password
+
-logout Log out of the current site. Combine with ``-all`` to log
out of all sites, or with :ref:`global options` ``-family``,
``-lang`` or ``-site`` to log out of a specific site.
@@ -46,6 +48,8 @@
*-async* option was added.
.. versionchanged:: 10.2
wildcard site codes in ``usernames`` dict are supported.
+.. versionchanged:: 10.3
+ the -cookies option
"""
#
# (C) Pywikibot team, 2003-2025
@@ -95,7 +99,8 @@
)
-def login_one_site(code, family, oauth, logout, autocreate) -> None:
+def login_one_site(code: str, family: str, oauth: bool, logout: bool,
+ autocreate: bool, cookies: bool) -> None:
"""Login on one site."""
try:
site = pywikibot.Site(code, family)
@@ -112,7 +117,7 @@
site.logout()
else:
try:
- site.login(autocreate=autocreate)
+ site.login(autocreate=autocreate, cookie_only=cookies)
except NoUsernameError as e:
pywikibot.error(e)
@@ -137,6 +142,7 @@
oauth = False
autocreate = False
asynchronous = False
+ cookies = False
unknown_args = []
for arg in pywikibot.handle_args(args):
if arg == '-all':
@@ -149,6 +155,8 @@
autocreate = True
elif arg == '-async':
asynchronous = True
+ elif arg == '-cookies':
+ cookies = True
else:
unknown_args.append(arg)
@@ -161,7 +169,7 @@
site = pywikibot.Site()
namedict = {site.family.name: {site.code: None}}
- params = oauth, logout, autocreate
+ params = oauth, logout, autocreate, cookies
context = (nullcontext(),
BoundedPoolExecutor('ThreadPoolExecutor'))[asynchronous]
with context as executor:
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1157612?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If38a806c9b222d39b50f7b464c3a4fb7b5985ab9
Gerrit-Change-Number: 1157612
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]