Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'User-Agent': user_agent
}
if config.has_option('Authentication', 'InstToken'):
token = config.get('Authentication', 'InstToken')
header.update({'X-ELS-APIKey': key, 'X-ELS-Insttoken': token})
# Perform request
params.update(**kwds)
# If config.ini has a section as follows:
#
# [Proxy]
# https = protocol://server:port
#
# it uses a proxy as defined
# see requests documentation for details
if config.has_section("Proxy"):
proxyDict = dict(config.items("Proxy"))
resp = requests.get(url, headers=header, proxies=proxyDict, params=params)
else:
resp = requests.get(url, headers=header, params=params)
# Handle error messages
if resp.ok:
return resp
else:
# Try raising ScopusError with supplied error message
# if no message given, do without supplied error message
# at least raise requests error
if resp.status_code in errors:
try:
reason = resp.json()['service-error']['status']['statusText']
except:
reason = ""
raise errors[resp.status_code](reason)