jenkins-bot has submitted this change and it was merged.
Change subject: [TOUCHUP] Properly run the no user test
......................................................................
[TOUCHUP] Properly run the no user test
Originally the username in the test was a str but with 1e54a7d6 this
changed into a unicode and added the u-prefix to the output. That patch
fixed the problem by casting the name into str prior to adding it. But
that defies the usage of %r so this patch tries to solve the problem
properly by not casting ALL names into str but only the tested name.
Using str instead of unicode actually uncovered a bug which is already
fixed by a0a194d5.
Change-Id: I3526cb3b29c76c18b92f80ba810b427d8d757617
---
M pywikibot/data/api.py
M tests/dry_api_tests.py
2 files changed, 4 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 61b34f0..41d6c82 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1146,7 +1146,7 @@
if ip.is_IP(self.site._userinfo['name']):
raise Error(u"API write action attempted as IP %r"
- % str(self.site._userinfo['name']))
+ % self.site._userinfo['name'])
if not self.site.user():
pywikibot.warning(
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 82d35af..ab80178 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -194,7 +194,9 @@
self.assertRaisesRegex(pywikibot.Error, ' without userinfo',
Request, site=site, action='edit')
- site._userinfo = {'name': '1.2.3.4', 'groups': []}
+ # Explicitly using str as the test expects it to be str (without the
+ # u-prefix) in Python 2 and this module is using unicode_literals
+ site._userinfo = {'name': str('1.2.3.4'), 'groups': []}
self.assertRaisesRegex(pywikibot.Error, " as IP '1.2.3.4'",
Request, site=site, action='edit')
--
To view, visit https://gerrit.wikimedia.org/r/203318
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3526cb3b29c76c18b92f80ba810b427d8d757617
Gerrit-PatchSet: 2
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Returns unknown version when git repo is cleaned, instead of crashing
......................................................................
Returns unknown version when git repo is cleaned, instead of crashing
When the git repo is clean, version.py can't open the git version file
to get hash and crashes, causes crash of all scripts.
Bug: T91904
Change-Id: Iaa6458e60e42bf3026ff56af9e797ec580e6bb85
---
M pywikibot/version.py
1 file changed, 8 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 3eba2a0..ee49fe7 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -117,7 +117,7 @@
date = time.strptime(date, "%Y-%m-%d %H:%M:%S")
return rev, date
if not rev:
- return "(unknown)", time.strptime("2000-01-01 00:00:00", "%Y-%m-%d %H:%M:%S")
+ raise ParseError
return rev, date
@@ -185,8 +185,13 @@
subprocess.Popen([cmd], stdout=subprocess.PIPE).communicate()
except:
#Means git hasn't been installed, no way to get the date, retreving date from gitblit
- hsh = open(os.path.join(_program_dir, '.git/refs/heads/master'), 'r').read().strip(" \n")
- rev, date = getversion_git_windows(hsh, path)
+ file_path = os.path.join(_program_dir, '.git/refs/heads/master')
+ if os.path.isfile(file_path):
+ with open(file_path, 'r') as hash_file:
+ hsh = hash_file.read().strip(' \n')
+ rev, date = getversion_git_windows(hsh, path)
+ else:
+ raise ParseError
tag = open(os.path.join(_program_dir, '.git/config'), 'r').read()
s = tag.find('url = ', tag.find('[remote "origin"]'))
e = tag.find('\n', s)
--
To view, visit https://gerrit.wikimedia.org/r/203305
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaa6458e60e42bf3026ff56af9e797ec580e6bb85
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Win32 UI: Explicitly use bytes in Python 2
......................................................................
[FIX] Win32 UI: Explicitly use bytes in Python 2
When searching for a unicode via 'in' in bytes it'll try decoding the
bytes which might fail if it doesn't contain ASCII characters.
Bug: T95671
Change-Id: I5ecf0539b4b056ba14a59fcce4cce595815c2ff7
---
M pywikibot/userinterfaces/terminal_interface_win32.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_win32.py b/pywikibot/userinterfaces/terminal_interface_win32.py
index ddef65f..d4f2c1f 100755
--- a/pywikibot/userinterfaces/terminal_interface_win32.py
+++ b/pywikibot/userinterfaces/terminal_interface_win32.py
@@ -102,7 +102,9 @@
def _raw_input(self):
data = self.stdin.readline()
- if '\x1a' in data:
+ # data is in both Python versions str but '\x1a' is unicode in Python 2
+ # so explicitly convert into str as it otherwise tries to decode data
+ if str('\x1a') in data:
raise EOFError()
return data.strip()
--
To view, visit https://gerrit.wikimedia.org/r/203346
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5ecf0539b4b056ba14a59fcce4cce595815c2ff7
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: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #2113
Status: Errored
Duration: 55 minutes and 18 seconds
Commit: f7b0f29 (master)
Author: Priyanka
Message: Port replace.py -replacementfile from compat
Added missing -replacementfile parameter.
Checked if the argument set being accepted are always taken in pattern
replacement pair.
Bug: T70503
Change-Id: I3c68edf090c605b78b5864bc19b68e8448604a4e
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/c653333dcf02...f7b0f29d…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/57926875
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Use bytes for ipaddress module detection
......................................................................
[FIX] Use bytes for ipaddress module detection
With 1e54a7d6, it is necessary to specify bytes
when attempting to detect whether the ipaddress module is sane.
Change-Id: If0daab025a626cca6b4f5bc5d70cd54f2d12b4b3
---
M pywikibot/tools/ip.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/ip.py b/pywikibot/tools/ip.py
index 08c03a1..808c0cc 100644
--- a/pywikibot/tools/ip.py
+++ b/pywikibot/tools/ip.py
@@ -35,7 +35,7 @@
# https://pypi.python.org/pypi/ipaddress
# However while it rejects u'1111', it will consider '1111' valid
try:
- ip_address('1111')
+ ip_address(b'1111')
warn('ipaddress backport is defective; patching.', ImportWarning)
orig_ip_address = ip_address
# force all input to be a unicode object so it validates correctly
--
To view, visit https://gerrit.wikimedia.org/r/203277
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If0daab025a626cca6b4f5bc5d70cd54f2d12b4b3
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Port replace.py -replacementfile from compat
......................................................................
Port replace.py -replacementfile from compat
Added missing -replacementfile parameter.
Checked if the argument set being accepted are always taken in pattern
replacement pair.
Bug: T70503
Change-Id: I3c68edf090c605b78b5864bc19b68e8448604a4e
---
M scripts/replace.py
1 file changed, 46 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
old mode 100755
new mode 100644
index 44f8ecb..19a7855
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -72,6 +72,11 @@
(or no replacements are defined via -fix or the arguments)
it'll ask for additional replacements at start.
+-replacementfile Lines from the given file name(s) will be read as replacement
+ arguments. i.e. a file containing lines "a" and "b", used as
+ python replace.py -page:X -replacementfile:file c d
+ will replace 'a' with 'b' and 'c' with 'd'.
+
-always Don't prompt you for each replacement
-recursive Recurse replacement as long as possible. Be careful, this
@@ -127,6 +132,7 @@
__version__ = '$Id$'
#
+import codecs
import collections
import re
import time
@@ -714,6 +720,9 @@
sleep = None
# Request manual replacements even if replacements are already defined
manual_input = False
+ # Replacements loaded from a file
+ replacement_file = None
+ replacement_file_arg_misplaced = False
# Read commandline parameters.
@@ -770,13 +779,48 @@
allowoverlap = True
elif arg.startswith('-manualinput'):
manual_input = True
+ elif arg.startswith('-replacementfile'):
+ if len(commandline_replacements) % 2:
+ replacement_file_arg_misplaced = True
+
+ if arg == '-replacementfile':
+ replacement_file = pywikibot.input(
+ u'Please enter the filename to read replacements from:')
+ else:
+ replacement_file = arg[len('-replacementfile:'):]
else:
commandline_replacements.append(arg)
site = pywikibot.Site()
- if (len(commandline_replacements) % 2):
- raise pywikibot.Error('require even number of replacements.')
+ if len(commandline_replacements) % 2:
+ pywikibot.error('Incomplete command line pattern replacement pair.')
+ return False
+
+ if replacement_file_arg_misplaced:
+ pywikibot.error(
+ '-replacementfile used between a pattern replacement pair.')
+ return False
+
+ if replacement_file:
+ try:
+ with codecs.open(replacement_file, 'r', 'utf-8') as f:
+ file_replacements = f.readlines()
+ except (IOError, OSError) as e:
+ pywikibot.error(u'Error loading {0}: {1}'.format(
+ replacement_file, e))
+ return False
+
+ if len(file_replacements) % 2:
+ pywikibot.error(
+ '{0} contains an incomplete pattern replacement pair.'.format(
+ replacement_file))
+ return False
+
+ # Strip BOM from first line
+ file_replacements[0].lstrip(u'\uFEFF')
+ commandline_replacements.extend(file_replacements)
+
if not(commandline_replacements or fixes_set) or manual_input:
old = pywikibot.input(u'Please enter the text that should be replaced:')
while old:
--
To view, visit https://gerrit.wikimedia.org/r/181242
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c68edf090c605b78b5864bc19b68e8448604a4e
Gerrit-PatchSet: 25
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Prianka <priyankajayaswal025(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: Prianka <priyankajayaswal025(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>