Page MenuHomePhabricator

Pywikibot logs despite -nolog
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

  • Decrease the space on your device :-)
  • Run pwb.py with -nolog

What happens?:

c:\Pywikibot>python pwb.py -nolog logstat.py
Traceback (most recent call last):
  File "pwb.py", line 39, in <module>
    sys.exit(main())
  File "pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "C:\Python37\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Python37\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "pywikibot\scripts\wrapper.py", line 516, in <module>
    main()
  File "pywikibot\scripts\wrapper.py", line 500, in main
    if not execute():
  File "pywikibot\scripts\wrapper.py", line 438, in execute
    unknown_args = pwb.handle_args(global_args)
  File "c:\Pywikibot\pywikibot\bot.py", line 1011, in handle_args
    writeToCommandLogFile()
  File "c:\Pywikibot\pywikibot\bot.py", line 1135, in writeToCommandLogFile
    command_log_file.write(' '.join(args) + os.linesep)
  File "C:\Python37\lib\contextlib.py", line 298, in __exit__
    self.thing.close()
OSError: [Errno 28] No space left on device
CRITICAL: Exiting due to uncaught exception <class 'OSError'>

What should have happened instead?:
Run without a problem and not use device.

Software version: 8.0.0

Event Timeline

In looking at this one, it seems like there is an issue with how arguments are handled. If -nolog is included as a global argument before the name of the script, then the wrapper handles -nolog as part of its arguments and it does not carry over into logstat.py. If -nolog is included as a local argument (after logstat.py in arguments), then logstat.py is not logged to the command log because -nolog is applied.

I will verify whether this is the case for all global arguments, as that would be a larger issue. Should this apply to all global arguments, I will write up a new bug report.

Change 973395 had a related patch set uploaded (by Enag2000; author: Enag2000):

[pywikibot/core@master] Pass global arguments into bot script from wrapper.

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

Under this change, commands like -log and -nolog will be applied to both the wrapper and the bot script to be run. If that is not desired, I can do another patchset.

Change 973395 merged by jenkins-bot:

[pywikibot/core@master] Pass global -nolog argument into bot script from wrapper.

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