Example #1
0
def passwordmgr(ui):
    try:
        realm = hgutil.urlreq.httppasswordmgrwithdefaultrealm()
        return url.passwordmgr(ui, realm)
    except (TypeError, AttributeError):
        # compat with hg < 3.9
        return url.passwordmgr(ui)
Example #2
0
 def _test(uri):
     print 'URI:', uri
     try:
         pm = url.passwordmgr(ui)
         print '    ', pm.find_user_password('test', uri)
     except Abort, e:
         print 'abort'
 def _test(uri):
     print 'URI:', uri
     try:
         pm = url.passwordmgr(ui)
         print '    ', pm.find_user_password('test', uri)
     except Abort, e:
         print 'abort'
Example #4
0
 def _test(uri):
     print 'URI:', uri
     try:
         pm = url.passwordmgr(ui)
         u, authinfo = util.url(uri).authinfo()
         if authinfo is not None:
             pm.add_password(*authinfo)
         print '    ', pm.find_user_password('test', u)
     except Abort:
         print 'abort'
Example #5
0
 def _test(uri):
     print('URI:', uri)
     try:
         pm = url.passwordmgr(ui, urlreq.httppasswordmgrwithdefaultrealm())
         u, authinfo = util.url(uri).authinfo()
         if authinfo is not None:
             pm.add_password(*authinfo)
         print('    ', pm.find_user_password('test', u))
     except error.Abort:
         print('    ', 'abort')
 def _test(uri):
     print 'URI:', uri
     try:
         pm = url.passwordmgr(ui)
         u, authinfo = util.url(uri).authinfo()
         if authinfo is not None:
             pm.add_password(*authinfo)
         print '    ', pm.find_user_password('test', u)
     except Abort:
         print 'abort'
Example #7
0
def _bb_apicall(ui, endpoint, data):
    uri = 'https://api.bitbucket.org/1.0/%s/' % endpoint
    # since bitbucket doesn't return the required WWW-Authenticate header when
    # making a request without Authorization, we cannot use the standard urllib2
    # auth handlers; we have to add the requisite header from the start
    req = urllib2.Request(uri, urllib.urlencode(data))
    # at least re-use Mercurial's password query
    passmgr = url.passwordmgr(ui)
    passmgr.add_password(None, uri, get_username(ui), '')
    upw = '%s:%s' % passmgr.find_user_password(None, uri)
    req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
    return urllib2.urlopen(req).read()
Example #8
0
def _bb_apicall(ui, endpoint, data, use_pass=True):
    uri = 'https://api.bitbucket.org/1.0/%s/' % endpoint
    # since bitbucket doesn't return the required WWW-Authenticate header when
    # making a request without Authorization, we cannot use the standard urllib2
    # auth handlers; we have to add the requisite header from the start
    if data is not None:
        data = urllib.urlencode(data)
    req = urllib2.Request(uri, data)
    #ui.status("Accessing %s" % uri)
    if use_pass:
        # at least re-use Mercurial's password query
        passmgr = url.passwordmgr(ui)
        passmgr.add_password(None, uri, get_username(ui), '')
        upw = '%s:%s' % passmgr.find_user_password(None, uri)
        req.add_header('Authorization',
                       'Basic %s' % base64.b64encode(upw).strip())
    return urllib2.urlopen(req).read()