I am trying to push all the data in a folder to Github
. If I put the following commands simply in linux shell, everything is OK, but it dots now work on Python
script with Pexpect
.
It seems to me that it is very-very simple and frequently used task, but I have not find any mudule for this task.
Here is my code:
import subprocess
import pexpect
from pexpect import spawn
import os
os.chdir("/home/python/Desktop/")
subprocess.run("git add .", shell=True)
subprocess.run( '''git commit -m "update"''', shell=True)
child = pexpect.spawn('git push origin master')
child.expect('Username.+')
child.sendline('***n@mail.net')
child.expect('Password.+')
child.sendline('sdfsdfsdfsdfs')
result = str(child.before)
print(result)