jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509035 )
Change subject: [doc] Update framework description
......................................................................
[doc] Update framework description
Change-Id: I3d06f3c6acdd8bf4d892d2a88f8a63d448d9badd
---
M pywikibot/README.rst
1 file changed, 6 insertions(+), 8 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/README.rst b/pywikibot/README.rst
index 82b3f35..8d1cca2 100644
--- a/pywikibot/README.rst
+++ b/pywikibot/README.rst
@@ -16,10 +16,8 @@
**External software can be used with Pywikibot:**
* Pydot, Pyparsing and Graphviz for use with interwiki_graph.py
- * JSON for use with site.py, bot.py
- * MySQLdb to access MySQL database for use with pagegenerators.py
- * PyGoogle to access Google Web API and PySearch to access Yahoo! Search
- Web Services for use with pagegenerators.py
+ * PyMySQL to access MySQL database for use with pagegenerators.py
+ * google to access Google Web API for use with pagegenerators.py
Pywikibot makes use of some modules that are part of python, but that
@@ -30,11 +28,11 @@
* python-tkinter (optional, used by some experimental GUI stuff)
-You need to have at least python version `2.7.4 <http://www.python.org/download/>`_
+You need to have at least Python version `2.7.4 <http://www.python.org/download/>`_
or newer installed on your computer to be able to run any of the code in this
-package, but not 3.0-3.3. It works fine with 3.4+ versions of python installed.
-Support for older versions of python is not planned. Some scripts could run with
-older python releases. Please refer the manual at mediawiki for further details
+package, but not 3.0-3.3. Support for older versions of Python is not planned
+and version 2.7 may be dropped soon as well. It works fine with 3.4+ versions
+of Python installed. Please refer the manual at mediawiki for further details
and restrictions.
--
To view, visit https://gerrit.wikimedia.org/r/509035
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3d06f3c6acdd8bf4d892d2a88f8a63d448d9badd
Gerrit-Change-Number: 509035
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/508960 )
Change subject: [bugfix] Make archive/script_wui.py work again
......................................................................
[bugfix] Make archive/script_wui.py work again
- fix errors in code preventing script to work
- create proper doc
- use lupa instead of discontinued lunatic-python
lupa is available on Windows and Linux and works with py2.7 and 3.4-3.7
- remove references to compat/trunk/rewrite
- create /Simulation subpage if missing
- fix botirc.py irc package import
- tested on py3.7 and py2.7
Change-Id: I9c5848bb0e8056c2d86b5c14b948e1d399d3c2be
---
M pywikibot/botirc.py
M scripts/archive/script_wui.py
2 files changed, 70 insertions(+), 75 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/botirc.py b/pywikibot/botirc.py
index b6d0a7d..4ada623 100644
--- a/pywikibot/botirc.py
+++ b/pywikibot/botirc.py
@@ -23,7 +23,7 @@
import pywikibot
try:
- from ircbot import SingleServerIRCBot
+ from irc.bot import SingleServerIRCBot
except ImportError as e:
ircbot_import_error = e
diff --git a/scripts/archive/script_wui.py b/scripts/archive/script_wui.py
index 1605903..555b257 100755
--- a/scripts/archive/script_wui.py
+++ b/scripts/archive/script_wui.py
@@ -1,20 +1,57 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-Bot which runs python framework scripts as (sub-)bot.
+A script to run Pywikibot shell with Lua support from wiki page.
-It provides a WikiUserInterface (WUI) with Lua support for bot operators.
+@deprecated: This method is not supported anymore. Use
+ U{PAWS<https://www.mediawiki.org/wiki/Manual:Pywikibot/PAWS>}
+ instead.
-This script needs external libraries (see imports and comments there)
-in order to run properly. Most of them can be checked-out at:
- https://gerrit.wikimedia.org/r/#/admin/projects/?filter=pywikibot
-(some code might get compiled on-the-fly, so a GNU compiler along
-with library header files is needed too)
+This script runs in the background and tracks changes in the predefined
+wiki page for shell – WikiUserInterface (WUI). When a change
+is recorded, the contents of the page is interpreted as Pywikibot shell
+commands and executed.
-Syntax example:
+The predefined wiki page for crontab sets the shell page contents to
+a specified revision in the specified interval.
- python pwb.py script_wui -dir:.
- Default operating mode.
+Usage
+~~~~~
+
+It needs Lua or LuaJIT installed and also external PyPI packages
+crontab, irc and lupa in order to run properly. Some code might
+get compiled on-the-fly, so a GNU compiler along with library
+header files is needed too.
+
+You will need to create the following pages on your wiki:
+
+:User:{username}/script_wui-crontab.css:
+ This page specifies the commands to execute, one command per line.
+ See [[de:Benutzer:DrTrigon/DrTrigonBot/script_wui-shell.css]]
+ for example.
+:User:{username}/script_wui-shell.css:
+ This page specifies the schedule to execute specific page revision.
+ The following format can be used: revision, timestamp
+ See [[de:Benutzer:DrTrigon/DrTrigonBot/script_wui-crontab.css]]
+ for example.
+
+Tips for writing code in Wikipedia:
+
+ # patches to keep code running
+ builtin_raw_input = __builtin__.raw_input
+ # overwrite 'raw_input' to run bot non-blocking and simulation mode
+ __builtin__.raw_input = lambda: 'n'
+
+ # backup sys.argv; not recommended, if possible manipulate
+ # pywikibot.config instead
+ sys_argv = copy.deepcopy( sys.argv )
+
+@todo: Simulationen werden ausgeführt und das Resultat mit eindeutiger
+ Id (rev-id) auf Ausgabeseite geschrieben, damit kann der Befehl
+ (durch Angabe der Sim-Id) ausgeführt werden -> crontab (!)
+ [ shell (rev-id) -> output mit shell rev-id ]
+ [ shell rev-id (eindeutige job/task-config bzw. script) -> crontab ]
+@todo: Bei jeder Botbearbeitung wird der Name des Auftraggebers vermerkt
"""
#
# (C) Dr. Trigon, 2012-2014
@@ -22,44 +59,6 @@
#
# Distributed under the terms of the MIT license.
#
-# @package script_wui
-# @brief Script WikiUserInterface (WUI) Bot
-#
-# @copyright Dr. Trigon, 2012
-#
-# @section FRAMEWORK
-#
-# Python wikipedia bot framework, DrTrigonBot.
-# @see https://www.mediawiki.org/wiki/Manual:Pywikibot
-# @see https://de.wikipedia.org/wiki/Benutzer:DrTrigonBot
-#
-# @section LICENSE
-#
-# Distributed under the terms of the MIT license.
-# @see https://de.wikipedia.org/wiki/MIT-Lizenz
-#
-# --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
-# @todo Simulationen werden ausgeführt und das Resultat mit eindeutiger
-# Id (rev-id) auf Ausgabeseite geschrieben, damit kann der Befehl
-# (durch Angabe der Sim-Id) ausgeführt werden -> crontab (!)
-# [ shell (rev-id) -> output mit shell rev-id ]
-# [ shell rev-id (eindeutige job/task-config bzw. script) -> crontab ]
-# @todo Bei jeder Botbearbeitung wird der Name des Auftraggebers vermerkt
-# --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
-# Writing code in Wikipedia:
-#
-# # patches to keep code running
-# builtin_raw_input = __builtin__.raw_input
-# # overwrite 'raw_input' to run bot non-blocking and simulation mode
-# __builtin__.raw_input = lambda: 'n'
-#
-# # backup sys.argv; depreciated: if possible manipulate pywikibot.config
-# instead
-# sys_argv = copy.deepcopy( sys.argv )
-#
-# ...
-# --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
-#
from __future__ import absolute_import, division, unicode_literals
import datetime
@@ -72,20 +71,16 @@
from io import StringIO
-# https://labix.org/lunatic-python is bit-rotting, and there are maintained
-# versions on github:
-# https://github.com/bastibe/lunatic-python.git
-# https://github.com/AlereDevices/lunatic-python.git
-import lua
+from lupa import LuaRuntime
+lua = LuaRuntime(unpack_returned_tuples=True)
-# The crontab package is https://github.com/josiahcarlson/parse-crontab
-# version 0.20 installs a package called 'tests' which conflicts with our
-# test suite. The patch to fix this has been merged, but is not released.
-# TODO: Use https://github.com/jayvdb/parse-crontab until it is fixed.
+# The 'crontab' PyPI package versions 0.20 and 0.20.1 installs
+# a package called 'tests' which conflicts with our test suite.
+# The patch to fix this has been released in version 0.20.2.
import crontab
import pywikibot
-# pywikibot.botirc depends on https://pypi.org/project/irc
+# pywikibot.botirc depends on 'irc' PyPI package
import pywikibot.botirc
from pywikibot.tools.formatter import color_format
from pywikibot.tools import PY2
@@ -93,7 +88,7 @@
if not PY2:
import _thread as thread
else:
- import thread # noqa: H237 (module does not exist in Python 3)
+ import thread
try:
import resource
@@ -107,7 +102,7 @@
'ConfCSScrontab': 'User:{username}/script_wui-crontab.css',
'ConfCSSoutput': 'User:{username}/Simulation',
- 'CRONMaxDelay': 5 * 60.0, # check all ~5 minutes
+ 'CRONMaxDelay': 5 * 60.0, # check all ~5 minutes
# forbidden parameters
# (at the moment none, but consider e.g. '-always' or allow it with
@@ -133,10 +128,10 @@
# - Lua -
pywikibot.output('** Redirecting Lua print in order to catch it')
lua.execute('__print = print')
- lua.execute('print = python.globals().pywikibot.output')
+ lua.execute('print = python.eval("pywikibot.output")')
# It may be useful in debugging to install the 'print' builtin
# as the 'print' function in lua. To do this:
- # lua.execute('print = python.builtins().print')
+ # lua.execute('print = python.builtins.print')
# init constants
templ = pywikibot.Page(self.site, bot_config['ConfCSSshell'])
@@ -151,14 +146,14 @@
for item in self.refs:
# First check if page is protected, reject any data if not
parts = self.refs[item].title().lower().rsplit('.')
- if len(parts) == 1 or parts[1] not in ['.css', '.js']:
+ if len(parts) == 1 or parts[1] not in ['css', 'js']:
raise ValueError('{0} config {1} = {2} is not a secure page; '
'it should be a css or js userpage which are '
'automatically semi-protected.'
.format(self.__class__.__name__, item,
self.refs[item]))
try:
- self.refs[item].get(force=True) # load all page contents
+ self.refs[item].get(force=True) # load all page contents
except pywikibot.NoPage:
pywikibot.error("The configuration page {0} doesn't exists"
.format(self.refs[item].title(as_link=True)))
@@ -168,17 +163,17 @@
self.on_timer()
def on_pubmsg(self, c, e):
- match = self.re_edit.match(e.arguments()[0])
+ match = self.re_edit.match(e.arguments[0])
if not match:
return
- user = match.group('user').decode(self.site.encoding())
+ user = match.group('user')
if user == bot_config['BotName']:
return
# test actual page against (template incl.) list
- page = match.group('page').decode(self.site.encoding())
+ page = match.group('page')
if page in self.refs:
pywikibot.output('RELOAD: ' + page)
- self.refs[page].get(force=True) # re-load (refresh) page content
+ self.refs[page].get(force=True) # re-load (refresh) page content
if page == self.templ:
pywikibot.output('SHELL: ' + page)
self.do_check(page)
@@ -196,7 +191,7 @@
ctab = self.refs[self.cron].get()
# extract 'rev' and 'timestmp' from 'crontab' page text ...
- # hacky/ugly/cheap; already better done in trunk dtbext
+ # hacky/ugly/cheap
for line in ctab.splitlines():
(rev, timestmp) = [item.strip() for item in line[1:].split(',')]
@@ -221,8 +216,8 @@
thread.start_new_thread(main_script, (self.refs[page_title], rev,
params))
except Exception:
- # (done according to subster in trunk and submit in
- # rewrite/.../data/api.py)
+ # (done according to subster.py from compat and submitted in
+ # pywikibot/data/api.py)
# TODO: is this error handling here needed at all??!?
# secure traceback print (from api.py submit)
@@ -263,8 +258,8 @@
try:
exec(code)
except Exception:
- # (done according to subster in trunk and submit in
- # rewrite/.../data/api.py)
+ # (done according to subster.py from compat and submitted in
+ # pywikibot/data/api.py)
# secure traceback print (from api.py submit)
pywikibot.exception(tb=True)
@@ -309,7 +304,7 @@
link = page.permalink(oldid=rev)
# append to page
outpage = pywikibot.Page(pywikibot.Site(), bot_config['ConfCSSoutput'])
- text = outpage.get()
+ text = outpage.text
outpage.put(
text + ('\n== Simulation vom %s mit [%s code:%s] =='
'\n<pre>\n%s</pre>\n\n')
--
To view, visit https://gerrit.wikimedia.org/r/508960
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9c5848bb0e8056c2d86b5c14b948e1d399d3c2be
Gerrit-Change-Number: 508960
Gerrit-PatchSet: 2
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/508116 )
Change subject: [cleanup] Cleanup dependency_links in setup.py
......................................................................
[cleanup] Cleanup dependency_links in setup.py
- pywinauto and pywin32 are available via pypi
- dependency_links wheren't processed since pip 1.4 due to a missing
--process-dependency-links option and is droppend since pip 19.0
Change-Id: I5580cc31204a1ee21dc79302b6aee0fbbef1bb44
---
M setup.py
1 file changed, 7 insertions(+), 15 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index c9f205d..766d5b9 100644
--- a/setup.py
+++ b/setup.py
@@ -93,18 +93,6 @@
if sys.platform.startswith('linux'):
script_deps['script_wui.py'] = ['irc', 'lunatic-python', 'crontab']
-# The main pywin32 repository contains a Python 2 only setup.py with a small
-# wrapper setup3.py for Python 3.
-# http://pywin32.hg.sourceforge.net:8000/hgroot/pywin32/pywin32
-# The main pywinauto repository doesn't support Python 3.
-# The repositories used below have a Python 3 compliant setup.py
-dependency_links = [
- 'git+https://github.com/AlereDevices/lunatic-python.git#egg='
- 'lunatic-python',
- 'hg+https://bitbucket.org/TJG/pywin32#egg=pywin32',
- 'git+https://github.com/vasily-v-ryabov/pywinauto-64#egg=pywinauto',
-]
-
if PY2:
# tools.ip does not have a hard dependency on an IP address module,
# as it falls back to using regexes if one is not available.
@@ -150,8 +138,13 @@
# Microsoft makes available a compiler for Python 2.7
# http://www.microsoft.com/en-au/download/details.aspx?id=44266
if os.name == 'nt' and os.environ.get('PYSETUP_TEST_NO_UI', '0') != '1':
- # which isn't provided on pypi.
- test_deps += ['pywin32', 'pywinauto>=0.4.0']
+ if PYTHON_VERSION >= (3, 5, 0) or PY2:
+ pywinauto = 'pywinauto>0.6.4'
+ pywin32 = 'pywin32>220'
+ else: # Python 3.4
+ pywinauto = 'pywinauto<=0.6.4'
+ pywin32 = 'pywin32<=220'
+ test_deps += [pywin32, pywinauto]
extra_deps.update(script_deps)
@@ -227,7 +220,6 @@
if package.startswith('pywikibot.')],
python_requires='>=2.7.4, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
install_requires=dependencies,
- dependency_links=dependency_links,
extras_require=extra_deps,
url='https://www.mediawiki.org/wiki/Manual:Pywikibot',
download_url='https://tools.wmflabs.org/pywikibot/',
--
To view, visit https://gerrit.wikimedia.org/r/508116
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5580cc31204a1ee21dc79302b6aee0fbbef1bb44
Gerrit-Change-Number: 508116
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/508128 )
Change subject: [IMPR] Avoid too many return statements within function
......................................................................
[IMPR] Avoid too many return statements within function
(reported by codeclimate)
Change-Id: I0ba7855a831116627e11e1f2e4b813448835280f
---
M pywikibot/bot.py
1 file changed, 13 insertions(+), 6 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index f79dd69..7bbdc81 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -2057,9 +2057,11 @@
'Skipping %s because claim with same property '
'already exists' % (claim.getID(),))
log('Use -exists:p option to override this behavior')
- return False
+ break
+
if not existing.target_equals(claim.getTarget()):
continue
+
# If some attribute of the claim being added
# matches some attribute in an existing claim of
# the same property, skip the claim, unless the
@@ -2069,19 +2071,22 @@
'Skipping %s because claim with same target already exists'
% (claim.getID(),))
log("Append 't' to -exists argument to override this behavior")
- return False
+ break
+
if 'q' not in exists_arg and not existing.qualifiers:
logger_callback(
'Skipping %s because claim without qualifiers already '
'exists' % (claim.getID(),))
log("Append 'q' to -exists argument to override this behavior")
- return False
+ break
+
if ('s' not in exists_arg or not source) and not existing.sources:
logger_callback(
'Skipping %s because claim without source already exists'
% (claim.getID(),))
log("Append 's' to -exists argument to override this behavior")
- return False
+ break
+
if ('s' not in exists_arg and source
and any(source.getID() in ref
and all(snak.target_equals(source.getTarget())
@@ -2091,9 +2096,11 @@
'Skipping %s because claim with the same source already '
'exists' % (claim.getID(),))
log("Append 's' to -exists argument to override this behavior")
- return False
+ break
+ else:
+ return self.user_add_claim(item, claim, source, **kwargs)
- return self.user_add_claim(item, claim, source, **kwargs)
+ return False
def create_item_for_page(self, page, data=None, summary=None, **kwargs):
"""
--
To view, visit https://gerrit.wikimedia.org/r/508128
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ba7855a831116627e11e1f2e4b813448835280f
Gerrit-Change-Number: 508128
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/508094 )
Change subject: [TEST] fix test_login_logout
......................................................................
[TEST] fix test_login_logout
- The tests worked locally, on the WM CI but not on Travis. It seems that
the login is in progress while expected as completed. Added this case.
Bug: T222508
Change-Id: I1dd500880ce6f2f995953c815fb24f0989e30b11
---
M tests/site_tests.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index d157f48..8d3f40e 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -3713,10 +3713,12 @@
loginstatus = pywikibot.site.LoginStatus
self.assertFalse(site.logged_in())
+ self.assertEqual(site._loginstatus, loginstatus.NOT_ATTEMPTED)
site.login()
self.assertTrue(site.logged_in())
- self.assertGreaterEqual(site._loginstatus, loginstatus.AS_USER)
+ self.assertIn(site._loginstatus, (loginstatus.IN_PROGRESS,
+ loginstatus.AS_USER))
self.assertIn('_userinfo', site.__dict__.keys())
self.assertIsNone(site.login())
--
To view, visit https://gerrit.wikimedia.org/r/508094
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1dd500880ce6f2f995953c815fb24f0989e30b11
Gerrit-Change-Number: 508094
Gerrit-PatchSet: 2
Gerrit-Owner: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)