python - pexpect - how to match a lot of blocks in large output strings -
i using pexpect login remote devices query metrics.
the output of command large (about 15k bytes) , need extract many metrics output. use big pattern string
"key1:([0-9a-za-z]*).*key2:([0-9a-za-z]*).*key3......"
to match metrics. when pattern long, expect block , never terminate.
i've set maxread
20k doesn't work. have ideas on how resolve issue?
add code snippet:
session.sendline(command_info["text"]) ret = session.expect([cmd_prompt, pexpect.eof, pexpect.timeout]) if ret == 1: logger.error("eof error.") return if ret == 2: logger.error("timeout") return result = re.match(getexpectedgroupstr(command_info, logger), session.before, re.s)
if use big pattern string instead of cmd_prompt, session.expect hang , never terminate if timeout reached.
Comments
Post a Comment