本文整理汇总了Python中subvertpy.ra.get_username_provider函数的典型用法代码示例。如果您正苦于以下问题:Python get_username_provider函数的具体用法?Python get_username_provider怎么用?Python get_username_provider使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_username_provider函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_diff
def test_diff(self):
r = ra.RemoteAccess(self.repos_url,
auth=ra.Auth([ra.get_username_provider()]))
dc = self.get_commit_editor(self.repos_url)
f = dc.add_file("foo")
f.modify("foo1")
dc.close()
dc = self.get_commit_editor(self.repos_url)
f = dc.open_file("foo")
f.modify("foo2")
dc.close()
if client.api_version() < (1, 5):
self.assertRaises(NotImplementedError, self.client.diff, 1, 2,
self.repos_url, self.repos_url)
return # Skip test
(outf, errf) = self.client.diff(1, 2, self.repos_url, self.repos_url)
self.addCleanup(outf.close)
self.addCleanup(errf.close)
self.assertEqual("""Index: foo
===================================================================
--- foo\t(revision 1)
+++ foo\t(revision 2)
@@ -1 +1 @@
-foo1
\\ No newline at end of file
+foo2
\\ No newline at end of file
""", outf.read())
self.assertEqual("", errf.read())
开发者ID:lygstate,项目名称:subvertpy,代码行数:32,代码来源:test_client.py
示例2: __init__
def __init__(self, config_dir, repopath, username=None, password=None):
super(Client, self).__init__(config_dir, repopath, username, password)
self.repopath = B(self.repopath)
self.config_dir = B(config_dir)
self._ssl_trust_prompt_cb = None
auth_providers = [
ra.get_simple_provider(),
ra.get_username_provider(),
]
if repopath.startswith('https:'):
auth_providers += [
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
ra.get_ssl_server_trust_prompt_provider(self.ssl_trust_prompt),
]
self.auth = ra.Auth(auth_providers)
if username:
self.auth.set_parameter(B('svn:auth:username'), B(username))
if password:
self.auth.set_parameter(B('svn:auth:password'), B(password))
cfg = get_config(self.config_dir)
self.client = SVNClient(cfg, auth=self.auth)
开发者ID:PingAnTech,项目名称:reviewboard,代码行数:30,代码来源:subvertpy.py
示例3: accept_ssl_certificate
def accept_ssl_certificate(self, path, on_failure=None):
"""If the repository uses SSL, this method is used to determine whether
the SSL certificate can be automatically accepted.
If the cert cannot be accepted, the ``on_failure`` callback
is executed.
``on_failure`` signature::
void on_failure(e:Exception, path:str, cert:dict)
"""
self._accept_cert = {}
self._accept_on_failure = on_failure
auth = ra.Auth([
ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_server_trust_prompt_provider(self._accept_trust_prompt),
])
cfg = get_config(self.config_dir)
client = SVNClient(cfg, auth)
try:
info = client.info(path)
logging.debug('SVN: Got repository information for %s: %s' %
(path, info))
except SubversionException as e:
if on_failure:
on_failure(e, path, self._accept_cert)
开发者ID:karthikkn,项目名称:reviewboard,代码行数:28,代码来源:subvertpy.py
示例4: _init_client
def _init_client(self):
self.client_ctx = client.Client()
self.client_ctx.auth = Auth([ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider()])
self.client_ctx.log_msg_func = self.log_message_func
开发者ID:KyleJ61782,项目名称:subvertpy,代码行数:8,代码来源:__init__.py
示例5: accept_ssl_certificate
def accept_ssl_certificate(self, path, on_failure=None):
"""If the repository uses SSL, this method is used to determine whether
the SSL certificate can be automatically accepted.
If the cert cannot be accepted, the ``on_failure`` callback
is executed.
``on_failure`` signature::
void on_failure(e:Exception, path:str, cert:dict)
"""
cert = {}
def _accept_trust_prompt(realm, failures, certinfo, may_save):
cert.update({
'realm': realm,
'failures': failures,
'hostname': certinfo[0],
'finger_print': certinfo[1],
'valid_from': certinfo[2],
'valid_until': certinfo[3],
'issuer_dname': certinfo[4],
})
if on_failure:
return 0, False
else:
del cert['failures']
return failures, True
auth = ra.Auth([
ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
ra.get_ssl_server_trust_prompt_provider(_accept_trust_prompt),
])
if self.username:
auth.set_parameter(AUTH_PARAM_DEFAULT_USERNAME, B(self.username))
if self.password:
auth.set_parameter(AUTH_PARAM_DEFAULT_PASSWORD, B(self.password))
cfg = get_config(self.config_dir)
client = SVNClient(cfg, auth)
try:
info = client.info(path)
logging.debug('SVN: Got repository information for %s: %s' %
(path, info))
except SubversionException as e:
if on_failure:
on_failure(e, path, cert)
return cert
开发者ID:chipx86,项目名称:reviewboard,代码行数:57,代码来源:subvertpy.py
示例6: test_commit_start
def test_commit_start(self):
self.build_tree({"dc/foo": None})
self.client = client.Client(auth=ra.Auth([ra.get_username_provider()]),
log_msg_func=lambda c: "Bmessage")
self.client.add("dc/foo")
self.client.commit(["dc"])
r = ra.RemoteAccess(self.repos_url)
revprops = r.rev_proplist(1)
self.assertEqual("Bmessage", revprops["svn:log"])
开发者ID:lygstate,项目名称:subvertpy,代码行数:9,代码来源:test_client.py
示例7: get_commit_editor
def get_commit_editor(self, url, message="Test commit"):
"""Obtain a commit editor.
:param url: URL to connect to
:param message: Commit message
:return: Commit editor object
"""
ra_ctx = RemoteAccess(url.encode("utf-8"), auth=Auth([ra.get_username_provider()]))
revnum = ra_ctx.get_latest_revnum()
return TestCommitEditor(ra_ctx.get_commit_editor({"svn:log": message}), ra_ctx.url, revnum)
开发者ID:vadmium,项目名称:subvertpy,代码行数:10,代码来源:__init__.py
示例8: client_set_revprop
def client_set_revprop(self, url, revnum, name, value):
"""Set a revision property on a repository.
:param url: URL of the repository
:param revnum: Revision number of the revision
:param name: Name of the property
:param value: Value of the property, None to remove
"""
r = ra.RemoteAccess(url, auth=Auth([ra.get_username_provider()]))
r.change_rev_prop(revnum, name, value)
开发者ID:KyleJ61782,项目名称:subvertpy,代码行数:10,代码来源:__init__.py
示例9: accept_ssl_certificate
def accept_ssl_certificate(self, path, on_failure=None):
"""If the repository uses SSL, this method is used to determine whether
the SSL certificate can be automatically accepted.
If the cert cannot be accepted, the ``on_failure`` callback
is executed.
``on_failure`` signature::
void on_failure(e:Exception, path:str, cert:dict)
"""
cert = {}
def _accept_trust_prompt(realm, failures, certinfo, may_save):
cert.update(
{
"realm": realm,
"failures": failures,
"hostname": certinfo[0],
"finger_print": certinfo[1],
"valid_from": certinfo[2],
"valid_until": certinfo[3],
"issuer_dname": certinfo[4],
}
)
if on_failure:
return 0, False
else:
del cert["failures"]
return failures, True
auth = ra.Auth(
[
ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
ra.get_ssl_server_trust_prompt_provider(_accept_trust_prompt),
]
)
cfg = get_config(self.config_dir)
client = SVNClient(cfg, auth)
try:
info = client.info(path)
logging.debug("SVN: Got repository information for %s: %s" % (path, info))
except SubversionException as e:
if on_failure:
on_failure(e, path, cert)
return cert
开发者ID:hcchen,项目名称:reviewboard,代码行数:53,代码来源:subvertpy.py
示例10: __init__
def __init__(self, config_dir, repopath, username=None, password=None):
super(Client, self).__init__(config_dir, repopath, username, password)
self.repopath = B(self.repopath)
self.config_dir = B(config_dir)
auth_providers = [ra.get_simple_provider(), ra.get_username_provider()]
if repopath.startswith("https:"):
auth_providers.append(ra.get_ssl_server_trust_prompt_provider(self.ssl_trust_prompt))
self.auth = ra.Auth(auth_providers)
if username:
self.auth.set_parameter(B("svn:auth:username"), B(username))
if password:
self.auth.set_parameter(B("svn:auth:password"), B(password))
cfg = get_config(self.config_dir)
self.client = SVNClient(cfg, auth=self.auth)
开发者ID:javins,项目名称:reviewboard,代码行数:14,代码来源:subvertpy.py
示例11: svn_remote
def svn_remote(url):
# note: client only works for local path
# create an auth with stock svn providers
auth = ra.Auth([
ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
])
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_USERNAME,
settings.SVN_USERNAME)
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_PASSWORD,
settings.SVN_PASSWORD)
return ra.RemoteAccess(url, auth=auth)
开发者ID:emory-libraries,项目名称:findingaids,代码行数:17,代码来源:svn.py
示例12: init_ra_and_client
def init_ra_and_client(self):
"""
Initializes the RA and client layers.
With the SWIG bindings, getting unified diffs runs the remote server
sometimes runs out of open files. It is not known whether the Subvertpy
is affected by this.
"""
def getclientstring():
return 'hgsubversion'
# TODO: handle certificate authentication, Mercurial style
def getpass(realm, username, may_save):
return self.username or username, self.password or '', False
def getuser(realm, may_save):
return self.username or '', False
providers = ra.get_platform_specific_client_providers()
providers += [
ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
ra.get_username_prompt_provider(getuser, 0),
ra.get_simple_prompt_provider(getpass, 0),
]
auth = ra.Auth(providers)
if self.username:
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_USERNAME, self.username)
if self.password:
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_PASSWORD, self.password)
self.remote = ra.RemoteAccess(url=self.svn_url,
client_string_func=getclientstring,
auth=auth)
self.client = client.Client()
self.client.auth = auth
开发者ID:avuori,项目名称:dotfiles,代码行数:39,代码来源:subvertpy_wrapper.py
示例13: __init__
def __init__(self, config_dir, repopath, username=None, password=None):
super(Client, self).__init__(config_dir, repopath, username, password)
self.repopath = B(self.repopath)
self.config_dir = B(config_dir)
self._ssl_trust_prompt_cb = None
auth_providers = [
ra.get_simple_provider(),
ra.get_username_provider(),
]
if repopath.startswith('https:'):
auth_providers += [
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
ra.get_ssl_server_trust_prompt_provider(self.ssl_trust_prompt),
]
self.auth = ra.Auth(auth_providers)
self.username = None
self.password = None
if username:
self.username = username
self.auth.set_parameter(AUTH_PARAM_DEFAULT_USERNAME,
B(self.username))
if password:
self.password = password
self.auth.set_parameter(AUTH_PARAM_DEFAULT_PASSWORD,
B(self.password))
cfg = get_config(self.config_dir)
self.client = SVNClient(cfg, auth=self.auth)
开发者ID:chipx86,项目名称:reviewboard,代码行数:36,代码来源:subvertpy.py
示例14: calculate_hot_spots
def calculate_hot_spots(jiraKey,repoUrl,end_time = time.time(),cache_update_time = time.time()):
providers = ra.get_platform_specific_client_providers()
providers += [
ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
ra.get_username_prompt_provider(getuser, 0),
ra.get_simple_prompt_provider(getpass, 0),
]
auth=ra.Auth(providers)
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_USERNAME, settings.username)
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_PASSWORD, settings.password)
conn = ra.RemoteAccess(repoUrl,auth=auth)
global bugCache
global svnCache
if jiraKey in bugCache:
bugs = bugCache[jiraKey]
else:
bugs = []
if jiraKey in svnCache:
svn_entries = svnCache[jiraKey]
else:
svn_entries = []
start_time = end_time
scores = {}
authors = {}
modified_files = []
if (len(bugs) == 0 and len(svn_entries) == 0) or time.time() > cache_update_time:
#retrieve the SVN log entries
for (changed_paths, rev, revprops, has_children) in conn.iter_log(paths=None,start=0, end=conn.get_latest_revnum(), discover_changed_paths=True):
svn_entries.append((changed_paths, rev, revprops, has_children))
#query jira for all the closed bugs
bugs = get_bugs(jiraKey)
#add to the cache dictionary
bugCache[jiraKey] = bugs
svnCache[jiraKey] = svn_entries
for (changed_paths, rev, revprops, has_children) in svn_entries:
commit_time = time.mktime(dateutil.parser.parse(revprops["svn:date"]).timetuple())
if commit_time <= end_time:
#this svn commit contains code that fixed a bug
if fixed_bug(revprops["svn:log"].decode('utf8') ,bugs):
#only consider *.java and *.js files for now
modified_files.extend([(commit_time,filename,revprops["svn:author"]) for filename in changed_paths.keys() if is_source_file(filename)])
if commit_time < start_time:
start_time = commit_time
for modified_file in modified_files:
filename = modified_file[1]
author = modified_file[2]
#as per Google's description, normalize t between 0 and 1
t = (modified_file[0]-start_time)/(end_time-start_time)
#google's magic sauce
score = 1/(1+(math.e**(-12*t+12)))
#map the score to the file
if filename not in scores:
scores[filename] = score
else:
scores[filename] = scores[filename] + score
#map the author(s) to the file
if filename not in authors:
authors[filename] = [author]
else:
authors[filename].append(author)
#convert the list of authors to a map containing the counts
for filename,authorsList in authors.items():
authors[filename]=Counter(authorsList)
sorted_scores = sorted(scores.iteritems(), key=operator.itemgetter(1))
sorted_scores.reverse()
#add the author count to the scores tuple
scoresWithAuthors =[]
for score in sorted_scores:
scoresWithAuthors.append((score[0],score[1],authors[score[0]]))
#return the top 10 hotspots
return scoresWithAuthors[:10]
开发者ID:nstehr,项目名称:Hotspot-Dashboard,代码行数:90,代码来源:bug_predictor.py
示例15: setUp
def setUp(self):
super(TestRemoteAccess, self).setUp()
self.repos_url = self.make_repository("d")
self.ra = ra.RemoteAccess(self.repos_url,
auth=ra.Auth([ra.get_username_provider()]))
开发者ID:scm-tools,项目名称:subvertpy,代码行数:5,代码来源:test_ra.py
示例16: RemoteAccess
#!/usr/bin/python
# Demonstrates how to use the replay function to fetch the
# changes made in a revision.
from subvertpy.ra import RemoteAccess, Auth, get_username_provider
conn = RemoteAccess("svn://svn.gnome.org/svn/gnome-specimen/trunk",
auth=Auth([get_username_provider()]))
class MyFileEditor:
def change_prop(self, key, value):
print("Change prop: %s -> %r" % (key, value))
def apply_textdelta(self, base_checksum):
# This should return a function that can receive delta windows
def apply_window(x):
pass
return apply_window
def close(self):
pass
class MyDirEditor:
def open_directory(self, *args):
print("Open dir: %s (base revnum: %r)" % args)
return MyDirEditor()
开发者ID:ardumont,项目名称:subvertpy,代码行数:30,代码来源:ra_replay.py
示例17: RemoteAccess
#!/usr/bin/python3
# Demonstrates how to do a new commit using Subvertpy
import os
from io import BytesIO
from subvertpy import delta, repos
from subvertpy.ra import RemoteAccess, Auth, get_username_provider
# Create a repository
repos.create("tmprepo")
# Connect to the "remote" repository using the file transport.
# Note that a username provider needs to be provided, so that Subversion
# knows who to record as the author of new commits made over this connection.
repo_url = "file://%s" % os.path.abspath("tmprepo")
conn = RemoteAccess(repo_url, auth=Auth([get_username_provider()]))
# Simple commit that adds a directory
editor = conn.get_commit_editor({"svn:log": "Commit message"})
root = editor.open_root()
# Add a directory
dir = root.add_directory("somedir")
dir.close()
# Add and edit a file
file = root.add_file("somefile")
# Set the svn:executable attribute
file.change_prop("svn:executable", "*")
# Obtain a textdelta handler and send the new file contents
txdelta = file.apply_textdelta()
delta.send_stream(BytesIO(b"new file contents"), txdelta)
file.close()
开发者ID:vadmium,项目名称:subvertpy,代码行数:31,代码来源:ra_commit.py
示例18: setUp
def setUp(self):
super(TestClient, self).setUp()
self.repos_url = self.make_client("d", "dc")
self.client = client.Client(auth=ra.Auth([ra.get_username_provider()]))
开发者ID:lygstate,项目名称:subvertpy,代码行数:5,代码来源:test_client.py
示例19:
#!/usr/bin/python3
# Demonstrates how to do access the working tree using subvertpy
import os
from subvertpy import client, repos, wc
from subvertpy.ra import Auth, get_username_provider
# Create a repository
repos.create("tmprepo")
c = client.Client(auth=Auth([get_username_provider()]))
c.checkout("file://" + os.getcwd() + "/tmprepo", "tmpco", "HEAD")
w = wc.WorkingCopy(None, "tmpco")
print(w)
entry = w.entry("tmpco")
print(entry.revision)
print(entry.url)
开发者ID:vadmium,项目名称:subvertpy,代码行数:18,代码来源:wc.py
示例20: init_ra_and_client
def init_ra_and_client(self):
"""
Initializes the RA and client layers.
With the SWIG bindings, getting unified diffs runs the remote server
sometimes runs out of open files. It is not known whether the Subvertpy
is affected by this.
"""
def getclientstring():
return 'hgsubversion'
def simple(realm, username, may_save):
return _prompt.simple(realm, username, may_save)
def username(realm, may_save):
return _prompt.username(realm, may_save)
def ssl_client_cert(realm, may_save):
return _prompt.ssl_client_cert(realm, may_save)
def ssl_client_cert_pw(realm, may_save):
return _prompt.ssl_client_cert_pw(realm, may_save)
def ssl_server_trust(realm, failures, cert_info, may_save):
creds = _prompt.ssl_server_trust(realm, failures, cert_info, may_save)
if creds is None:
# We need to reject the certificate, but subvertpy doesn't
# handle None as a return value here, and requires
# we instead return a tuple of (int, bool). Because of that,
# we return (0, False) instead.
creds = (0, False)
return creds
providers = ra.get_platform_specific_client_providers()
providers += [
ra.get_simple_provider(),
ra.get_username_provider(),
ra.get_ssl_client_cert_file_provider(),
ra.get_ssl_client_cert_pw_file_provider(),
ra.get_ssl_server_trust_file_provider(),
]
if _prompt:
providers += [
ra.get_simple_prompt_provider(simple, 2),
ra.get_username_prompt_provider(username, 2),
ra.get_ssl_client_cert_prompt_provider(ssl_client_cert, 2),
ra.get_ssl_client_cert_pw_prompt_provider(ssl_client_cert_pw, 2),
ra.get_ssl_server_trust_prompt_provider(ssl_server_trust),
]
auth = ra.Auth(providers)
if self.username:
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_USERNAME, self.username)
if self.password:
auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_PASSWORD, self.password)
try:
self.remote = ra.RemoteAccess(url=self.svn_url,
client_string_func=getclientstring,
auth=auth)
except SubversionException, e:
# e.child contains a detailed error messages
msglist = []
svn_exc = e
while svn_exc:
if svn_exc.args[0]:
msglist.append(svn_exc.args[0])
svn_exc = svn_exc.child
msg = '\n'.join(msglist)
raise common.SubversionConnectionException(msg)
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:70,代码来源:subvertpy_wrapper.py
注:本文中的subvertpy.ra.get_username_provider函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论