Repository navigation
Added exception handling the ex.py client as some routers return 406 on the Memory request - #85
FriedrichM wants to merge 4 commits into
Conversation
|
ive been able to recreate the 406 error code by running the readme script in quick succession / even in parallel. so it seems to be tied to that maybe something with logins or request ratelimiting |
|
Hi! |
|
|
||
| _, values = self.req_act(acts) | ||
|
|
||
| if not values or any(x is None for x in values[:-2]): |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
| free = int(values[4]["free"]) | ||
| status.mem_usage = ((total - free) / total) | ||
| try: | ||
| total = int(values[4]['total']) |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
| status.mem_usage = 0 | ||
|
|
||
| status.cpu_usage = int(values[5]['CPUUsage']) / 100 | ||
| try: |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
| attrs=['IPAddress', 'physAddress', 'hostName', 'leaseTimeRemaining']), | ||
| ] | ||
| _, values = self.req_act(acts) | ||
| if not values or values[0] is None: |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
| 'connIPv4DnsServer']), | ||
| ] | ||
| _, values = self.req_act(acts) | ||
| if not values or any(v is None for v in values): |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
| self.ActItem(self.ActItem.GL, 'DEV2_PVPN_CLIENT', attrs=['connAct']), | ||
| ] | ||
| _, values = self.req_act(acts) | ||
| if not values or any(v is None for v in values): |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
| _, values = self.req_act(acts) | ||
|
|
||
| if not values: | ||
| if not values or values[0] is None: |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
| self.ActItem(self.ActItem.GL, 'DEV2_DHCPV4_POOL_STATICADDR', attrs=['enable', 'chaddr', 'yiaddr']), | ||
| ] | ||
| _, values = self.req_act(acts) | ||
| if not values or values[0] is None: |
There was a problem hiding this comment.
Would be great if you could add test for this behavior
# Conflicts: # tplinkrouterc6u/client/mr.py
As described in AlexandrErohin/home-assistant-tplink-router#180 sometimes certain routers return 406 for the memory state request.
This is one way to handle those 406 responses feel free to give me feedback on this draft.
Do you want to handle it in another way ?