jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/505459 )
Change subject: [python 3.8] threading.Thread.isAlive() method is deprecated
......................................................................
[python 3.8] threading.Thread.isAlive() method is deprecated
The isAlive() method of threading.Thread has been deprecated.
The renaming to is_alive() was done in python 2.6
Change-Id: I7322d86a73133fa28f97d3b1e0b406fd08645137
---
M pywikibot/__init__.py
M pywikibot/tools/__init__.py
M scripts/weblinkchecker.py
3 files changed, 5 insertions(+), 5 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 2caa6f0..a4cbfdc 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1366,7 +1366,7 @@
'{lightblue}Waiting for {num} pages to be put. '
'Estimated time remaining: {sec}{default}', num=num, sec=sec))
- while _putthread.isAlive() and page_put_queue.qsize() > 0:
+ while _putthread.is_alive() and page_put_queue.qsize() > 0:
try:
_putthread.join(1)
except KeyboardInterrupt:
@@ -1400,7 +1400,7 @@
def async_request(request, *args, **kwargs):
"""Put a request on the queue, and start the daemon if necessary."""
- if not _putthread.isAlive():
+ if not _putthread.is_alive():
try:
page_put_queue.mutex.acquire()
try:
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 4515301..8bd43d5 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -842,7 +842,7 @@
def __iter__(self):
"""Iterate results from the queue."""
- if not self.isAlive() and not self.finished.isSet():
+ if not self.is_alive() and not self.finished.isSet():
self.start()
# if there is an item in the queue, yield it, otherwise wait
while not self.finished.isSet():
@@ -985,7 +985,7 @@
"""Return the number of alive threads and delete all non-alive ones."""
cnt = 0
for item in self[:]:
- if item.isAlive():
+ if item.is_alive():
cnt += 1
else:
self.remove(item)
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index e3d5d69..320c8b8 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -1031,7 +1031,7 @@
# wait until the report thread is shut down; the user can
# interrupt it by pressing CTRL-C.
try:
- while bot.history.reportThread.isAlive():
+ while bot.history.reportThread.is_alive():
time.sleep(0.1)
except KeyboardInterrupt:
pywikibot.output('Report thread interrupted.')
--
To view, visit https://gerrit.wikimedia.org/r/505459
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: I7322d86a73133fa28f97d3b1e0b406fd08645137
Gerrit-Change-Number: 505459
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.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: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/505409 )
Change subject: Implement create_short_link function to use Extension:UrlShortener
......................................................................
Implement create_short_link function to use Extension:UrlShortener
Implement create_short_link in APISite then in BasePage.
Bug: T220876
Change-Id: I57280c24e0049cda751bf5646f58079763316b55
---
M pywikibot/family.py
M pywikibot/page.py
M pywikibot/site.py
3 files changed, 52 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 5f5c932..97ed83e 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -933,6 +933,10 @@
# 'pt': { '_default': [0]}
# }
+ # Some wiki farms have UrlShortener extension enabled only on the main
+ # site. This value can specify this last one with (lang, family) tuple.
+ shared_urlshortner_wiki = None
+
_families = {}
def __getattribute__(self, name):
@@ -1676,6 +1680,10 @@
# wikibase code and item number:
disambcatname = {'wikidata': 'Q1982926'}
+ # UrlShortener extension is only usable on metawiki, and this wiki can
+ # process links to all WM domains.
+ shared_urlshortner_wiki = ('meta', 'meta')
+
@classproperty
def domain(cls):
"""Domain property."""
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 05c05f8..b4cfd5f 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2212,6 +2212,33 @@
"""
return self.content_model == 'flow-board'
+ def create_short_link(self, permalink=False, with_protocol=False):
+ """
+ Return a shortened link that points to that page.
+
+ If shared_urlshortner_wiki is defined in family config, it'll use
+ that site to create the link instead of the current wiki.
+
+ @param permalink: If true, the link will point to the actual revision
+ of the page.
+ @type permalink: bool
+ @param with_protocol: If true, the link will have https propotol
+ prepend.
+ @type with_protocol: bool
+ @return: The reduced link.
+ @rtype: str
+ """
+ wiki = self.site
+ if self.site.family.shared_urlshortner_wiki:
+ wiki = pywikibot.Site(*self.site.family.shared_urlshortner_wiki)
+
+ url = self.permalink() if permalink else self.full_url()
+
+ link = wiki.create_short_link(url)
+ if with_protocol:
+ return '{}://{}'.format(wiki.protocol(), link)
+ return link
+
# ####### DEPRECATED METHODS ########
@deprecated('Site.encoding()', since='20090307')
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 0373533..12de127 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -7454,6 +7454,23 @@
gen.set_maximum_items(total)
return gen
+ @need_extension('UrlShortener')
+ def create_short_link(self, url):
+ """
+ Return a shortened link.
+
+ Note that on Wikimedia wikis only metawiki supports this action,
+ and this wiki can process links to all WM domains.
+
+ @param url: The link to reduce, with propotol prefix.
+ @type url: str
+ @return: The reduced link, without protocol prefix.
+ @rtype: str
+ """
+ req = self._simple_request(action='shortenurl', url=url)
+ data = req.submit()
+ return data['shortenurl']['shorturl']
+
# aliases for backwards compatibility
isBlocked = redirect_func(is_blocked, old_name='isBlocked',
class_name='APISite', since='20141218')
--
To view, visit https://gerrit.wikimedia.org/r/505409
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: I57280c24e0049cda751bf5646f58079763316b55
Gerrit-Change-Number: 505409
Gerrit-PatchSet: 2
Gerrit-Owner: Framawiki <framawiki(a)tools.wmflabs.org>
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)