Changeset View
Standalone View
swh/deposit/cli/__init__.py
Show All 10 Lines | |||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
@click.group(context_settings=CONTEXT_SETTINGS) | @click.group(context_settings=CONTEXT_SETTINGS) | ||||
@click.pass_context | @click.pass_context | ||||
def deposit(ctx): | def deposit(ctx): | ||||
"""Deposit main command | """Deposit main command | ||||
""" | """ | ||||
logger.debug('deposit') | if hasattr(ctx, 'obj') and ctx.obj is not None: | ||||
log_level = ctx.obj['log_level'] | |||||
else: | |||||
log_level = logging.INFO | |||||
ardumont: Without this, this no longer displayed anything...
Which i think you warned me a little earlier… | |||||
Not Done Inline ActionsHow can ctx.obj not be None? vlorentz: How can `ctx.obj` not be `None`? | |||||
Done Inline ActionsBecause, from my understanding of the latest refactoring on cli (swh-core), depending on how you call this, this can be populated. That's what i meant in my first comment here about the behavior divergence between swh deposit (using swh-core inheritance, i'd expect ctx.obj not none here) and (swh-deposit, no init, i'd expect it to be none). ardumont: Because, from my understanding of the latest refactoring on cli (swh-core), depending on how… | |||||
Not Done Inline Actionsnvm, got it. What about doing this instead? ctx.ensure_object(dict) log_level = ctx.obj.get('log_level', logging.INFO) vlorentz: nvm, got it. What about doing this instead?
```
ctx.ensure_object(dict)
log_level = ctx.obj. | |||||
Done Inline ActionsI tried the second line initially without and that failed. I'll check Thanks for the heads up. ardumont: I tried the second line initially without and that failed.
Probably because of the missing… | |||||
Done Inline ActionsIt works, awesome. ardumont: It works, awesome.
I'll change. | |||||
logger.setLevel(log_level) | |||||
ctx.ensure_object(dict) | ctx.ensure_object(dict) | ||||
def main(): | def main(): | ||||
logging.basicConfig() | logging.basicConfig() | ||||
return deposit(auto_envvar_prefix='SWH_DEPOSIT') | return deposit(auto_envvar_prefix='SWH_DEPOSIT') | ||||
# These import statements MUST be executed after defining the 'deposit' group | # These import statements MUST be executed after defining the 'deposit' group | ||||
Show All 10 Lines |
Without this, this no longer displayed anything...
Which i think you warned me a little earlier during the week ;)
This fixed both swh-deposit and swh deposit which were divergent in behavior.