Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)

        def request(url, method, body=None, username=None, password=None):
    headers={'Content-Type': 'application/xml',
             "Accept": 'application/xml'}
    if username:
        headers["Authorization"] = 'Basic %s' % base64.encodestring("%s:%s" % (username, password))[:-1]

    req = urllib2.Request(url=url, data=body, headers=headers)
    return urllib2.urlopen(req)
        


src/g/i/git-crucible-0.1.2/crucible/client.py   git-crucible(Download)
import xml.etree.ElementTree as ElementTree
from xml.sax.saxutils import escape
from crucible.rest import request
import urllib2
 
 
        try:
            resp = request(url, method='POST', body=body,
                       username=self.username,
                       password=self.password)

src/g/i/git-crucible-HEAD/crucible/client.py   git-crucible(Download)
import xml.etree.ElementTree as ElementTree
from xml.sax.saxutils import escape
from crucible.rest import request
import urllib2
 
 
        try:
            resp = request(url, method='POST', body=body,
                       username=self.username,
                       password=self.password)

src/g/i/git-crucible-0.1.2/crucible/tests/test_rest.py   git-crucible(Download)
                 "Authorization": "Basic amltOmJvYg==",
               }
        rest.request("http://localhost/", "POST", "body", username="jim", password="bob")
        urllib2_mock.Request.assert_called_once_with(url="http://localhost/", data="body", headers=headers)
 

src/g/i/git-crucible-HEAD/crucible/tests/test_rest.py   git-crucible(Download)
                 "Authorization": "Basic amltOmJvYg==",
               }
        rest.request("http://localhost/", "POST", "body", username="jim", password="bob")
        urllib2_mock.Request.assert_called_once_with(url="http://localhost/", data="body", headers=headers)