Python 德威治远程回购认证
有没有通过HTTPS访问和获取远程存储库的好例子?我有一个Git存储库,我可以用我的用户名和密码从命令行克隆它,但我希望能够使用Dulwich做到这一点,并且在创建HTTPS客户端时只提供我的用户名和密码Python 德威治远程回购认证,python,git,authentication,dulwich,Python,Git,Authentication,Dulwich,有没有通过HTTPS访问和获取远程存储库的好例子?我有一个Git存储库,我可以用我的用户名和密码从命令行克隆它,但我希望能够使用Dulwich做到这一点,并且在创建HTTPS客户端时只提供我的用户名和密码 另一个要求是使用MemoryReporto选项而不是写入文件系统。Dulwich 0.16.0及更高版本支持URL中的用户名/密码 在旧版本中,可以通过指定自定义HTTP处理程序来执行此操作: import urllib2 password_mgr = urllib2.HTT
另一个要求是使用MemoryReporto选项而不是写入文件系统。Dulwich 0.16.0及更高版本支持URL中的用户名/密码 在旧版本中,可以通过指定自定义HTTP处理程序来执行此操作:
import urllib2
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
# Add the username and password.
password_mgr.add_password(realm, top_level_url, username, password)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener([handler])
client, path = get_transport_and_path(remote_location)
client.opener = opener
remote_refs = client.fetch(path, target_repo)