libsolace.util module¶
-
libsolace.util.
httpRequest
(url, fields=None, headers=None, method='GET', timeout=3, protocol='http', verifySsl=False, **kwargs)[source]¶ Performs HTTP request
Parameters: - url (str) – URL accessed
- kwargs (dict) –
Returns: Tuple containing data, headers and responsecode
Return type: tuple
>>> l = httpRequest('http://www.google.se', method='GET') >>> type(l) <type 'tuple'>
-
libsolace.util.
generateBasicAuthHeader
(username, password)[source]¶ Generates a basic auth header
Parameters: - username (str) – Username of user
- password (str) – Password of user
Returns: Dict containing basic auth header
Return type: dict
>>> generateBasicAuthHeader('test','test') {'Authorization': 'Basic dGVzdDp0ZXN0'}
-
libsolace.util.
generateRequestHeaders
(**kwargs)[source]¶ Generates a dict of headers
Parameters: kwargs (dict) – Dict of headers Returns: Dict containing headers Return type: dict >>> generateRequestHeaders(someheaders={'header1':'value1'}) {'header1': 'value1', 'User-agent': 'libsolace/doctest'}
-
libsolace.util.
version_equal_or_greater_than
(left, right)[source]¶ Checks if right is equals or greater than left
Parameters: - left (str) – soltr_version string
- right (str) – soltr_version string
Returns: result of comparison
Return type: bool
>>> version_equal_or_greater_than('soltr/6_0', 'soltr/6_2') True
-
libsolace.util.
get_key_from_kwargs
(key, kwargs, default=None)[source]¶ Returns a key from kwargs or raises exception is no key is present
Example:
>>> get_key_from_kwargs("vpn_name", kwargs) 'dev_testvpn'
>>> get_key_from_kwargs("missing_key", other_dict, default=True) True
>>> get_key_from_kwargs("missin_key", kwargs) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/keghol/Development/libsolace/libsolace/util.py", line 303, in get_key_from_kwargs raise(MissingProperty(key)) libsolace.Exceptions.MissingProperty: missing_key
-
libsolace.util.
get_key_from_settings
(key, kwargs, default=None)[source]¶ Same as above, but different error message