Page MenuHomeSoftware Heritage

cli: Fix swh-scheduler command
ClosedPublic

Authored by anlambert on Tue, May 14, 4:20 PM.

Details

Summary

Add a simple fix for currently broken swh-scheduler command (see stacktrace below).

The command should be removed soon but while it is still here, it should work.

Executing test script test_01_loader_git.sh
Scheduling the loading of the git repository located at https://forge.softwareheritage.org/source/swh-loader-tar.git[test_01_loader_git.sh] 

Traceback (most recent call last):
  File "/srv/softwareheritage/venv/bin/swh-scheduler", line 10, in <module>
    sys.exit(main())
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/swh/scheduler/cli/__init__.py", line 72, in main
    return cli(auto_envvar_prefix='SWH_SCHEDULER')
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/click/core.py", line 1134, in invoke
    Command.invoke(self, ctx)
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/srv/softwareheritage/venv/lib/python3.6/site-packages/swh/scheduler/cli/__init__.py", line 36, in cli
    loglevel=ctx.obj['log_level'], colorize=False,
TypeError: 'NoneType' object is not subscriptable
An error occurred when running test script test_01_loader_git.sh

Depends on D1463

Diff Detail

Repository
rDSCH Scheduling utilities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Tue, May 14, 4:20 PM
anlambert edited the summary of this revision. (Show Details)Tue, May 14, 6:11 PM
anlambert updated this revision to Diff 4812.Wed, May 15, 1:53 PM

Update: Simply add a fix for the swh-scheduler command until it is removed

anlambert retitled this revision from cli: Use decorator from swh.core.cli for the log level option to cli: Fix swh-scheduler command.Wed, May 15, 1:55 PM
anlambert edited the summary of this revision. (Show Details)
anlambert updated this revision to Diff 4813.Wed, May 15, 1:57 PM

Update: simplify code

douardda accepted this revision.Wed, May 15, 2:38 PM

I would have just written this as

setup_log_handler(
    loglevel=ctx.obj.get('log_level', logging.INFO), colorize=False,
    format='[%(levelname)s] %(name)s -- %(message)s',
    log_console=not no_stdout)

but meh

This revision is now accepted and ready to land.Wed, May 15, 2:38 PM
This revision was automatically updated to reflect the committed changes.