2021-09-09 13:36:34 +00:00
|
|
|
#!/usr/bin/python3.8
|
|
|
|
|
|
|
|
import pexpect
|
|
|
|
|
|
|
|
from robot.api.deco import keyword
|
|
|
|
|
|
|
|
ROBOT_AUTO_KEYWORDS = False
|
|
|
|
|
2022-06-09 13:08:11 +00:00
|
|
|
|
2021-09-09 13:36:34 +00:00
|
|
|
@keyword('Run Process And Enter Empty Password')
|
|
|
|
def run_proccess_and_interact(cmd: str) -> str:
|
|
|
|
p = pexpect.spawn(cmd)
|
|
|
|
p.expect("[pP]assword")
|
|
|
|
# enter empty password
|
|
|
|
p.sendline('\r')
|
|
|
|
p.wait()
|
|
|
|
# throw a string with password prompt
|
|
|
|
first = p.readline()
|
|
|
|
# take all output
|
|
|
|
child_output = p.readline()
|
|
|
|
p.close()
|
|
|
|
if p.exitstatus != 0:
|
|
|
|
raise Exception(f"{first}\n{child_output}")
|
|
|
|
return child_output
|