Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在没有第三方模块的情况下使用python脚本从SVN签出代码时提供用户名和密码_Python_Python 2.7_Python 3.x_Svn_Svn Checkout - Fatal编程技术网

如何在没有第三方模块的情况下使用python脚本从SVN签出代码时提供用户名和密码

如何在没有第三方模块的情况下使用python脚本从SVN签出代码时提供用户名和密码,python,python-2.7,python-3.x,svn,svn-checkout,Python,Python 2.7,Python 3.x,Svn,Svn Checkout,我能够使用“pysvn”模块编写一个脚本来检查SVN问题中的代码,但我只是想知道,没有pysvn,我还能做什么?因为pysvn是第三方库,我必须在linux和windows上分别安装,我不想安装。请帮助我获得无需安装任何第三方模块代码的替代方法- import pysvn,os,shutil def getLogin(realm, username, may_save): svn_user = '<my-username>' svn_pass = '<my-

我能够使用“pysvn”模块编写一个脚本来检查SVN问题中的代码,但我只是想知道,没有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”
导入pysvn、os、shutil
def getLogin(域、用户名、可保存):
svn_用户=“”
svn_通行证=“”
返回True、svn\u用户、svn\u传递、False
def ssl_服务器_信任_提示符(信任命令):
返回(True)#服务器受信任
,信任_dict[“失败”]
,True)#保存答案,以便不再调用回调
def签出(svn_url、目的地目录):
如果os.path.isdir(dest_dir):
shutil.rmtree(目的地目录)
os.mkdir(目的地目录)
client=pysvn.client()
client.callback\u ssl\u server\u trust\u prompt=ssl\u server\u trust\u prompt
client.callback\u get\u login=getLogin
client.checkout(svn\u url,dest\u dir)
其他:
os.mkdir(目的地目录)
client=pysvn.client()
client.callback\u ssl\u server\u trust\u prompt=ssl\u server\u trust\u prompt
client.callback\u get\u login=getLogin
client.checkout(svn\u url,dest\u dir)
打印“签出代码挂起…\n”
结帐(“”,'ABC')
打印“签出代码\n”
打印“签出代码挂起…\n”
签出(“”,'XYZ')
打印“签出代码\n”
打印“签出代码挂起…\n”
结帐(“”,'MNP')
打印“签出代码\n”

您可以将用户名和密码作为参数传递:

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

您可以将包含pysvn的ur脚本制作成可执行的二进制文件,这样就不需要导入或pip安装任何库,ur代码也可以在没有python的机器上运行

共享您尝试过的代码片段。我尝试过这样的导入os.system('svn co')。这里总是会弹出密码窗口。我正在ubuntuo上运行此操作,或者我以相同的方式尝试使用子流程。请帮助我在描述部分提供了足够信息的代码。我请求你们重新打开并帮助我解决此问题。