Question

I have an expected string "Version 0.0.9999.0"

I do the spawn correctly then

e.expect('Version 0.0.9999.0')

and this works fine, however, I want to make it dynamic to accept any version (any 4 numbers separated by dots). Is this possible or does it have to be a specific string? if yes, how?

Thanks.

Was it helpful?

Solution

The method you are using actually expects a pattern and not a fixed string, as per the documentation:

expect(self, pattern, timeout=-1, searchwindowsize=None)

This seeks through the stream until a pattern is matched. The pattern is overloaded and may take several types. The pattern can be a StringType, EOF, a compiled re, or a list of any of those types. Strings will be compiled to re types.

From what you say, the regular expression could be something like "Version \d.\d.\d{4}.\d", but it depends on the possible values for the version. For fixed strings there is expect_exact.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top