jenkins-bot has submitted this change and it was merged.
Change subject: pwb.py: make sure pywikibot is correctly loaded before starting a script ......................................................................
pwb.py: make sure pywikibot is correctly loaded before starting a script
generate_user_files.py will load pywikibot with PYWIKIBOT2_NO_USER_CONFIG=2, which works correctly, but will overwrite command line arguments (pywikibot.argvu). This makes sure pywikibot is fully loaded before we try to change argv/argvu, by setting PYWIKIBOT2_NO_USER_CONFIG=2 ourselves if no user-config.py is found.
In addition, add the missing argvu parameter to generate_user_files.py.
Bug: T126880 Change-Id: I0f84e5b739942154f8fe164b47d19cfac47266c0 --- M pwb.py 1 file changed, 8 insertions(+), 5 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py index fe2eeec..0c31b26 100755 --- a/pwb.py +++ b/pwb.py @@ -64,9 +64,10 @@ try: import pywikibot # noqa pwb = pywikibot - except RuntimeError: - pwb = lambda: None - pwb.argvu = [] + except RuntimeError: # no user-config.py provided + os.environ['PYWIKIBOT2_NO_USER_CONFIG'] = '2' + import pywikibot # noqa + pwb = pywikibot
def run_python_file(filename, argv, argvu, package=None): @@ -206,11 +207,13 @@ except RuntimeError as err: # user-config.py to be created print("NOTE: 'user-config.py' was not found!") - if filename is not None and not filename.startswith('generate_'): + if not filename.startswith('generate_'): print("Please follow the prompts to create it:") run_python_file('generate_user_files.py', ['generate_user_files.py'], - []) + [u'generate_user_files.py']) + # because we have loaded pywikibot without user-config.py loaded, we need to re-start + # the entire process. Ask the user to do so. sys.exit(1)
pywikibot-commits@lists.wikimedia.org