Page MenuHomePhabricator

NowCommons template not found
Closed, ResolvedPublic

Description

The bot says that template isn't found though it's actually present and is mentioned in the code:

C:\pt2>c:\python27\python.exe pwb.py nowcommons.py -replaceloose -replace -v
The base directory is C:\pt2
=== Pywikibot framework v2.0 -- Logging header ===
COMMAND: ['nowcommons.py', '-replaceloose', '-replace', '-v']
DATE: 2015-04-26 12:25:18.418000 UTC
svnversion failed
WARNING: C:\pt2\pywikibot\version.py:97: DeprecationWarning: pywikibot.version.g
etversion_svn is deprecated, use getversion_svn_setuptools instead.
  (tag, rev, date, hsh) = vcs_func(_program_dir)

WARNING: C:\pt2\pywikibot\version.py:245: DeprecationWarning: pywikibot.version.
svn_rev_info is deprecated, use getversion_svn_setuptools instead.
  tag, rev, date = svn_rev_info(_program_dir)

VERSION: pywikibot/__init__.py (, -1 (unknown), 2015/04/26, 13:50:19, n/a)
CONFIG FILE DIR: C:\pt2
PACKAGES:
  BaseHTTPServer (c:\python27\lib\BaseHTTPServer.pyc) = 0.3
  SimpleHTTPServer (c:\python27\lib\SimpleHTTPServer.pyc) = 0.6
  SocketServer (c:\python27\lib\SocketServer.pyc) = 0.4
  Tkinter (c:\python27\lib\lib-tk\Tkinter.pyc) = $Revision: 81008 $
  _ctypes (c:\python27\DLLs\_ctypes.pyd) = 1.1.0
  _hashlib (c:\python27\DLLs\_hashlib.pyd) = ??
  _socket (c:\python27\DLLs\_socket.pyd) = ??
  _sqlite3 (c:\python27\DLLs\_sqlite3.pyd) = ??
  _ssl (c:\python27\DLLs\_ssl.pyd) = ??
  _tkinter (c:\python27\DLLs\_tkinter.pyd) = ??
  cgi (c:\python27\lib\cgi.pyc) = 2.6
  ctypes (c:\python27\lib\ctypes\) = 1.1.0
  distutils (c:\python27\lib\distutils\) = 2.7.9
  email (c:\python27\lib\email\) = 4.0.3
  logging (c:\python27\lib\logging\) = 0.5.1.2
  mwparserfromhell: No module named mwparserfromhell
  pickle (c:\python27\lib\pickle.pyc) = $Revision: 72223 $
  platform (c:\python27\lib\platform.pyc) = 1.0.7
  pyexpat (c:\python27\DLLs\pyexpat.pyd) = 2.7.9
  pywikibot ([path unknown]) = ??
  re (c:\python27\lib\re.pyc) = 2.2.1
  select (c:\python27\DLLs\select.pyd) = ??
  setuptools (c:\python27\lib\site-packages\setuptools\) = 7.0
  tkFont (c:\python27\lib\lib-tk\tkFont.pyc) = 0.9
  unicodedata (c:\python27\DLLs\unicodedata.pyd) = ??
  urllib (c:\python27\lib\urllib.pyc) = 1.17
  urllib2 (c:\python27\lib\urllib2.pyc) = 2.7
MODULES:
=== === === === === === === === === === === === === ===
Pywikibot SVN repository
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)]
LOADING SITE wikipedia:ru VERSION: 1.26wmf2
Found 2 wikipedia:ru processes running, including this one.
Retrieving 50 pages from wikipedia:ru.
Working on u'\u0424\u0430\u0439\u043b:Ptz al vet.jpg'


>>> Файл:Ptz al vet.jpg <<<
NowCommons template not found.
Working on u'\u0424\u0430\u0439\u043b:Ptz-al-pobr.jpg'


>>> Файл:Ptz-al-pobr.jpg <<<
NowCommons template not found.
Working on u'\u0424\u0430\u0439\u043b:Magas-4.PNG'


>>> Файл:Magas-4.PNG <<<
NowCommons template not found.
Working on u'\u0424\u0430\u0439\u043b:Groz-11.PNG'


>>> Файл:Groz-11.PNG <<<
NowCommons template not found.
Working on u'\u0424\u0430\u0439\u043b:Groz-12.PNG'


