def __attrs_post_init__(self): # HTTP session-related settings self.user_agent = ( "Exoscale-Python/{python_exoscale_version} " "cs/{cs_version} " "{requests_user_agent} " "{python_implementation}/{python_version} " "{os_name}/{os_version}").format( python_exoscale_version=pkg_resources.get_distribution( "exoscale").version, cs_version=pkg_resources.get_distribution("cs").version, requests_user_agent=requests_user_agent(), python_implementation=platform.python_implementation(), python_version=platform.python_version(), os_name=platform.system(), os_version=platform.release(), ) adapter = HTTPAdapter(max_retries=Retry( total=self.max_retries, backoff_factor=self.retry_backoff_factor, status_forcelist=None, )) self.session.mount("http://", adapter=adapter) self.session.mount("https://", adapter=adapter)
def default_user_agent(base=None): """Create the default User-Agent string for the python-replicated client. Parameters ---------- base : str The User-Agent string to extend. The default is the ``python-requests`` User-Agent. """ if base is None: base = requests_user_agent() return 'python-replicated/{0} {1}'.format(__version__, base)
def usagi_user_agent(): return 'usagi/{0} haas/{1} {2}'.format( usagi.__version__, haas.__version__, requests_user_agent())