def __open(self, url, headers=None, data=None, baseurl="<STR_LIT>"):
headers = headers or {}<EOL>if not baseurl:<EOL><INDENT>baseurl = self.baseurl<EOL><DEDENT>req = Request("<STR_LIT>" % (baseurl, url), headers=headers)<EOL>_LOGGER.debug(url)<EOL>try:<EOL><INDENT>req.data = urlencode(data).encode('<STR_LIT:utf-8>')<EOL><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>opener = build_opener()<EOL>try:<EOL><INDENT>resp = opener.open(req)<EOL>charset = resp.info().get('<STR_LIT>', '<STR_LIT:utf-8>')<EOL>data = json.loads(resp.read().decode(charset))<EOL>opener.close()<EOL>_LOGGER.debug(json.dumps(data))<EOL>return data<EOL><DEDENT>except HTTPError as exception_:<EOL><INDENT>if exception_.code == <NUM_LIT>:<EOL><INDENT>_LOGGER.debug("<STR_LIT:%s>", exception_)<EOL>return False<EOL><DEDENT>raise TeslaException(exception_.code)<EOL><DEDENT>
Use raw urlopen command.