jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/607072 )
Change subject: [IMPR] a wait time may be given with -simulate option ......................................................................
[IMPR] a wait time may be given with -simulate option
This is a more realistic simulation because it simulates a delay for each write action.
Change-Id: I3fa4b5f430e8d59a5648eb89cb6042b752f1d809 --- M pywikibot/bot.py M pywikibot/data/api.py 2 files changed, 6 insertions(+), 1 deletion(-)
Approvals: Matěj Suchánek: Looks good to me, but someone else must approve JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py index 1dc7855..ca6af38 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -210,6 +210,8 @@ -simulate Disables writing to the server. Useful for testing and debugging of new code (if given, doesn't do any real changes, but only shows what would have been changed). + An integer or float value may be given to simulate a + processing time; the bot just waits for given seconds.
-<config var>:n You may use all given numeric config variables as option and modify it with command line. @@ -839,7 +841,7 @@ output('NOTE: option cosmetic_changes is %s\n' % config.cosmetic_changes) elif option == '-simulate': - config.simulate = True + config.simulate = value or True # # DEBUG control: # diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 8a80457..28b64e4 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1592,6 +1592,9 @@ pywikibot.output(color_format( '{lightyellow}SIMULATION: {0} action blocked.{default}', action)) + # for more realistic simulation + if config.simulate is not True: + pywikibot.sleep(float(config.simulate)) return {action: {'result': 'Success', 'nochange': ''}}
def _is_wikibase_error_retryable(self, error):
pywikibot-commits@lists.wikimedia.org