Page MenuHomePhabricator

generate_family_file fails to create a file for schoolwiki.in
Closed, ResolvedPublic

Description

C:\pwb\GIT\core>pwb generate_family_file https://schoolwiki.in

Usage: generate_family_file.py <url> <short name>
Example: generate_family_file.py https://www.mywiki.bogus/wiki/Main_Page mywiki
This will create the file mywiki_family.py in pywikibot\families
Please insert a short name (eg: freeciv): school
Generating family file from https://schoolwiki.in
Traceback (most recent call last):
  File "C:\pwb\GIT\core\pwb.py", line 362, in <module>
    if not main():
  File "C:\pwb\GIT\core\pwb.py", line 354, in main
    run_python_file(filename,
  File "C:\pwb\GIT\core\pwb.py", line 73, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File ".\generate_family_file.py", line 207, in <module>
    main()
  File ".\generate_family_file.py", line 203, in main
    FamilyFileGenerator(*sys.argv[1:]).run()
  File ".\generate_family_file.py", line 44, in run
    w = self.Wiki(self.base_url)
  File "C:\pwb\GIT\core\pywikibot\site_detect.py", line 42, in __init__
    r = fetch(fromurl)
  File "C:\pwb\GIT\core\pywikibot\comms\http.py", line 453, in fetch
    error_handling_callback(request)
  File "C:\pwb\GIT\core\pywikibot\comms\http.py", line 336, in error_handling_callback
    raise FatalServerError(str(request.data))
pywikibot.exceptions.FatalServerError: HTTPSConnectionPool(host='schoolwiki.in', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.FatalServerError'>

C:\pwb\GIT\core>

MediaWiki version is <meta name="generator" content="MediaWiki 1.27.3"/>

See also T263983

Event Timeline

Xqt triaged this task as Medium priority.Oct 11 2020, 12:20 PM
Xqt added a subscriber: Mpaa.

For solution ignore_validation must be set for session.request in http._http_process. I have to check how this can be done with generate_family_file.py.

As a quick solution the attached file can be used which is a result of the generator script..

@Adithyak1997:

@Xqt That didn't work. I have got following error:

C:\Users\Adithya K\pywikibot>python pwb.py login
ERROR: Traceback (most recent call last):
  File "C:\Users\Adithya K\pywikibot\pywikibot\data\api.py", line 1705, in _http_request
    data = http.request(
  File "C:\Users\Adithya K\pywikibot\pywikibot\tools\__init__.py", line 1499, in wrapper
    return obj(*__args, **__kw)
  File "C:\Users\Adithya K\pywikibot\pywikibot\comms\http.py", line 313, in request
    r = fetch(baseuri, method, params, body, headers, **kwargs)
  File "C:\Users\Adithya K\pywikibot\pywikibot\comms\http.py", line 516, in fetch
    error_handling_callback(request)
  File "C:\Users\Adithya K\pywikibot\pywikibot\comms\http.py", line 397, in error_handling_callback
    raise FatalServerError(str(request.data))
pywikibot.exceptions.FatalServerError: HTTPSConnectionPool(host='schoolwiki.in', port=443): Max retries exceeded with url: /api.php?action=query&meta=siteinfo%7Cuserinfo&siprop=namespaces%7Cnamespacealiases%7Cgeneral&continue=&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))

Traceback (most recent call last):
  File "pwb.py", line 360, in <module>
    if not main():
  File "pwb.py", line 352, in main
    run_python_file(filename,
  File "pwb.py", line 73, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File ".\scripts\login.py", line 185, in <module>
    main()
  File ".\scripts\login.py", line 167, in main
    site.login(autocreate=autocreate)
  File "C:\Users\Adithya K\pywikibot\pywikibot\tools\__init__.py", line 1499, in wrapper
    return obj(*__args, **__kw)
  File "C:\Users\Adithya K\pywikibot\pywikibot\site\__init__.py", line 1901, in login
    self.getuserinfo(force=True)
  File "C:\Users\Adithya K\pywikibot\pywikibot\site\__init__.py", line 2005, in getuserinfo
    uidata = uirequest.submit()
  File "C:\Users\Adithya K\pywikibot\pywikibot\data\api.py", line 1951, in submit
    self._add_defaults()
  File "C:\Users\Adithya K\pywikibot\pywikibot\data\api.py", line 1477, in _add_defaults
    and self.site.mw_version >= '1.25wmf5'):
  File "C:\Users\Adithya K\pywikibot\pywikibot\site\__init__.py", line 2609, in mw_version
    mw_ver = MediaWikiVersion(self.version())
  File "C:\Users\Adithya K\pywikibot\pywikibot\site\__init__.py", line 2580, in version
    version = self.siteinfo.get('generator',
  File "C:\Users\Adithya K\pywikibot\pywikibot\site\__init__.py", line 1539, in get
    preloaded = self._get_general(key, expiry)
  File "C:\Users\Adithya K\pywikibot\pywikibot\site\__init__.py", line 1485, in _get_general
    default_info = self._get_siteinfo(props, expiry)
  File "C:\Users\Adithya K\pywikibot\pywikibot\site\__init__.py", line 1408, in _get_siteinfo
    data = request.submit()
  File "C:\Users\Adithya K\pywikibot\pywikibot\data\api.py", line 2239, in submit
    self._data = super(CachedRequest, self).submit()
  File "C:\Users\Adithya K\pywikibot\pywikibot\data\api.py", line 1969, in submit
    rawdata, use_get = self._http_request(use_get, uri, body, headers,
  File "C:\Users\Adithya K\pywikibot\pywikibot\data\api.py", line 1705, in _http_request
    data = http.request(
  File "C:\Users\Adithya K\pywikibot\pywikibot\tools\__init__.py", line 1499, in wrapper
    return obj(*__args, **__kw)
  File "C:\Users\Adithya K\pywikibot\pywikibot\comms\http.py", line 313, in request
    r = fetch(baseuri, method, params, body, headers, **kwargs)
  File "C:\Users\Adithya K\pywikibot\pywikibot\comms\http.py", line 516, in fetch
    error_handling_callback(request)
  File "C:\Users\Adithya K\pywikibot\pywikibot\comms\http.py", line 397, in error_handling_callback
    raise FatalServerError(str(request.data))
pywikibot.exceptions.FatalServerError: HTTPSConnectionPool(host='schoolwiki.in', port=443): Max retries exceeded with url: /api.php?action=query&meta=siteinfo%7Cuserinfo&siprop=namespaces%7Cnamespacealiases%7Cgeneral&continue=&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')))
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.FatalServerError'>

The contents of my user-config.py file is:

mylang='ml'
family='school'
usernames['school']['*']='Adithyak1997'
console_encoding='utf-8'
password_file='password.py'

password_py file contains the text in the following format:

('Adithyak1997',BotPassword('Adithyakbot','generated passowrd'))

Change 633353 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Ignore ssl certificate validation in generate_family_file.py

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

Add the following line to the family file given above as you mentioned already with refering to Creating_the_family_file_manually (last lines):

def ignore_certificate_error(self, code):
    return True

I included it here:

Xqt lowered the priority of this task from Medium to Low.Oct 13 2020, 2:18 AM

Change 633353 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Ignore ssl certificate validation in generate_family_file.py

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

Xqt claimed this task.