WikibaseSync icon indicating copy to clipboard operation
WikibaseSync copied to clipboard

Can't run WikibaseSync

Open Podbrushkin opened this issue 3 years ago • 1 comments

  • Operating system: Windows 10
  • Python 3.10.8

Hello, I can't run your application - python import_one.py Q2 fails with TypeError: 'NoneType' object is not subscriptable error. I have no expirience with Python or venv, how to launch virtual environment I've found here and here is what I've did:

git clone https://github.com/the-qa-company/WikibaseSync.git
cd WikibaseSync
*created bot, changed 3 config files*
python -m venv .
.\Scripts\activate.bat
pip install -r requirements.txt
python import_one.py Q2

It brings this output:

Traceback (most recent call last):
  File "C:\WikibaseLocal\WikibaseSync\import_one.py", line 17, in <module>
    wikibase_importer = WikibaseImporter(wikibase_repo,wikidata_repo)
  File "C:\WikibaseLocal\WikibaseSync\util\util.py", line 22, in __init__
    self.identifier.get(wikibase_repo)
  File "C:\WikibaseLocal\WikibaseSync\util\PropertyWikidataIdentifier.py", line 32, in get
    wikibase_item.editEntity(data, summary=u'Insert a property to have a wikidata identifier')
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\page\_decorators.py", line 50, in wrapper
    handle(func, self, *args, **kwargs)
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\page\_decorators.py", line 29, in handle
    func(self, *args, **kwargs)
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\page\__init__.py", line 3662, in editEntity
    super().editEntity(data, **kwargs)
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\page\__init__.py", line 3413, in editEntity
    updates = self.repo.editEntity(
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\tools\__init__.py", line 1478, in wrapper
    return obj(*__args, **__kw)
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\site\_decorators.py", line 93, in callee
    return fn(self, *args, **kwargs)
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\site\_datasite.py", line 333, in editEntity
    params['token'] = self.tokens['edit']
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\site\_tokenwallet.py", line 58, in __getitem__
    key = self.site.validate_tokens([key])[0]
  File "C:\WikibaseLocal\WikibaseSync\lib\site-packages\pywikibot\site\_apisite.py", line 1537, in validate_tokens
    types_wiki_old = self._paraminfo.parameter('query+info',
TypeError: 'NoneType' object is not subscriptable
CRITICAL: Exiting due to uncaught exception <class 'TypeError'>

At first I've tried to run python import_one.py Q2 without setting up virtual environment, and it resulted with the same error. Also I'm not quite understand what values should have entityUri and propertyUri variables in application.config.ini file. My WIKIBASE_HOST var in .env file has a 192.168.1.3 value and is accessible in browser via localhost and 192.168.1.3, but 192.168.1.3/entity brings 404 error. Items are available through http://localhost/wiki/Item:Q1 or http://192.168.1.3/wiki/Special:EntityPage/Q1. Is there a way to consistently determine what values should be used for entityUri and propertyUri variables?

Podbrushkin avatar Nov 14 '22 07:11 Podbrushkin

Related to the problem mentioned at https://phabricator.wikimedia.org/T291202.

The pywikibot in this project is out of date and some API modules in MediaWiki were dropped.

If you change the code below in _apisite.py of the pywikibot the code will work.

types_wiki_old = self._paraminfo.parameter('query+info', 'token')['type']

to

if mw_ver < '1.36':
    types_wiki_old = self._paraminfo.parameter('query+info', 'token')['type']
else:
    types_wiki_old = []

It is odd because the exception only occurs since the second import using import_one.py. There is no exception for the first import in a fresh install of the wikibase docker wmde.9.

chauraph avatar Dec 06 '22 14:12 chauraph