mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-14 18:44:27 +05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad1210d5cc | ||
|
|
687e80f729 |
@@ -157,11 +157,10 @@ class MegaD:
|
|||||||
if force_d is not None:
|
if force_d is not None:
|
||||||
self.customize[CONF_FORCE_D] = force_d
|
self.customize[CONF_FORCE_D] = force_d
|
||||||
try:
|
try:
|
||||||
if allow_hosts is not None:
|
if allow_hosts is not None and DOMAIN in hass.data:
|
||||||
allow_hosts = set(allow_hosts.split(';'))
|
allow_hosts = set(allow_hosts.split(';'))
|
||||||
hass.data[DOMAIN][CONF_HTTP].allowed_hosts |= allow_hosts
|
hass.data[DOMAIN][CONF_HTTP].allowed_hosts |= allow_hosts
|
||||||
hass.data[DOMAIN][CONF_HTTP].protected = protected
|
hass.data[DOMAIN][CONF_HTTP].protected = protected
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.lg.exception('while setting allowed hosts')
|
self.lg.exception('while setting allowed hosts')
|
||||||
|
|
||||||
@@ -290,6 +289,8 @@ class MegaD:
|
|||||||
url = f"{url}/?{cmd}"
|
url = f"{url}/?{cmd}"
|
||||||
self.lg.debug('request: %s', url)
|
self.lg.debug('request: %s', url)
|
||||||
async with self._http_lck(priority):
|
async with self._http_lck(priority):
|
||||||
|
for _ntry in range(3):
|
||||||
|
try:
|
||||||
async with aiohttp.request("get", url=url) as req:
|
async with aiohttp.request("get", url=url) as req:
|
||||||
if req.status != 200:
|
if req.status != 200:
|
||||||
self.lg.warning('%s returned %s (%s)', url, req.status, await req.text())
|
self.lg.warning('%s returned %s (%s)', url, req.status, await req.text())
|
||||||
@@ -298,6 +299,10 @@ class MegaD:
|
|||||||
ret = await req.text()
|
ret = await req.text()
|
||||||
self.lg.debug('response %s', ret)
|
self.lg.debug('response %s', ret)
|
||||||
return ret
|
return ret
|
||||||
|
except asyncio.TimeoutError:
|
||||||
|
self.lg.warning(f'timeout while requesting {url}')
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
raise asyncio.TimeoutError('after 3 tries')
|
||||||
|
|
||||||
async def save(self):
|
async def save(self):
|
||||||
await self.send_command(cmd='s')
|
await self.send_command(cmd='s')
|
||||||
|
|||||||
Reference in New Issue
Block a user