Page MenuHomeSoftware Heritage

cli: Fix swh-scheduler command

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



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
Scheduling the loading of the git repository located at[] 

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

Depends on D1463

Diff Detail

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

Event Timeline

anlambert created this revision.May 14 2019, 4:20 PM
anlambert edited the summary of this revision. (Show Details)May 14 2019, 6:11 PM
anlambert updated this revision to Diff 4812.May 15 2019, 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.May 15 2019, 1:55 PM
anlambert edited the summary of this revision. (Show Details)
anlambert updated this revision to Diff 4813.May 15 2019, 1:57 PM

Update: simplify code

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

I would have just written this as

    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.May 15 2019, 2:38 PM
This revision was automatically updated to reflect the committed changes.