Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch login failures with PySVN?

I'm new to Python and PySVN in general, and I'm trying to export my SVN repository using pysvn. Here's my code:

#set up svn login data  
def svn_credentials (realm, username, may_save):  
  return True, svn_login_name, svn_login_password, False

#establish connection  
svn_client = pysvn.Client ()  
svn_client.callback_get_login = svn_credentials

#export data  
svn_client.export('server-path-goes-here', 'client-path-goes-here', force=True)

Which works fine, but if the password is wrong or the user name is unknown, this code just sits. I believe it's being presented with a user login prompt on the SVN side, but I'm at a loss as to how to check what's happening with callback_get_login. Any help would be greatly appreciated.

like image 658
Geoff Avatar asked Apr 12 '10 20:04

Geoff


2 Answers

If the credentials are wrong pysvn will call the callback, if the credentials are still wrong it will call it again, and again, and it will just keep doing that until the credentials are correct.

For an automated script you are probably better off not setting the callback and instead setting the default username and password by calling set_default_username and set_default_password on the pysvn.Client instance.

With that setup incorrect credentials will result in pysvn propagating an exception suggesting that you set the callback which you can catch and turn into a meaningful error message.

like image 189
Gordon Wrigley Avatar answered Sep 22 '22 02:09

Gordon Wrigley


Are you using SSH? In which case, perhaps it's SSH presenting the login prompt and PySVN can't do much about that. You could try messing with the SSH configuration on the client side to disable keyboard interactive prompts:

http://www.ssh.com/support/documentation/online/ssh/adminguide/32/Configuring_the_Server_and_Client.html

like image 27
ars Avatar answered Sep 22 '22 02:09

ars