Need little assistance with making this code work with pexpect module.
This code executes git pull by logging into a server and then downloads the latest code (if upgrade is available) or just sends out a messages saying "Already up-to-date."
The code actually idenfies the password screen but does not identify the text "already up-to-date"
not sure if I'm missing anything here.
A snippet from the code is:
p = pexpect.spawn('git pull',cwd = comp_dir,maxread = 10000, timeout = 100)
i = p.expect(['password:','Already up-to-date.',pexpect.EOF])
if i == 0:
output_lines = p.before
output_line_list = output_lines.split('\r\n')
for line in output_line_list: print line
count = 0
p.sendline(pwd)
while count < 3: **# The server in case of unsuccessful login asks for password thrice so this check... (not sure if there is a better way of achieving this)**
try:
output = p.expect('Permission denied')
count+=1
p.sendline(pwd)
p.logfile = sys.stdout
except:
print 'Successful Login !!!! ------'
p.expect('Already up-to-date',timeout=None)
count = 3
if i == 1:
output_lines = p.before
output_line_list = output_lines.split('\r\n')
for line in output_line_list: print line
p.expect(pexpect.EOF)
Any help is greatly appreciated.
Thanks, -Vijay