Page MenuHomePhabricator

ErfgoedBot categorisation fails with 'unicode' object has no attribute 'isHiddenCategory'
Closed, ResolvedPublic

Description

Traceback (most recent call last):
  File "/data/project/heritage/pywikibot/pwb.py", line 263, in <module>
    if not main():
  File "/data/project/heritage/pywikibot/pwb.py", line 257, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "/data/project/heritage/pywikibot/pwb.py", line 121, in run_python_file
    main_mod.__dict__)
  File "/data/project/heritage/erfgoedbot/categorize_images.py", line 557, in <module>
    main()
  File "/data/project/heritage/erfgoedbot/categorize_images.py", line 547, in main
    countrycode, lang, countryconfig, commonsCatTemplates, conn, cursor)
  File "/data/project/heritage/erfgoedbot/categorize_images.py", line 427, in processCountry
    commonsCatTemplates, page, conn, cursor, harvest_type)
  File "/data/project/heritage/erfgoedbot/categorize_images.py", line 107, in categorizeImage
    replace_default_cat_with_new_categories_in_image(page, commonsCategoryBase, newcats, comment, verbose=True)
  File "/data/project/heritage/erfgoedbot/categorize_images.py", line 202, in replace_default_cat_with_new_categories_in_image
    old_categories)
  File "/data/project/heritage/erfgoedbot/categorize_images.py", line 242, in filter_out_categories_to_add
    list(candidate_categories))
  File "/data/project/heritage/erfgoedbot/categorize_images.py", line 241, in <lambda>
    final_categories = filter(lambda cat: not cat.isHiddenCategory(),
AttributeError: 'unicode' object has no attribute 'isHiddenCategory'
CRITICAL: Closing network session.
<type 'exceptions.AttributeError'>

Event Timeline

Sounds like a category name, rather then a pywikibot.Category object, made it's way into the list

For which run/country did you get this?

Change 377927 had a related patch set uploaded (by Lokal Profil; owner: Lokal Profil):
[labs/tools/heritage@master] Ensure all added categories are pywikibot.Category objects

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

Change 377927 merged by jenkins-bot:
[labs/tools/heritage@master] Ensure all added categories are pywikibot.Category objects

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

Thanks for looking into it @Lokal_Profil !I just saw it in the logs − no clue what country/file it was. We need better exception handling for this :-/