Fix various FIXME related to ShellSession.prompt_str
There are 3 different FIXME in the lava_dispatcher source code related to the ShellSession.prompt_str:
- FIXME: rename prompt_str to indicate it can be a list or str
- FIXME: This should be logged whenever prompt_str is changed, by the connection object.
- FIXME: connection.prompt_str needs to be always a list
For point 1 I looked in to how that attribute is used and gave it
a name that indicates its use. What is actually used for is the
pexpect's Spawn.expect method call. The argument name is called
patterns
. So rename prompt_str to spawn_expect_patterns.
For point 2 the changes to prompt_str are already logged in the setter so no additional logging is required. Remove all logger calls that log the changes to prompt_str.
For point 3 it looks like the job schemas allow prompt be either string or list of strings. However, internally the prompt_str is expected to be a list of strings. While it is possible to change the schema to not accept single strings it would break someones setup. I think a better solution is to wrap single strings in to a list of one element using a setter function. This way internally the prompt_str would always be list of strings but no existing job would break.
I also looked in to providing the typing information for this attribute. Unfortunately the @property.setter is required to only accept the same typing as the read part of property. So it is impossible to have a @Property that reads one type and writes different type. (without declaring your own descriptor class) So instead I made the spawn_expect_patterns a read-only property and added a set_spawn_expect_patterns function which accepts both string and a list.