CLI sessions: handle case where retry is not passed as an argument #364
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some logic was introduced in #283 to allow auto-retries in the CLI sessions plugin. This new functionality is disabled by default. As can be seen in the original PR, most of the testing has been done using
omero sessions login
where the functionality was introduced.Most CLI plugins can inherit the login mechanism: the addition of
add_login_arguments()
in the CLI plugin sub-parser means theself.ctx.conn(args)
can then useself.controls["sessions"].login(args)
.As the
--retry
argument was only added to the sessions plugin, a misleading error message can be printed under some scenarios. The most typical ones and the easiest to reproduce is to enter an incorrect password. Thelogin
command produces the expected behavior with 3 tries by defaut:But any other command will fail immediately with a cryptic
InternalException
e5ac9c6 proposes one way to fix this issue by adding an additional check for the existence of the
retry
in thevar(args)
dictionary and would make the two examples above behave identically.An alternate strategy would be to add
--retry
toParser. add_login_arguments
and allow all sub-commands to set the value.