Hello all,

So I'm setting up a script that runs when CVS wants to connect to an ext type 
server by setting CVS_RSH to my script so I can log in with a password. IE 
CVS_RSH=/etc/projects/blah.py. Which runs when I type say "cvs -d:ext:[EMAIL 
PROTECTED]:/cvsroot co module". I need this because of the way cruise control 
works and the fact that the cvs server the projects are hosted on are password 
protected. I cannot install keys nor can I create a passwordless user or any 
thing other than commit and checkout.

So I know my script needs to wrap SSH and when cvs calls it, it runs "blah.py 
-l user host 'cvs server'" and then pipes stdio to pass commands to 'cvs 
server'. I can log in and I can send and receive commands through stdio which I 
am passing through an ugly bit of code like the following, but with some 
select.select() statements so it doesn't block:

###
child = pexpect.spawn(cmd...., maxread=1)
...
while (1):
  input = child.readline()
  sys.stdout.write(input)
  if (ouput == 'ok\r\n'):
    break

  output = sys.stdin.readline()
  sys.stderr.write("Sending to child: "+output)
  child.send(output)
####

Also a separate test file test.txt
###
Root /cvsroot
history
###

Basically, I can call the script alone like "cat text.txt | ./blah.py -l user 
host 'cvs server'" and it works as expected. But when CVS calls it through "cvs 
history" using the CVS_RSH variable it just hangs right after the child gets, 
or doesn't get, the "Root /cvsroot" request. All that gets output is some 
debugging and hangs right after I see "Sending to child: Root /cvsroot".

I know it's authenticating, I know cvs server starts on the server and I can 
pipe commands to it as a standalone script, I just don't know what is different 
when CVS calls blah.py as opposed to me calling it. I'm also wondering if 
there's an easier way to do this somehow, I have played with os.dup2() and 
child.interact() to no avail.

Thanks, Ben Snider.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to