2016-11-23 15 views
-3

我能够使用“pysvn”模块编写脚本来检出SVN问题的代码,但只是想知道是否有任何我没有pysvn吗?因为pysvn是我必须单独安装在Linux和Windows上的第三方库,而这两者都是我不想要的。请帮我在我没有安装任何第三方模块代码另一种方式 -如何提供用户名和密码,同时使用python脚本从SVN检出代码而无需第三方模块

import pysvn,os,shutil 


def getLogin(realm, username, may_save): 
    svn_user = '<my-username>' 
    svn_pass = '<my-password>' 
    return True, svn_user, svn_pass, False 

def ssl_server_trust_prompt(trust_dict): 
    return (True # server is trusted 
      ,trust_dict["failures"] 
      ,True) # save the answer so that the callback is not called again 

def checkOut(svn_url,dest_dir): 
    if os.path.isdir(dest_dir): 
     shutil.rmtree(dest_dir) 
     os.mkdir(dest_dir) 
     client = pysvn.Client() 
    client.callback_ssl_server_trust_prompt = ssl_server_trust_prompt 
     client.callback_get_login = getLogin 
     client.checkout(svn_url,dest_dir) 
    else: 
     os.mkdir(dest_dir) 
     client = pysvn.Client() 
    client.callback_ssl_server_trust_prompt = ssl_server_trust_prompt 
     client.callback_get_login = getLogin 
     client.checkout(svn_url,dest_dir) 


print "Checking out the code hang on...\n" 
checkOut('<svn-repo>','ABC') 
print "checked out the code \n" 

print "Checking out the code hang on...\n" 
checkOut('<svn-repo>','XYZ') 
print "checked out the code\n" 

print "Checking out the code hang on...\n" 
checkOut('<svn-repo>','MNP') 
print "checked out the code \n” 
+2

份额片段。 – ArunDhaJ

+0

其中一个我试过像这样import os os.system('svn co https:// svn-path')。在这里它总是弹出密码窗口。我在ubuntu上运行这个 – user2564083

+0

其他我以同样的方式尝试子进程。请帮助 – user2564083

回答

0

我能够使用“pysvn”模块来解决这个问题,但只是想知道有没有什么办法,我没有pysvn也可以吗?因为pysvn是我必须单独安装在Linux和Windows上的第三方库,而这两者都是我不想要的。请帮我在我没有安装任何第三方模块代码另一种方式 -

import pysvn,os,shutil 


def getLogin(realm, username, may_save): 
    svn_user = '<my-username>' 
    svn_pass = '<my-password>' 
    return True, svn_user, svn_pass, False 

def ssl_server_trust_prompt(trust_dict): 
    return (True # server is trusted 
      ,trust_dict["failures"] 
      ,True) # save the answer so that the callback is not called again 

def checkOut(svn_url,dest_dir): 
    if os.path.isdir(dest_dir): 
     shutil.rmtree(dest_dir) 
     os.mkdir(dest_dir) 
     client = pysvn.Client() 
    client.callback_ssl_server_trust_prompt = ssl_server_trust_prompt 
     client.callback_get_login = getLogin 
     client.checkout(svn_url,dest_dir) 
    else: 
     os.mkdir(dest_dir) 
     client = pysvn.Client() 
    client.callback_ssl_server_trust_prompt = ssl_server_trust_prompt 
     client.callback_get_login = getLogin 
     client.checkout(svn_url,dest_dir) 


print "Checking out the code hang on...\n" 
checkOut('<svn-repo>','ABC') 
print "checked out the code \n" 

print "Checking out the code hang on...\n" 
checkOut('<svn-repo>','XYZ') 
print "checked out the code\n" 

print "Checking out the code hang on...\n" 
checkOut('<svn-repo>','MNP') 
print "checked out the code \n" 
0

你可以通过用户名和密码作为参数:你已经尝试过

$ svn update --username 'user2' --password 'password' 
+0

我已在代码中提供了足够的信息在描述部分。我请求你们请重新开放并帮我解决问题。 – user2564083

相关问题