Page MenuHomePhabricator

Make QuitKeyboardInterrupt errors unified and disable traceback in scripts
Open, MediumPublic

Description

Steps to reproduce

  1. Run e.g. python pwb.py template commonscat -remove -ns:0 -start:! on cswiki
  2. Select option q (quit) or press Ctrl+C

Expected behavior (10 % of scripts)

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit [l]atest, open in [b]rowser, [a]ll, [q]uit): q
Bot was interrupted by user, 8 pages are waiting for being saved:
Page Orange was saved
...
Page Pineapple was saved
[user@Computer pywikibot]$ ▮

Current behavior (90 % of scripts)

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit [l]atest, open in [b]rowser, [a]ll, [q]uit): q
ERROR: Fatal error:
Traceback (most recent call last):
  File "./scripts/template.py", line 366, in <module>
    main()
  File "./scripts/template.py", line 361, in main
    bot.run()
  File "/home/pavel/pywikibot/scripts/replace.py", line 771, in run
    default='N')
  File "/home/pavel/pywikibot/pywikibot/bot.py", line 451, in input_choice
    automatic_quit=automatic_quit, force=force)
  File "/home/pavel/pywikibot/pywikibot/userinterfaces/terminal_interface_base.py", line 392, in input_choice
    raise answer
pywikibot.bot_choice.QuitKeyboardInterrupt[user@Computer pywikibot]$ ▮

This is problem of 90 % of all scripts, but there are some which behave as expected (I think replace or category's output is ok, but the behavior should be unified and global)

Relevant scripts

  • archivebot
  • category_redirect
  • checkimages
  • cleansandbox
  • downloaddump
  • interwiki
  • login
  • nowcommons
  • replicate_wiki
  • revertbot
  • templatecount
  • watchlist

Event Timeline

Dvorapa updated the task description. (Show Details)
Dvorapa updated the task description. (Show Details)
Dvorapa updated the task description. (Show Details)

In other words, make all scripts inherit from BaseBot class...

Xqt triaged this task as Medium priority.Aug 4 2017, 12:25 PM
Xqt subscribed.

Aha. I now see how to create good task (detailed).. Thank you!

Honestly I don't understand why the quit should be a KeyboardInterrupt and not SystemExit, which are both direct sub-exceptions of BaseException. KeyboardInterrupt are almost always for SIGINTs, which may happen in many cases, most commonly CTRL-C, but it is usually an unexpected input and therefore people like a traceback. Script-caused exits should be SystemExit instead, as they are entirely expected, and will not cause a traceback in default sys.excepthook (sys.__excepthook__).

Xqt renamed this task from Make KeyboardInterrupt errors unified and disable traceback in scripts to Make QuitKeyboardInterrupt errors unified and disable traceback in scripts.Aug 22 2017, 5:53 AM

The exception is QuitKeyboardInterrupt to be used with bot class. Unfortunately not all bot scripts derive from it and in result you get an exception similar to KeyboardInterrupt which is the right behavior then because the user wants to terminate.

Change 434330 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR, bugfix] use Bot's default behaviour for followlive.py

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

Change 434325 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [cleanup] use Bot's default run method

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

Change 434325 merged by jenkins-bot:
[pywikibot/core@master] [cleanup] use Bot's default run method

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

Change 434330 merged by jenkins-bot:
[pywikibot/core@master] [IMPR, bugfix] use Bot's default behaviour for followlive.py

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

Change 589717 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] rename replace.run() with replace.treat()

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

Change 589717 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] rename replace.run() with replace.treat()

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

Change 636460 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Rename ReferencesRobot.run to treat

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

Change 636132 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] split WelcomeBot.run into parts

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

Change 636460 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Rename ReferencesRobot.run to treat

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

Change 443832 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] remove outdated "followRedirects" parameter from imagelinks()

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

Change 443832 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] remove outdated "followRedirects" parameter from imagelinks()

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

Change 636132 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] split WelcomeBot.run into parts

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

Change 641057 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Derive CommonsLinkBot from CurrentPageBot

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

Change 641057 abandoned by Xqt:
[pywikibot/core@master] [IMPR] Derive CommonsLinkBot from CurrentPageBot

Reason:
no longer maintained

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

@Xqt: Hi, all related patches in Gerrit have been merged or abandoned. Is there more to do in this task? Asking as you are set as task assignee. Thanks in advance!
(You can change the task status via Add Action...Change Status in the dropdown menu.)

Aklapper removed Xqt as the assignee of this task.Jul 2 2021, 5:22 AM

Removing task assignee due to inactivity, as this open task has been assigned for more than two years (see emails sent to assignee on May26 and Jun17, and T270544). Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be very welcome!

(See https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator.)

Change 724000 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Derive blockpageschecker.py from CurrentPageBot

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

Change 724000 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Derive blockpageschecker.py from CurrentPageBot

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

Xqt updated the task description. (Show Details)
Xqt updated the task description. (Show Details)