Beispiel #1
0
 def __init__(self, access_key, username, api_url, timeout=30):
     self._access_key = access_key
     self._username = username
     self._api_url = api_url
     self._timeout = timeout
     self._user_info = get_user_info()
     self._session = requests.Session()
     self._session.proxies = getproxies()
     self._session.headers.update({
         'Authorization': self._access_key,
         'User-Agent': self._user_info
     })
     self._http_methods = {'GET', 'PUT', 'POST', 'DELETE'}
Beispiel #2
0
    def __init__(self, config, name=None):
        """
        Construct Brain object by passing in a Config object with an
        optional name argument.

        Arguments:
            config: A configuration used to connect to the BRAIN.
            name:   The name of the BRAIN to connect to.
        """
        self._config = config
        self._api = BrainAPI(config, config.network_timeout)
        self._timeout = self.config.network_timeout
        self.description = None
        self.name = name if name else self.config.brain
        self._status = None
        self._info = None
        self._state = None
        self._sims = None
        self.latest_version = None
        self._user_info = get_user_info()
        self.update()
Beispiel #3
0
 def _get_headers(self):
     return {
         'Authorization': self._auth_token,
         'User-Agent': get_user_info()
     }