1

I would need little help here. I'm trying to get the git respository from my corporate server via ssh.

the command to run is git clone ssh://[email protected]/somefile.git/

I'm a newbie to python programming and looking out for some assistance.

def getRepository():
    command =  'ssh://[email protected]/somefile.git'
    clone_process = subprocess.Popen(['git','clone',command],stdin = subprocess.PIPE, stdout = subprocess.PIPE,stderr=subprocess.PIPE)
    output,error = clone_process.communicate(input='password') 


if  __name__ == '__main__':
    getRepository()

During this process, it prompts for user password which I thought communicate(input='password') would take care but it does not.

Actually it takes some time to prompt for password and I have to read that line before I give the password as input. How do I achieve this?

I tried writing the stdout in a file and read the file till I get that line but that too did not work..

Also, when I enter the password manually I don't see the progress of downloading on the terminal. is there a way to get that too?

2
  • pexpect module can help you Commented Jun 26, 2012 at 7:18
  • You could take a look at the mr.developer source code; that package manages git, hg, svn and bazaar checkouts from Python. At least the SVN plugin handles username and password prompting as well. Commented Jun 26, 2012 at 8:37

2 Answers 2

1

Use pexpect module to provide interactive inputs

See one of my previous example for the answer: Simplest way to run expect script from python

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Pyfunc.. I have used the pexpect module but stuck with an issue which i have put it on the following thread.. stackoverflow.com/questions/11208931/…
0

You can also use Paramiko module with a very nice API

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.