Python requests_toolbelt.user_agent() Examples
The following are 7
code examples of requests_toolbelt.user_agent().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
requests_toolbelt
, or try the search function
.
Example #1
Source File: __init__.py From controller with MIT License | 7 votes |
def get_session(k8s_api_verify_tls): global session if session is None: with open('/var/run/secrets/kubernetes.io/serviceaccount/token') as token_file: token = token_file.read() session = requests.Session() session.headers = { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'User-Agent': user_agent('Deis Controller', deis_version) } if k8s_api_verify_tls: session.verify = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt' else: session.verify = False return session
Example #2
Source File: __init__.py From controller with MIT License | 6 votes |
def get_session(k8s_api_verify_tls): global session if session is None: with open('/var/run/secrets/kubernetes.io/serviceaccount/token') as token_file: token = token_file.read() session = requests.Session() session.headers = { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json', 'User-Agent': user_agent('Deis Controller', deis_version) } if k8s_api_verify_tls: session.verify = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt' else: session.verify = False return session
Example #3
Source File: __init__.py From controller with MIT License | 5 votes |
def get_session(): global session if session is None: session = requests.Session() session.headers = { # https://toolbelt.readthedocs.org/en/latest/user-agent.html#user-agent-constructor 'User-Agent': user_agent('Deis Controller', deis_version), } # `mount` a custom adapter that retries failed connections for HTTP and HTTPS requests. # http://docs.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter session.mount('http://', requests.adapters.HTTPAdapter(max_retries=10)) session.mount('https://', requests.adapters.HTTPAdapter(max_retries=10)) return session
Example #4
Source File: uploader.py From poetry with MIT License | 5 votes |
def user_agent(self): return user_agent("poetry", __version__)
Example #5
Source File: uploader.py From poetry with MIT License | 5 votes |
def make_session(self): session = requests.session() if self.is_authenticated(): session.auth = (self._username, self._password) session.headers["User-Agent"] = self.user_agent for scheme in ("http://", "https://"): session.mount(scheme, self.adapter) return session
Example #6
Source File: __init__.py From controller with MIT License | 5 votes |
def get_session(): global session if session is None: session = requests.Session() session.headers = { # https://toolbelt.readthedocs.org/en/latest/user-agent.html#user-agent-constructor 'User-Agent': user_agent('Deis Controller', deis_version), } # `mount` a custom adapter that retries failed connections for HTTP and HTTPS requests. # http://docs.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter session.mount('http://', requests.adapters.HTTPAdapter(max_retries=10)) session.mount('https://', requests.adapters.HTTPAdapter(max_retries=10)) return session
Example #7
Source File: Options.py From WSPIH with MIT License | 5 votes |
def __init__(self): """Constructs an OptionsIdentity instance.""" self.auth = None self.cookies = requests.cookies.RequestsCookieJar() self.headers = requests.utils.default_headers() self.headers.update({"User-Agent": user_agent(PackageHelper.get_alias(), PackageHelper.get_version())}) self.proxies = None