Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _check_key_and_version():
params = {'text': PyGraphistry.api_key()}
try:
response = requests.get(PyGraphistry._check_url(), params=params, timeout=(3,3),
verify=PyGraphistry._config['certificate_validation'])
response.raise_for_status()
jres = response.json()
cver = sys.modules['graphistry'].__version__
if 'pygraphistry' in jres and 'minVersion' in jres['pygraphistry'] and 'latestVersion' in jres['pygraphistry']:
mver = jres['pygraphistry']['minVersion']
lver = jres['pygraphistry']['latestVersion']
if util.compare_versions(mver, cver) > 0:
util.warn('Your version of PyGraphistry is no longer supported (installed=%s latest=%s). Please upgrade!' % (cver, lver))
elif util.compare_versions(lver, cver) > 0:
print('A new version of PyGraphistry is available (installed=%s latest=%s).' % (cver, lver))
if jres['success'] is not True:
**Example: Developer**
::
import graphistry
graphistry.register('my api key', server='staging', protocol='https')
**Example: Through environment variable**
::
export GRAPHISTRY_API_KEY = 'my api key'
::
import graphistry
graphistry.register()
"""
PyGraphistry.api_key(key)
PyGraphistry.server(server)
PyGraphistry.api_version(api)
PyGraphistry.protocol(protocol)
PyGraphistry.certificate_validation(certificate_validation)
PyGraphistry.authenticate()
PyGraphistry.set_bolt_driver(bolt)
def authenticate():
"""Authenticate via already provided configuration.
This is called once automatically per session when uploading and rendering a visualization."""
key = PyGraphistry.api_key()
#Mocks may set to True, so bypass in that case
if (key is None) and PyGraphistry._is_authenticated == False:
util.error('API key not set explicitly in `register()` or available at ' + EnvVarNames['api_key'])
if not PyGraphistry._is_authenticated:
PyGraphistry._check_key_and_version()
PyGraphistry._is_authenticated = True