def _request(method, url, session=None, **kwargs):
url = BASE_URL + url<EOL>if session:<EOL><INDENT>request_func = getattr(session, method)<EOL><DEDENT>else:<EOL><INDENT>request_func = getattr(requests, method)<EOL><DEDENT>response = request_func(url, **kwargs)<EOL>if not response.status_code == requests.codes.ok:<EOL><INDENT>raise DweepyError('<STR_LIT>'.format(response.status_code))<EOL><DEDENT>response_json = response.json()<EOL>if response_json['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>raise DweepyError(response_json['<STR_LIT>'])<EOL><DEDENT>return response_json['<STR_LIT>']<EOL>
Make HTTP request, raising an exception if it fails.