mirror of
https://github.com/miaowware/qrm2.git
synced 2025-02-03 09:44:07 -05:00
Merge pull request #143 from classabbyamp/5c-fixclose
Fix unclosed files (BytesIO)
This commit is contained in:
commit
70505f10f6
@ -40,7 +40,8 @@ class QRZCog(commands.Cog):
|
|||||||
async with self.session.get(url) as resp:
|
async with self.session.get(url) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
||||||
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
with BytesIO(await resp.read()) as resp_file:
|
||||||
|
resp_xml = etree.parse(resp_file).getroot()
|
||||||
|
|
||||||
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
||||||
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
||||||
@ -97,7 +98,8 @@ async def qrz_login(user: str, passwd: str, session: aiohttp.ClientSession):
|
|||||||
async with session.get(url) as resp:
|
async with session.get(url) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
||||||
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
with BytesIO(await resp.read()) as resp_file:
|
||||||
|
resp_xml = etree.parse(resp_file).getroot()
|
||||||
|
|
||||||
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
||||||
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
||||||
@ -113,7 +115,8 @@ async def qrz_test_session(key: str, session: aiohttp.ClientSession):
|
|||||||
async with session.get(url) as resp:
|
async with session.get(url) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
raise ConnectionError(f'Unable to connect to QRZ (HTTP Error {resp.status})')
|
||||||
resp_xml = etree.parse(BytesIO(await resp.read())).getroot()
|
with BytesIO(await resp.read()) as resp_file:
|
||||||
|
resp_xml = etree.parse(resp_file).getroot()
|
||||||
|
|
||||||
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
resp_xml_session = resp_xml.xpath('/x:QRZDatabase/x:Session', namespaces={'x': 'http://xmldata.qrz.com'})
|
||||||
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
resp_session = {el.tag.split('}')[1]: el.text for el in resp_xml_session[0].getiterator()}
|
||||||
|
Loading…
Reference in New Issue
Block a user