Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if kwargs.get('write_config_flag', True):
self.write_config()
except Exception:
self.read_config()
if self.config['insecure']:
requests.packages.urllib3.disable_warnings()
if self.config['debug']:
print(self.configfile)
self.token, self.csrf_token, self.cookie = self.get_auth_token()
try:
self.version_info = self._get_hub_rest_api_version_info()
except UnknownVersion:
self.version_info = {'version': '3'} # assume it's v3 since all versions after 3 supported version info
self.bd_major_version = self._get_major_version()
def _get_hub_rest_api_version_info(self):
'''Get the version info from the server, if available
'''
session = requests.session()
url = self.config['baseurl'] + "/api/current-version"
response = session.get(url, verify = not self.config['insecure'])
if response.status_code == 200:
version_info = response.json()
if 'version' in version_info:
return version_info
else:
raise UnknownVersion("Did not find the 'version' key in the response to a successful GET on /api/current-version")
else:
raise UnknownVersion("Failed to retrieve the version info from {}, status code {}".format(url, response.status_code))
def _get_hub_rest_api_version_info(self):
'''Get the version info from the server, if available
'''
session = requests.session()
url = self.config['baseurl'] + "/api/current-version"
response = session.get(url, verify = not self.config['insecure'])
if response.status_code == 200:
version_info = response.json()
if 'version' in version_info:
return version_info
else:
raise UnknownVersion("Did not find the 'version' key in the response to a successful GET on /api/current-version")
else:
raise UnknownVersion("Failed to retrieve the version info from {}, status code {}".format(url, response.status_code))
def _get_hub_rest_api_version_info(self):
'''Get the version info from the server, if available
'''
session = requests.session()
url = self.config['baseurl'] + "/api/current-version"
response = session.get(url, verify = not self.config['insecure'])
if response.status_code == 200:
version_info = response.json()
if 'version' in version_info:
return version_info
else:
raise UnknownVersion("Did not find the 'version' key in the response to a successful GET on /api/current-version")
else:
raise UnknownVersion("Failed to retrieve the version info from {}, status code {}".format(url, response.status_code))
def _get_hub_rest_api_version_info(self):
'''Get the version info from the server, if available
'''
session = requests.session()
url = self.config['baseurl'] + "/api/current-version"
response = session.get(url, verify = not self.config['insecure'])
if response.status_code == 200:
version_info = response.json()
if 'version' in version_info:
return version_info
else:
raise UnknownVersion("Did not find the 'version' key in the response to a successful GET on /api/current-version")
else:
raise UnknownVersion("Failed to retrieve the version info from {}, status code {}".format(url, response.status_code))