Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #1920
Status: Errored
Duration: 1 hour, 17 minutes, and 49 seconds
Commit: 435d69b (master)
Author: John Vandenberg
Message: Fix port of imagetransfer
Using the script with -interwiki or a page other than an image
resulted in exceptions due to incorrect usage of core library.
Bug: T86627
Change-Id: I941b9d72467b98378f2ef66c52b8d22261a3e5d9
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/161110a02e64...435d69b4…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/46845386
--
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: Prevent hang in LiveRCPageGenerator
......................................................................
Prevent hang in LiveRCPageGenerator
The socketio client is being disconnected, but continues to poll
for new items indefinitely.
Detect disconnection and stop polling, making LiveRCPageGenerator
fail to fetch the requested total number of items instead of
stalling.
Correct item counter so that the thread quits after total
instead of total+1, reducing the chance of a disconnect.
These changes allows other tests to run after the disconnection,
lowering the impact and frequency of this bug.
Bug: T85717
Change-Id: I0748938b5fbe22a70e032f909c61d3c5bd2b7034
---
M pywikibot/comms/rcstream.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/comms/rcstream.py b/pywikibot/comms/rcstream.py
index f3282ac..7b4ea73 100644
--- a/pywikibot/comms/rcstream.py
+++ b/pywikibot/comms/rcstream.py
@@ -85,10 +85,6 @@
debug('Received change %r' % change, _logger)
thread.count += 1
- if thread.total is not None and thread.count > thread.total:
- thread.stop()
- return
-
thread.queue.put(change)
if thread.queue.qsize() > thread.warn_queue_length:
warning('%r queue length exceeded %i'
@@ -96,6 +92,10 @@
thread.warn_queue_length),
_logger=_logger)
thread.warn_queue_length = thread.warn_queue_length + 100
+
+ if thread.total is not None and thread.count >= thread.total:
+ thread.stop()
+ return
def on_connect(self):
debug('Connected to %r; subscribing to %s'
@@ -115,7 +115,7 @@
def run(self):
""" Threaded function. Runs insided the thread when started with .start(). """
self.running = True
- while self.running:
+ while self.running and self.client.connected:
self.client.wait(seconds=0.1)
debug('Shut down event loop for %r' % self, _logger)
self.client.disconnect()
--
To view, visit https://gerrit.wikimedia.org/r/184285
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0748938b5fbe22a70e032f909c61d3c5bd2b7034
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploader(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: Fix port of imagetransfer
......................................................................
Fix port of imagetransfer
Using the script with -interwiki or a page other than an image
resulted in exceptions due to incorrect usage of core library.
Bug: T86627
Change-Id: I941b9d72467b98378f2ef66c52b8d22261a3e5d9
---
M scripts/imagetransfer.py
1 file changed, 5 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
XZise: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index 12d4e3e..94a1739 100644
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -266,14 +266,15 @@
if self.interwiki:
imagelist = []
for linkedPage in page.interwiki():
- imagelist.append(linkedPage.imagelinks(followRedirects=True))
+ linkedPage = pywikibot.Page(linkedPage)
+ imagelist.extend(
+ linkedPage.imagelinks(
+ followRedirects=True))
elif page.isImage():
imagePage = pywikibot.FilePage(page.site, page.title())
imagelist = [imagePage]
else:
- imagePage = (page.imagelinks(followRedirects=True)).result(
- {'title': page.title(), 'ns': pywikibot.Site().image_namespace()})
- imagelist = [imagePage]
+ imagelist = list(page.imagelinks(followRedirects=True))
while len(imagelist) > 0:
self.showImageList(imagelist)
--
To view, visit https://gerrit.wikimedia.org/r/184589
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I941b9d72467b98378f2ef66c52b8d22261a3e5d9
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 <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #1918
Status: Errored
Duration: 49 minutes and 27 seconds
Commit: 622c01f (master)
Author: Fabian Neundorf
Message: [FEAT] bot: add open_webbrowser
This adds a open_webbrowser method to the bot module to open the
webbrowser with the given page. The Page object now also supports to get
the full URL and the Family object can now returns a URI now with the
correct hostname and path prefix selected depending on the fact that SSL
is used.
Change-Id: Ic4f340b42981121216af3ab1f6cee00289fb6b47
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/d70ae6beaf87...622c01fc…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/46742216
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #1916
Status: Failed
Duration: 48 minutes and 5 seconds
Commit: dbd0151 (master)
Author: Fabian Neundorf
Message: [FIX] gui: Fix import errors of gui module
The gui imports are invalid and thus it wasn't possible to use the
tkinter editor. The relative import in editor.py was neither in Python 3
nor in Python 2 valid and introduced with
728524b6a94c56a9fe92f338bfa5a8149e0a6ab5. The import in
terminal_interface_base.py is valid in Python 2 but not in Python 3 so
changed that into an absolute also.
Change-Id: I6fb408452ff7878e67b3edb953a02526af97c0e3
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/73aaebacdfd6...dbd01515…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/46671213
--
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] Editor: Support spaces, delete always and warn on \n (etc)
......................................................................
[FIX] Editor: Support spaces, delete always and warn on \n (etc)
This support spaces in the editor file name and warns if it contains a
string literal like \n with Windows because the backslash was used as a
path delimiter without escaping them.
The pywikibot.editor.TextEditor.command method has been deprecated,
because outside scripts don't require access anyway and this makes it
possible to return a list of command segments.
This now deletes the temporary file on any case, also when there were no
changes done. And it uses the more secure 'mkstemp' function.
Bug: T86481
Change-Id: If7e9feee49acd1147c5554cdd74a7ad0758397c5
---
M pywikibot/config2.py
M pywikibot/editor.py
2 files changed, 58 insertions(+), 32 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index e7df241..6e1a27e 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -886,6 +886,17 @@
elif transliteration_target in ('None', 'none'):
transliteration_target = None
+if sys.platform == 'win32' and editor:
+ # single character string literals from
+ # https://docs.python.org/2/reference/lexical_analysis.html#string-literals
+ # encode('unicode-escape') also changes Unicode characters
+ if set(editor) & set('\a\b\f\n\r\t\v'):
+ print('WARNING: The editor path contains probably invalid escaped '
+ 'characters. Make sure to use a raw-string (r"..." or r\'...\'), '
+ 'forward slashs as a path delimiter or to escape the normal '
+ 'path delimiter.')
+
+
# Fix up default site
if family == 'wikipedia' and mylang == 'language':
print("WARNING: family and mylang are not set.\n"
diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index d3e268a..b928dc7 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -11,50 +11,64 @@
__version__ = '$Id$'
#
-import os
-import tempfile
import codecs
+import os
+import subprocess
+import tempfile
+
import pywikibot
from pywikibot import config
+from pywikibot.tools import deprecated
class TextEditor(object):
"""Text editor."""
- def command(self, tempFilename, text, jumpIndex=None):
+ def _command(self, file_name, text, jump_index=None):
"""Return editor selected in user-config.py."""
- command = config.editor
- if jumpIndex:
+ if jump_index:
# Some editors make it possible to mark occurrences of substrings,
# or to jump to the line of the first occurrence.
# TODO: Find a better solution than hardcoding these, e.g. a config
# option.
- line = text[:jumpIndex].count('\n')
- column = jumpIndex - (text[:jumpIndex].rfind('\n') + 1)
+ line = text[:jump_index].count('\n')
+ column = jump_index - (text[:jump_index].rfind('\n') + 1)
else:
line = column = 0
# Linux editors. We use startswith() because some users might use
# parameters.
if config.editor.startswith('kate'):
- command += " -l %i -c %i" % (line + 1, column + 1)
+ command = ['-l', '%i' % (line + 1), '-c', '%i' % (column + 1)]
elif config.editor.startswith('gedit'):
- command += " +%i" % (line + 1) # seems not to support columns
+ command = ['+%i' % (line + 1)] # seems not to support columns
elif config.editor.startswith('emacs'):
- command += " +%i" % (line + 1) # seems not to support columns
+ command = ['+%i' % (line + 1)] # seems not to support columns
elif config.editor.startswith('jedit'):
- command += " +line:%i" % (line + 1) # seems not to support columns
+ command = ['+line:%i' % (line + 1)] # seems not to support columns
elif config.editor.startswith('vim'):
- command += " +%i" % (line + 1) # seems not to support columns
+ command = ['+%i' % (line + 1)] # seems not to support columns
elif config.editor.startswith('nano'):
- command += " +%i,%i" % (line + 1, column + 1)
+ command = ['+%i,%i' % (line + 1, column + 1)]
# Windows editors
elif config.editor.lower().endswith('notepad++.exe'):
- command += " -n%i" % (line + 1) # seems not to support columns
+ command = ['-n%i' % (line + 1)] # seems not to support columns
+ else:
+ command = []
- command += ' %s' % tempFilename
- pywikibot.log(u'Running editor: %s' % command)
+ command = [config.editor] + command + [file_name]
+ pywikibot.log(u'Running editor: %s' % TextEditor._concat(command))
return command
+
+ @staticmethod
+ def _concat(command):
+ return ' '.join("'{0}'".format(part) if ' ' in part else part
+ for part in command)
+
+ @deprecated('_command (should not be used from the outside)')
+ def command(self, tempFilename, text, jumpIndex=None):
+ """Return editor selected in user-config.py."""
+ return TextEditor._concat(self._command(tempFilename, text, jumpIndex))
def edit(self, text, jumpIndex=None, highlight=None):
"""
@@ -73,24 +87,25 @@
@rtype: unicode or None
"""
if config.editor:
- tempFilename = '%s.%s' % (tempfile.mktemp(),
+ tempFilename = '%s.%s' % (tempfile.mkstemp()[1],
config.editor_filename_extension)
- with codecs.open(tempFilename, 'w',
- encoding=config.editor_encoding) as tempFile:
- tempFile.write(text)
- creationDate = os.stat(tempFilename).st_mtime
- command = self.command(tempFilename, text, jumpIndex)
- os.system(command)
- lastChangeDate = os.stat(tempFilename).st_mtime
- if lastChangeDate == creationDate:
- # Nothing changed
- return None
- else:
- with codecs.open(tempFilename, 'r',
- encoding=config.editor_encoding) as temp_file:
- newcontent = temp_file.read()
+ try:
+ with codecs.open(tempFilename, 'w',
+ encoding=config.editor_encoding) as tempFile:
+ tempFile.write(text)
+ creationDate = os.stat(tempFilename).st_mtime
+ subprocess.call(self._command(tempFilename, text, jumpIndex))
+ lastChangeDate = os.stat(tempFilename).st_mtime
+ if lastChangeDate == creationDate:
+ # Nothing changed
+ return None
+ else:
+ with codecs.open(tempFilename, 'r',
+ encoding=config.editor_encoding) as temp_file:
+ newcontent = temp_file.read()
+ return newcontent
+ finally:
os.unlink(tempFilename)
- return newcontent
try:
import gui # noqa
--
To view, visit https://gerrit.wikimedia.org/r/184241
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If7e9feee49acd1147c5554cdd74a7ad0758397c5
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>