>>> Файл:Groz-12.PNG <<<
NowCommons template not found.
Working on u'\u0424\u0430\u0439\u043b:Groz-13.PNG'


>>> Файл:Groz-13.PNG <<<
NowCommons template not found.
Working on u'\u0424\u0430\u0439\u043b:Groz-14.PNG'

See file: it has {{NowCommons}} template, mentioned in line 153 of nowcommons.py

Details

Related Gerrit Patches:

Event Timeline

Rubin16 created this task.Apr 26 2015, 12:30 PM
Rubin16 raised the priority of this task from to Normal.
Rubin16 updated the task description. (Show Details)
Rubin16 added a project: Pywikibot.
Rubin16 added a subscriber: Rubin16.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptApr 26 2015, 12:30 PM
XZise added a subscriber: XZise.Apr 26 2015, 12:54 PM

Hmm I where does Файл:Groz-14.PNG have a now commons template? In line 333 of nowcommons.py it's searching through the contents of that page and looking for the template. As that page is not hosted on the Russian Wikipedia anymore that won't work.

>>> s = pywikibot.Site('ru', 'wikipedia')
>>> p = pywikibot.Page(s, 'Файл:Groz-14.PNG')
>>> list(p.templatesWithParams())
[]

And (if I interpret that correctly), the file was moved on 2015-04-13 and you've run your script 13 days later.

Oops, I have already deleted it.

When I ran the script, the file was the following:
https://ru.wikipedia.org/wiki/%D0%A4%D0%B0%D0%B9%D0%BB:Groz-14.PNG

XZise added a comment.Apr 26 2015, 1:10 PM

Ah okay, I tested it with that:

>>> import pywikibot
>>> s = pywikibot.Site('ru', 'wikipedia')
>>> p = pywikibot.Page(s, 'Файл:Groz-14.PNG')
>>> t = list(p.templatesWithParams())
>>> list(p.templatesWithParams())
[(Page(b'\xd0\xa8\xd0\xb0\xd0\xb1\xd0\xbb\xd0\xbe\xd0\xbd:\xd0\x98\xd0\xb7\xd0\xbe\xd0\xb1\xd1\x80\xd0\xb0\xd0\xb6\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5'), ['Время создания=2010', 'Источник=Станислав Гайдук', 'Автор=Станислав Гайдук', 'Описание=Грозный, фонтан, 2010 год.']), (Page(b'\xd0\xa8\xd0\xb0\xd0\xb1\xd0\xbb\xd0\xbe\xd0\xbd:PD-self'), []), (Page(b'\xd0\xa8\xd0\xb0\xd0\xb1\xd0\xbb\xd0\xbe\xd0\xbd:NowCommons'), [])]
>>> [_[0] for _ in t]
[Page(b'\xd0\xa8\xd0\xb0\xd0\xb1\xd0\xbb\xd0\xbe\xd0\xbd:\xd0\x98\xd0\xb7\xd0\xbe\xd0\xb1\xd1\x80\xd0\xb0\xd0\xb6\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5'), Page(b'\xd0\xa8\xd0\xb0\xd0\xb1\xd0\xbb\xd0\xbe\xd0\xbd:PD-self'), Page(b'\xd0\xa8\xd0\xb0\xd0\xb1\xd0\xbb\xd0\xbe\xd0\xbd:NowCommons')]
>>> [_[0] in ['NowCommons'] for _ in t]
[False, False, False]
>>> [_[0].title(withNamespace=False) in ['NowCommons'] for _ in t]
[False, False, True]

So I think at some point templatesWithParams returned a Page instance instead of a string and nowcommons hasn't been updated.

XZise added a comment.Apr 26 2015, 1:35 PM

Okay I checked and compat does use strings while core uses since 55d6232e Page instances. And the script was committed in 00dee9ab with the code regarding the templates as it is now.

Change 206759 had a related patch set uploaded (by XZise):
[FIX] Expect that the template is a Page instance

https://gerrit.wikimedia.org/r/206759

Change 206759 merged by jenkins-bot:
[FIX] Expect that the template is a Page instance

https://gerrit.wikimedia.org/r/206759

Xqt closed this task as Resolved.May 2 2015, 2:32 PM
Xqt claimed this task.
XZise claimed this task.May 2 2015, 4:39 PM
XZise set Security to None.