open-iscsi / configshell-fb

configshell with additional modifications, see README
Apache License 2.0
28 stars 37 forks source link

Calling non-existing command causes failure of shell context #12

Closed iavael closed 10 years ago

iavael commented 10 years ago

When user tries to call non-existing command, library thows exception, which could be caught only after shell context termination and the only is to restart the shell.

agrover commented 10 years ago

This is a change we made to give the caller a chance to do something when an exception occurs, instead of swallowing the exception internally. You can look at the changes in targetcli-fb's script:

    while not shell._exit:
        try:
            shell.run_interactive()
        except (RTSLibError, ExecutionError) as msg:
            shell.log.error(str(msg))

basically just handling the exception (if desired) and then re-invoking the shell if an explicit exit command has not been given.

iavael commented 10 years ago

Ok, I agree that catching this exception is necessary. But if shell initialization is heavy it may be reasonable to let user catch exception closer to it's raise, so that there would be no need to reinitialize shell context.

agrover commented 10 years ago

It's just re-invoking run_interactive, which is not a big deal as far as I can tell.

iavael commented 10 years ago

Ok, I've got it, thanks for your help.