jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/640724 )
Change subject: [bugfix] fix import of httplib after release of requests 2.25
......................................................................
[bugfix] fix import of httplib after release of requests 2.25
Requests v2,25 uses urllib3 1.26, which has removed the export of
httplib from urllib3/response.py.
Use httplib in urllib3.util.response then.
Bug: T267762
Change-Id: I220675cdc61bf508b346c9db2f3f8b5fa9f5d939
---
M pywikibot/comms/eventstreams.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py
index e354ffb..456b35e 100644
--- a/pywikibot/comms/eventstreams.py
+++ b/pywikibot/comms/eventstreams.py
@@ -22,7 +22,7 @@
from requests import __version__ as requests_version
from requests.packages.urllib3.exceptions import ProtocolError
-from requests.packages.urllib3.response import httplib
+from requests.packages.urllib3.util.response import httplib
try:
from sseclient import SSEClient as EventSource
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/640724
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I220675cdc61bf508b346c9db2f3f8b5fa9f5d939
Gerrit-Change-Number: 640724
Gerrit-PatchSet: 2
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/640171 )
Change subject: [doc] Improved doc string for logging.py function
......................................................................
[doc] Improved doc string for logging.py function
Extended doc strings for logging.py functions such as error, exception,
stdout, log, critical and debug.
Bug: T85271
Change-Id: I265a5258d711a6e038b1974e4f1cf29fd5c0f650
---
M pywikibot/logging.py
1 file changed, 51 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/logging.py b/pywikibot/logging.py
index ed4e842..457e276 100644
--- a/pywikibot/logging.py
+++ b/pywikibot/logging.py
@@ -137,7 +137,15 @@
def stdout(text, decoder=None, newline=True, **kwargs):
- """Output script results to the user via the userinterface."""
+ """Output script results to the user via the userinterface.
+
+ @param text: the message printed via stdout logger to the user.
+ @param decoder: If None, text should be a unicode string else it should
+ be encoded in the given encoding.
+ @param newline: If True, a line feed will be added after printing the text.
+ @param kwargs: The keyword arguments can be found in the python doc:
+ https://docs.python.org/3/howto/logging-cookbook.html.
+ """
logoutput(text, decoder, newline, STDOUT, **kwargs)
@@ -146,7 +154,7 @@
"""Output a warning message to the user via the userinterface.
@param text: the message the user wants to display.
- @param decoder: If None, text should be a unicode string. Otherwise it
+ @param decoder: If None, text should be a unicode string else it
should be encoded in the given encoding.
@param newline: If True, a line feed will be added after printing the text.
@param kwargs: The keyword arguments can be found in the python doc:
@@ -156,23 +164,53 @@
def error(text, decoder=None, newline=True, **kwargs):
- """Output an error message to the user via the userinterface."""
+ """Output an error message to the user via the userinterface.
+
+ @param text: the message containing the error which occured.
+ @param decoder: If None, text should be a unicode string else it should
+ be encoded in the given encoding.
+ @param newline: If True, a line feed will be added after printing the text.
+ @param kwargs: The keyword arguments can be found in the python doc:
+ https://docs.python.org/3/howto/logging-cookbook.html.
+ """
logoutput(text, decoder, newline, ERROR, **kwargs)
def log(text, decoder=None, newline=True, **kwargs):
- """Output a record to the log file."""
+ """Output a record to the log file.
+
+ @param text: the message which is to be logged to the log file.
+ @param decoder: If None, text should be a unicode string else it should
+ be encoded in the given encoding.
+ @param newline: If True, a line feed will be added after printing the text.
+ @param kwargs: The keyword arguments can be found in the python doc:
+ https://docs.python.org/3/howto/logging-cookbook.html.
+ """
logoutput(text, decoder, newline, VERBOSE, **kwargs)
def critical(text, decoder=None, newline=True, **kwargs):
- """Output a critical record to the user via the userinterface."""
+ """Output a critical record to the user via the userinterface.
+
+ @param text: the critical message which is to be displayed to the user.
+ @param decoder: If None, text should be a unicode string else it should
+ be encoded in the given encoding.
+ @param newline: If True, a line feed will be added after printing the text.
+ @param kwargs: The keyword arguments can be found in the python doc:
+ https://docs.python.org/3/howto/logging-cookbook.html.
+ """
logoutput(text, decoder, newline, CRITICAL, **kwargs)
def debug(text, layer, decoder=None, newline=True, **kwargs):
"""Output a debug record to the log file.
+ @param text: the message of the debug record to be logged to the log file.
+ @param decoder: If None, text should be a unicode string else it should
+ be encoded in the given encoding.
+ @param newline: If True, a line feed will be added after printing the text.
+ @param kwargs: The keyword arguments can be found in the python doc:
+ https://docs.python.org/3/howto/logging-cookbook.html.
@param layer: The name of the logger that text will be sent to.
"""
logoutput(text, decoder, newline, DEBUG, layer, **kwargs)
@@ -195,6 +233,14 @@
pywikibot.exception(e)
...
+ This function should only be called from an Exception handler.
+
+ @param msg: If not None,contains the description of the exception occured.
+ @param decoder: If None, text should be a unicode string else it should
+ be encoded in the given encoding.
+ @param newline: If True, a line feed will be added after printing the text.
+ @param kwargs: The keyword arguments can be found in the python doc:
+ https://docs.python.org/3/howto/logging-cookbook.html.
@param tb: Set to True in order to output traceback also.
"""
if isinstance(msg, BaseException):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/640171
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I265a5258d711a6e038b1974e4f1cf29fd5c0f650
Gerrit-Change-Number: 640171
Gerrit-PatchSet: 9
Gerrit-Owner: Homeboy 445 <akshitsan13(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/640437 )
Change subject: [IMPR] revertbot.py: use site.rollbackpage() method
......................................................................
[IMPR] revertbot.py: use site.rollbackpage() method
Bug: T106646
Change-Id: I159b7792b095b4fbb8c77a811aee6bc2ce272303
---
M pywikibot/site/__init__.py
M scripts/revertbot.py
2 files changed, 26 insertions(+), 25 deletions(-)
Approvals:
Meno25: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py
index 9526291..ee5f949 100644
--- a/pywikibot/site/__init__.py
+++ b/pywikibot/site/__init__.py
@@ -4871,27 +4871,30 @@
one that is not by the same user who made the last edit.
@param page: the Page to be rolled back (must exist)
-
+ @keyword user: the last user to be rollbacked;
+ default is page.latest_revision.user
"""
if len(page._revisions) < 2:
raise Error(
- 'Rollback of %s aborted; load revision history first.'
- % page.title(as_link=True))
- last_rev = page.latest_revision
- last_user = last_rev.user
+ 'Rollback of {} aborted; load revision history first.'
+ .format(page))
+
+ user = kwargs.pop('user', page.latest_revision.user)
for rev in sorted(page._revisions.values(), reverse=True,
key=lambda r: r.timestamp):
# start with most recent revision first
- if rev.user != last_user:
+ if rev.user != user:
break
else:
raise Error(
- 'Rollback of %s aborted; only one user in revision history.'
- % page.title(as_link=True))
- parameters = merge_unique_dicts(kwargs, action='rollback',
+ 'Rollback of {} aborted; only one user in revision history.'
+ .format(page))
+
+ parameters = merge_unique_dicts(kwargs,
+ action='rollback',
title=page,
token=self.tokens['rollback'],
- user=last_user)
+ user=user)
self.lock_page(page)
req = self._simple_request(**parameters)
try:
diff --git a/scripts/revertbot.py b/scripts/revertbot.py
index 38c071c..a5f5819 100755
--- a/scripts/revertbot.py
+++ b/scripts/revertbot.py
@@ -46,6 +46,8 @@
import pywikibot
from pywikibot.bot import OptionHandler
+from pywikibot.data import api
+from pywikibot.exceptions import Error
from pywikibot import i18n
from pywikibot.tools import deprecate_arg
from pywikibot.tools.formatter import color_format
@@ -123,25 +125,21 @@
page.save(comment)
return comment
- params = {
- 'action': 'rollback',
- 'title': page,
- 'user': self.user,
- 'token': self.site.tokens['rollback'],
- 'markbot': True,
- }
try:
- r = pywikibot.data.api.Request(self.site, parameters=params)
- r.submit()
- except pywikibot.data.api.APIError as e:
+ self.site.rollbackpage(page, user=self.user, markbot=True)
+ except api.APIError as e:
if e.code == 'badtoken':
pywikibot.error(
'There was an API token error rollbacking the edit')
- else:
- pywikibot.exception()
- return False
- return 'The edit(s) made in {} by {} was rollbacked'.format(
- page.title(), self.user)
+ return False
+ except Error:
+ pass
+ else:
+ return 'The edit(s) made in {} by {} was rollbacked'.format(
+ page.title(), self.user)
+
+ pywikibot.exception()
+ return False
def log(self, msg) -> None:
"""Log the message msg."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/640437
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I159b7792b095b4fbb8c77a811aee6bc2ce272303
Gerrit-Change-Number: 640437
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged