jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/762107 )
Change subject: pywikibot: Add support for chunked uploading in imagetransfer.py
......................................................................
pywikibot: Add support for chunked uploading in imagetransfer.py
Support for -asynchronous and -chunk_size flags were added to upload.py
in e68f619. This patch adds the same options to imagetransfer.py and just
maps them to the corresponding UploadBot parameters.
Bug: T300531
Change-Id: I46c1a2484475075921888d4782ec25715fa5271c
---
M scripts/imagetransfer.py
1 file changed, 16 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index 98743a2..c25e8bc 100755
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -22,6 +22,10 @@
-force_if_shared Upload the file to the target, even if it exists on that
wiki's shared repo
+ -asynchronous Upload to stash.
+
+ -chunk_size:n Upload in chunks of n bytes.
+
-file:z Upload many files from textfile: [[Image:x]]
[[Image:y]]
@@ -144,6 +148,8 @@
'keepname': False,
'target': None,
'force_if_shared': False,
+ 'asynchronous': False,
+ 'chunk_size': 0,
}
def __init__(self, **kwargs):
@@ -162,6 +168,10 @@
shared to the target site (e.g. when moving from Commons to another
wiki)
:type force_if_shared: boolean
+ :keyword asynchronous: Upload to stash.
+ :type asynchronous: boolean
+ :keyword chunk_size: Upload in chunks of this size bytes.
+ :type chunk_size: integer
"""
super().__init__(**kwargs)
if self.opt.target is None:
@@ -217,7 +227,9 @@
keep_filename=self.opt.keepname,
verify_description=not self.opt.keepname,
ignore_warning=self.opt.ignore_warning,
- force_if_shared=self.opt.force_if_shared)
+ force_if_shared=self.opt.force_if_shared,
+ asynchronous=self.opt.asynchronous,
+ chunk_size=self.opt.chunk_size)
# try to upload
if bot.skip_run():
@@ -347,7 +359,7 @@
for arg in local_args:
opt, _, value = arg.partition(':')
if opt in ('-ignore_warning', '-interwiki', '-keepname',
- '-force_if_shared'):
+ '-force_if_shared', '-asynchronous'):
options[opt[1:]] = True
elif opt == '-tolang':
target_code = value
@@ -355,6 +367,8 @@
target_family = value
elif opt == '-tosite':
options['target'] = value
+ elif opt == '-chunk_size':
+ options['chunk_size'] = value
else:
generator_factory.handle_arg(arg)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/762107
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: I46c1a2484475075921888d4782ec25715fa5271c
Gerrit-Change-Number: 762107
Gerrit-PatchSet: 1
Gerrit-Owner: Xover <xover(a)pobox.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.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/+/762101 )
Change subject: pywikibot: Fix KeyError in create_warnings_list
......................................................................
pywikibot: Fix KeyError in create_warnings_list
create_warnings_list() was looking for an offset entry in the passed-in
response dict which is (no longer?) being set for that code path. This
patch uses the _offest argument to upload() instead.
Bug: T301610
Change-Id: Ibe63befb6f80a0831adee446c66c4fb875ff0b1d
---
M pywikibot/site/_apisite.py
1 file changed, 2 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 305dc01..faf8f03 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2954,11 +2954,8 @@
_file_key = None
if not report_success:
- if source_filename:
- offset = result.setdefault('offset', True)
- else:
- offset = False
-
+ result.setdefault('offset', bool(source_filename))
+ offset = result['offset'] if source_filename else False
if ignore_warnings(create_warnings_list(result)):
return self.upload(
filepage, source_filename=source_filename,
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/762101
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: Ibe63befb6f80a0831adee446c66c4fb875ff0b1d
Gerrit-Change-Number: 762101
Gerrit-PatchSet: 2
Gerrit-Owner: Xover <xover(a)pobox.com>
Gerrit-Reviewer: Inductiveload <inductiveload(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Welcome, new contributor! <ssethi(a)wikimedia.org>
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/761342 )
Change subject: [cleanup] remove deprecated http.get_fake_user_agent() function
......................................................................
[cleanup] remove deprecated http.get_fake_user_agent() function
- http.get_fake_user_agent() function is nowhere used in the framework
and deprecated for over 5 years.
- also config.fake_user_agent isn't used anywhere in the famework an
is deprecated for years; it can be removed.
- remove GetFakeUserAgentTestCase
Change-Id: I30f5ffffd0a5c81c06ce68608bfb412f12238a09
---
M pywikibot/comms/http.py
M pywikibot/config.py
M tests/http_tests.py
3 files changed, 2 insertions(+), 60 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 6a99a24..ad635a0 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -22,7 +22,7 @@
:py:obj:`flush()` can be called to close the session object.
"""
#
-# (C) Pywikibot team, 2007-2021
+# (C) Pywikibot team, 2007-2022
#
# Distributed under the terms of the MIT license.
#
@@ -48,10 +48,7 @@
Server504Error,
)
from pywikibot.logging import critical, debug, error, log, warning
-from pywikibot.tools import (
- deprecated,
- file_mode_checker,
-)
+from pywikibot.tools import file_mode_checker
try:
@@ -194,22 +191,6 @@
return formatted
-@deprecated('pywikibot.comms.http.fake_user_agent', since='20161205')
-def get_fake_user_agent():
- """
- Return a fake user agent depending on `fake_user_agent` option in config.
-
- Deprecated, use fake_user_agent() instead.
-
- :rtype: str
- """
- if isinstance(config.fake_user_agent, str):
- return config.fake_user_agent
- if config.fake_user_agent is False:
- return user_agent()
- return fake_user_agent()
-
-
def fake_user_agent() -> str:
"""Return a fake user agent."""
try:
diff --git a/pywikibot/config.py b/pywikibot/config.py
index 09c185f..a60dad2 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -159,8 +159,6 @@
# Example: {'problematic.site.example': True,
# 'prefers.specific.ua.example': 'snakeoil/4.2'}
fake_user_agent_exceptions = {} # type: Dict[str, Union[bool, str]]
-# This following option is deprecated in favour of finer control options above.
-fake_user_agent = False
# The default interface for communicating with the site
# currently the only defined interface is 'APISite', so don't change this!
diff --git a/tests/http_tests.py b/tests/http_tests.py
index 62b066e..d52dd1a 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -303,43 +303,6 @@
self._test_fetch_use_fake_user_agent()
-class GetFakeUserAgentTestCase(TestCase):
-
- """Test the deprecated get_fake_user_agent()."""
-
- net = False
-
- def setUp(self):
- """Set up unit test."""
- self.orig_fake_user_agent = config.fake_user_agent
- super().setUp()
-
- def tearDown(self):
- """Tear down unit test."""
- config.fake_user_agent = self.orig_fake_user_agent
- super().tearDown()
-
- def _test_config_settings(self):
- """Test if method honours configuration toggle."""
- with suppress_warnings(r'.*?get_fake_user_agent is deprecated'):
- # ON: True and None in config are considered turned on.
- config.fake_user_agent = True
- self.assertNotEqual(http.get_fake_user_agent(), http.user_agent())
- config.fake_user_agent = None
- self.assertNotEqual(http.get_fake_user_agent(), http.user_agent())
-
- # OFF: All other values won't make it return random UA.
- config.fake_user_agent = False
- self.assertEqual(http.get_fake_user_agent(), http.user_agent())
- config.fake_user_agent = 'ARBITRARY'
- self.assertEqual(http.get_fake_user_agent(), 'ARBITRARY')
-
- @require_modules('fake_useragent')
- def test_with_fake_useragent(self):
- """Test method with fake_useragent module."""
- self._test_config_settings()
-
-
class CharsetTestCase(TestCase):
"""Test that HttpRequest correct handles the charsets given."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/761342
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: I30f5ffffd0a5c81c06ce68608bfb412f12238a09
Gerrit-Change-Number: 761342
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: MtDu <justin.d128(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/761754 )
Change subject: [doc] Update documentation
......................................................................
[doc] Update documentation
* Update redirected URLs
Change-Id: Ia5300b56c7bd2aac6e3c9a9d509d3c4002e69af7
---
M .github/workflows/login_tests-ci.yml
M .github/workflows/pywikibot-ci.yml
2 files changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.github/workflows/login_tests-ci.yml b/.github/workflows/login_tests-ci.yml
index 95fda73..0dd1eb6 100644
--- a/.github/workflows/login_tests-ci.yml
+++ b/.github/workflows/login_tests-ci.yml
@@ -1,6 +1,6 @@
# This workflow will install Python dependencies, run Pywikibot tests
# with a variety of Python versions. For more information see:
-# https://help.github.com/actions/language-and-framework-guides/using-python-…
+# https://docs.github.com/en/actions/automating-builds-and-tests/building-and…
name: Login CI
diff --git a/.github/workflows/pywikibot-ci.yml b/.github/workflows/pywikibot-ci.yml
index 62a757e..ca92152 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -1,6 +1,6 @@
# This workflow will install Python dependencies, run Pywikibot tests
# with a variety of Python versions. For more information see:
-# https://help.github.com/actions/language-and-framework-guides/using-python-…
+# https://docs.github.com/en/actions/automating-builds-and-tests/building-and…
name: Pywikibot CI
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/761754
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: Ia5300b56c7bd2aac6e3c9a9d509d3c4002e69af7
Gerrit-Change-Number: 761754
Gerrit-PatchSet: 2
Gerrit-Owner: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged