jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Upload: Use fake filename in MIME header
......................................................................
[FIX] Upload: Use fake filename in MIME header
The standard MIME request does only support ASCII characters in the
headers. As the value is apparently not interpreted it's replaced by
a dummy value, so Unicode characters in the file page name doesn't cause
pywikibot to receive an API error.
There is RFC2231 which is supported by both Python versions but not by
PHP on which the MediaWiki server rely (see bug: 73662). This does only
fix the uploads as it is unknown how to handle other MIME requests.
Bug: 73661
Change-Id: I5ea92dcf1115b675b56142494d805e75d389b7d4
---
M pywikibot/site.py
1 file changed, 4 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5b1399d..0093c79 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4460,6 +4460,8 @@
result = None
file_page_title = filepage.title(withNamespace=False)
if source_filename:
+ # TODO: Dummy value to allow also Unicode names, see bug 73661
+ mime_filename = 'FAKE-NAME'
# upload local file
# make sure file actually exists
if not os.path.isfile(source_filename):
@@ -4483,7 +4485,7 @@
mime_params={}, throttle=throttle)
req.mime_params['chunk'] = (chunk,
("application", "octet-stream"),
- {'filename': file_page_title})
+ {'filename': mime_filename})
if file_key:
req['filekey'] = file_key
try:
@@ -4518,7 +4520,7 @@
'mime_params': {
'file': (file_contents,
filetype.split('/'),
- {'filename': file_page_title})
+ {'filename': mime_filename})
}
}
req = api.Request(site=self, action="upload", token=token,
--
To view, visit https://gerrit.wikimedia.org/r/174677
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5ea92dcf1115b675b56142494d805e75d389b7d4
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Matanya <matanya(a)foss.co.il>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix tests after improvements in APISite.sametitle
......................................................................
Fix tests after improvements in APISite.sametitle
The preloading tests where written before APISite.sametitle
was improved, however they landed after the sametitle change.
As a result, most of the builds broke.
Change-Id: I3381d693fb3d03708bcb0218d0ad95d90f1f8002
---
M tests/site_tests.py
1 file changed, 6 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index ca605d8..e738859 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1685,6 +1685,7 @@
# preloadpages will send the page ids, as they have already been loaded
# by pagelinks, and preloadpages should complain the returned titles
# do not match any title in the pagelist.
+ # However, APISite.sametitle now correctly links them.
for page in links:
page._link._text += ' '
@@ -1693,8 +1694,8 @@
self.assertIsInstance(page, pywikibot.Page)
self.assertIsInstance(page.exists(), bool)
if page.exists():
- self.assertFalse(hasattr(page, "_text"))
- self.assertEqual(len(page._revisions), 0)
+ self.assertTrue(hasattr(page, "_text"))
+ self.assertEqual(len(page._revisions), 1)
self.assertFalse(hasattr(page, '_pageprops'))
count += 1
if count > 5:
@@ -1712,6 +1713,7 @@
# change the title of the page _and_ delete the pageids.
# preloadpages can only send the titles, and preloadpages should
# complain the returned titles do not match any title in the pagelist.
+ # However, APISite.sametitle now correctly links them.
for page in links:
page._link._text += ' '
del page._pageid
@@ -1721,8 +1723,8 @@
self.assertIsInstance(page, pywikibot.Page)
self.assertIsInstance(page.exists(), bool)
if page.exists():
- self.assertFalse(hasattr(page, "_text"))
- self.assertEqual(len(page._revisions), 0)
+ self.assertTrue(hasattr(page, "_text"))
+ self.assertEqual(len(page._revisions), 1)
self.assertFalse(hasattr(page, '_pageprops'))
count += 1
if count > 5:
--
To view, visit https://gerrit.wikimedia.org/r/174753
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3381d693fb3d03708bcb0218d0ad95d90f1f8002
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix noreferences xml support
......................................................................
Fix noreferences xml support
The initial port imported xmlreader instead of pywikibot.xmlreader.
Change-Id: Ia92826d131307525cb599da4f835fc8a860492f9
---
M scripts/noreferences.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 3ca9711..d0e7ce0 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -42,7 +42,9 @@
#
import re
+
import pywikibot
+
from pywikibot import i18n, pagegenerators, textlib, Bot
# This is required for the text that is shown when you run this script
@@ -446,7 +448,7 @@
self.referencesR = re.compile('<references.*?/>', re.IGNORECASE)
def __iter__(self):
- import xmlreader
+ from pywikibot import xmlreader
dump = xmlreader.XmlDump(self.xmlFilename)
for entry in dump.parse():
text = textlib.removeDisabledParts(entry.text)
--
To view, visit https://gerrit.wikimedia.org/r/174605
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia92826d131307525cb599da4f835fc8a860492f9
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Consistent usage of 'force'
......................................................................
[IMPROV] Consistent usage of 'force'
The newly added function _cache_interwikimap is using 'refresh' instead of
'force' and is the only function with this nomenclature.
Change-Id: Ida651bfecc3fb51836376bd81e6e8fed384a1c71
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 4a139fa..f50d167 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -597,11 +597,11 @@
return [lang for lang in self.languages()
if lang[:1].upper() + lang[1:] not in nsnames]
- def _cache_interwikimap(self, refresh=False):
+ def _cache_interwikimap(self, force=False):
"""Cache the interwikimap with usable site instances."""
# _iw_sites is a local cache to return a APISite instance depending
# on the interwiki prefix of that site
- if refresh or not hasattr(self, '_iw_sites'):
+ if force or not hasattr(self, '_iw_sites'):
self._iw_sites = {}
for iw in self.siteinfo['interwikimap']:
try:
--
To view, visit https://gerrit.wikimedia.org/r/174028
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ida651bfecc3fb51836376bd81e6e8fed384a1c71
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Stop login retrying if username is invalid
......................................................................
Stop login retrying if username is invalid
After an unsuccessful login using a password from the password file,
when the API returns 'NotExists' or 'Invalid', repeating the login
process with a new password supplied from the terminal by the user
will not remedy the situation. Raise NoUsername exception instead,
as the problem is a config issue.
Bug: 73533
Change-Id: I4276c47be2e34fb6aba3490e2b029f9276b7d03a
---
M pywikibot/exceptions.py
M pywikibot/login.py
2 files changed, 32 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index b5013df..e711f48 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -3,7 +3,7 @@
Exception classes used throughout the framework.
Error: Base class, all exceptions should the subclass of this class.
- - NoUsername: Username is not in user-config.py
+ - NoUsername: Username is not in user-config.py, or it is invalid.
- UserBlockedY: our username or IP has been blocked
- AutoblockUser: requested action on a virtual autoblock user not valid
- UserActionRefuse
diff --git a/pywikibot/login.py b/pywikibot/login.py
index ee05bd1..db7be8f 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -37,6 +37,22 @@
@deprecated_args(username="user", verbose=None)
def __init__(self, password=None, sysop=False, site=None, user=None):
+ """
+ Constructor.
+
+ All parameters default to defaults in user-config.
+
+ @param site: Site object to log into
+ @type site: BaseSite
+ @param user: username to use
+ @type user: basestring
+ @param password: password to use
+ @type password: basestring
+ @param sysop: login as sysop account
+ @type sysop: bool
+
+ @raises NoUsername: No username is configured for the requested site.
+ """
if site is not None:
self.site = site
else:
@@ -169,6 +185,14 @@
password_f.close()
def login(self, retry=False):
+ """
+ Attempt to log into the server.
+
+ @param retry: infinitely retry if the API returns an unknown error
+ @type retry: bool
+
+ @raises NoUsername: Username is not recognised by the site.
+ """
if not self.password:
# As we don't want the password to appear on the screen, we set
# password = True
@@ -176,7 +200,6 @@
u'Password for user %(name)s on %(site)s (no characters will '
u'be shown):' % {'name': self.username, 'site': self.site},
password=True)
-# self.password = self.password.encode(self.site.encoding())
pywikibot.output(u"Logging in to %(site)s as %(name)s"
% {'name': self.username, 'site': self.site})
@@ -184,6 +207,13 @@
cookiedata = self.getCookie()
except pywikibot.data.api.APIError as e:
pywikibot.error(u"Login failed (%s)." % e.code)
+ if e.code == 'NotExists':
+ raise NoUsername(u"Username '%s' does not exist on %s"
+ % (self.username, self.site))
+ elif e.code == 'Illegal':
+ raise NoUsername(u"Username '%s' is invalid on %s"
+ % (self.username, self.site))
+ # TODO: investigate other unhandled API codes (bug 73539)
if retry:
self.password = None
return self.login(retry=True)
--
To view, visit https://gerrit.wikimedia.org/r/174035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4276c47be2e34fb6aba3490e2b029f9276b7d03a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Use envvar EDITOR if it exists, with tests
......................................................................
Use envvar EDITOR if it exists, with tests
EDITOR is usually set on Unix platforms to be a basic editor.
Use this as the default editor, if set, even on Windows.
Set EDITOR in the script tests to be a noop (like /bin/true) so
the script continues.
Scripts 'editarticle' and 'upload' are now able to be tested.
Change-Id: I8a069960d0919c760441538c0ac0d11d1015bf01
---
M pywikibot/config2.py
M pywikibot/editor.py
M tests/script_tests.py
3 files changed, 12 insertions(+), 8 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index e24ebca..3cf1608 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -337,6 +337,7 @@
# ############# EXTERNAL EDITOR SETTINGS ##############
# The command for the editor you want to use. If set to None, a simple Tkinter
# editor will be used.
+editor = os.environ.get('EDITOR', None)
# On Windows systems, this script tries to determine the default text editor.
if sys.platform == 'win32':
try:
@@ -350,15 +351,13 @@
_key2 = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,
'%s\shell\open\command' % _progID)
_cmd = _winreg.QueryValueEx(_key2, None)[0]
- editor = _cmd.replace('%1', '')
+ _cmd = _cmd.replace('%1', '')
# Notepad is even worse than our Tkinter editor.
- if editor.lower().endswith('notepad.exe'):
- editor = None
+ if not _cmd.lower().endswith('notepad.exe'):
+ editor = _cmd
except WindowsError:
# Catch any key lookup errors
- editor = None
-else:
- editor = None
+ pass
# Warning: DO NOT use an editor which doesn't support Unicode to edit pages!
# You will BREAK non-ASCII symbols!
diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index 440dadc..0243717 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -54,7 +54,7 @@
command += " -n%i" % (line + 1) # seems not to support columns
command += ' %s' % tempFilename
- #print command
+ pywikibot.log(u'Running editor: %s' % command)
return command
def convertLinebreaks(self, text):
diff --git a/tests/script_tests.py b/tests/script_tests.py
index d575a66..e37cda9 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -55,7 +55,6 @@
unrunnable_script_list = [
'script_wui', # depends on lua compiling
- 'editarticle', # requires a X DISPLAY
]
deadlock_script_list = [
@@ -211,7 +210,13 @@
else:
return stream
env = os.environ.copy()
+ # sys.path may have been modified by the test runner to load dependencies.
env['PYTHONPATH'] = ":".join(sys.path)
+ # Set EDITOR to an executable that ignores all arguments and does nothing.
+ if sys.platform == 'win32':
+ env['EDITOR'] = 'call'
+ else:
+ env['EDITOR'] = 'true'
options = {
'stdout': subprocess.PIPE,
'stderr': subprocess.PIPE
--
To view, visit https://gerrit.wikimedia.org/r/172202
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8a069960d0919c760441538c0ac0d11d1015bf01
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Page.categories parameter withSortKey ignored
......................................................................
Page.categories parameter withSortKey ignored
The withSortKey parameter of Site.pagecategories has been marked as deprecated
since the method was first introduced. However the method Page.categories
has an equivalent parameter which it passes to Site.pagecategories, only
for it to be ignored.
Raise NotImplementedError if withSortKey is enabled calling Page.categories.
Bug: 73561
Change-Id: I22ce77fb91c1f02b71dc028fe75178b1b40c1cde
---
M pywikibot/page.py
1 file changed, 6 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index bda181f..2d71d8a 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1341,8 +1341,12 @@
@return: a generator that yields Category objects.
"""
- return self.site.pagecategories(self, withSortKey=withSortKey,
- step=step, total=total, content=content)
+ # FIXME: bug 73561: withSortKey is ignored by Site.pagecategories
+ if withSortKey:
+ raise NotImplementedError('withSortKey is not implemented')
+
+ return self.site.pagecategories(self, step=step, total=total,
+ content=content)
def extlinks(self, step=None, total=None):
"""Iterate all external URLs (not interwiki links) from this page.
--
To view, visit https://gerrit.wikimedia.org/r/174143
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I22ce77fb91c1f02b71dc028fe75178b1b40c1cde
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>