开发者

How to catch login failures with PySVN?

开发者 https://www.devze.com 2022-12-26 08:04 出处:网络
I\'m new to Python and PySVN in general, and I\'m trying to export my SVN repository using pysvn. Here\'s my code:

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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号