tplinkrouterc6u 5.9.4__py3-none-any.whl → 5.10.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- test/test_client_c6u.py +63 -0
- tplinkrouterc6u/client/c6u.py +13 -8
- tplinkrouterc6u/common/dataclass.py +30 -0
- {tplinkrouterc6u-5.9.4.dist-info → tplinkrouterc6u-5.10.1.dist-info}/METADATA +5 -1
- {tplinkrouterc6u-5.9.4.dist-info → tplinkrouterc6u-5.10.1.dist-info}/RECORD +8 -8
- {tplinkrouterc6u-5.9.4.dist-info → tplinkrouterc6u-5.10.1.dist-info}/WHEEL +0 -0
- {tplinkrouterc6u-5.9.4.dist-info → tplinkrouterc6u-5.10.1.dist-info}/licenses/LICENSE +0 -0
- {tplinkrouterc6u-5.9.4.dist-info → tplinkrouterc6u-5.10.1.dist-info}/top_level.txt +0 -0
test/test_client_c6u.py
CHANGED
|
@@ -769,6 +769,69 @@ class TestTPLinkClient(TestCase):
|
|
|
769
769
|
self.assertEqual(result.wan_ipv4_gateway, '0.0.0.0')
|
|
770
770
|
self.assertEqual(result.lan_macaddr, '06-E6-97-9E-23-F5')
|
|
771
771
|
|
|
772
|
+
def test_get_status_wifi_disabled(self) -> None:
|
|
773
|
+
"""Test that get_status gracefully handles when WiFi is disabled and wireless statistics fail."""
|
|
774
|
+
response_status = '''
|
|
775
|
+
{
|
|
776
|
+
"success": true,
|
|
777
|
+
"data": {
|
|
778
|
+
"lan_macaddr": "06:e6:97:9e:23:f5",
|
|
779
|
+
"wan_macaddr": "06:e6:97:9e:23:f6",
|
|
780
|
+
"wan_ipv4_ipaddr": "192.168.1.1",
|
|
781
|
+
"wan_ipv4_gateway": "192.168.1.254",
|
|
782
|
+
"lan_ipv4_ipaddr": "192.168.0.1",
|
|
783
|
+
"mem_usage": 0.43,
|
|
784
|
+
"cpu_usage": 0.28,
|
|
785
|
+
"conn_type": "1",
|
|
786
|
+
"access_devices_wired": [
|
|
787
|
+
{
|
|
788
|
+
"wire_type": "wired",
|
|
789
|
+
"macaddr": "3d:24:25:24:30:79",
|
|
790
|
+
"ipaddr": "192.168.1.228",
|
|
791
|
+
"hostname": "SERVER"
|
|
792
|
+
}
|
|
793
|
+
],
|
|
794
|
+
"access_devices_wireless_host": [],
|
|
795
|
+
"access_devices_wireless_guest": [],
|
|
796
|
+
"wireless_2g_enable": "off",
|
|
797
|
+
"wireless_5g_enable": "off",
|
|
798
|
+
"guest_2g_enable": "off",
|
|
799
|
+
"guest_5g_enable": "off"
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
'''
|
|
803
|
+
|
|
804
|
+
class TPLinkRouterTest(TplinkRouter):
|
|
805
|
+
def request(self, path: str, data: str,
|
|
806
|
+
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
807
|
+
if path == 'admin/status?form=all&operation=read':
|
|
808
|
+
return loads(response_status)['data']
|
|
809
|
+
elif path == 'admin/wireless?form=statistics':
|
|
810
|
+
# Simulate the error that occurs when WiFi is disabled
|
|
811
|
+
from tplinkrouterc6u.common.exception import ClientError
|
|
812
|
+
raise ClientError('TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0)')
|
|
813
|
+
raise ClientException()
|
|
814
|
+
|
|
815
|
+
client = TPLinkRouterTest('', '')
|
|
816
|
+
result = client.get_status()
|
|
817
|
+
|
|
818
|
+
# Should complete successfully without crashing
|
|
819
|
+
self.assertIsInstance(result, Status)
|
|
820
|
+
self.assertEqual(result.wan_macaddr, '06-E6-97-9E-23-F6')
|
|
821
|
+
self.assertEqual(result.lan_macaddr, '06-E6-97-9E-23-F5')
|
|
822
|
+
self.assertEqual(result.wan_ipv4_addr, '192.168.1.1')
|
|
823
|
+
self.assertEqual(result.wan_ipv4_gateway, '192.168.1.254')
|
|
824
|
+
self.assertEqual(result.lan_ipv4_addr, '192.168.0.1')
|
|
825
|
+
self.assertEqual(result.wired_total, 1)
|
|
826
|
+
self.assertEqual(result.wifi_clients_total, 0)
|
|
827
|
+
self.assertEqual(result.guest_clients_total, 0)
|
|
828
|
+
self.assertEqual(result.clients_total, 1)
|
|
829
|
+
self.assertEqual(result.wifi_2g_enable, False)
|
|
830
|
+
self.assertEqual(result.wifi_5g_enable, False)
|
|
831
|
+
# Devices list should only contain wired devices
|
|
832
|
+
self.assertEqual(len(result.devices), 1)
|
|
833
|
+
self.assertEqual(result.devices[0].type, Connection.WIRED)
|
|
834
|
+
|
|
772
835
|
def test_vpn_status(self) -> None:
|
|
773
836
|
response_openvpn_read = """
|
|
774
837
|
{
|
tplinkrouterc6u/client/c6u.py
CHANGED
|
@@ -360,14 +360,19 @@ class TplinkBaseRouter(AbstractRouter, TplinkRequest):
|
|
|
360
360
|
devices[item['mac']].up_speed = item.get('uploadSpeed')
|
|
361
361
|
devices[item['mac']].signal = int(item.get('signal')) if item.get('signal') else None
|
|
362
362
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
363
|
+
try:
|
|
364
|
+
wireless_stats = self.request('admin/wireless?form=statistics', 'operation=load')
|
|
365
|
+
for item in wireless_stats:
|
|
366
|
+
if item['mac'] not in devices:
|
|
367
|
+
status.wifi_clients_total += 1
|
|
368
|
+
type = self._map_wire_type(item.get('type'))
|
|
369
|
+
devices[item['mac']] = Device(type, EUI48(item['mac']), IPv4Address('0.0.0.0'),
|
|
370
|
+
'')
|
|
371
|
+
devices[item['mac']].packets_sent = item.get('txpkts')
|
|
372
|
+
devices[item['mac']].packets_received = item.get('rxpkts')
|
|
373
|
+
except Exception:
|
|
374
|
+
# WiFi might be disabled on the router, skip wireless statistics
|
|
375
|
+
pass
|
|
371
376
|
|
|
372
377
|
status.devices = list(devices.values())
|
|
373
378
|
status.clients_total = status.wired_total + status.wifi_clients_total + status.guest_clients_total
|
|
@@ -274,6 +274,36 @@ class LTEStatus:
|
|
|
274
274
|
rsrq: int | None = None
|
|
275
275
|
snr: int | None = None
|
|
276
276
|
isp_name: str | None = None
|
|
277
|
+
network_types = {
|
|
278
|
+
0: "No Service",
|
|
279
|
+
1: "GSM",
|
|
280
|
+
2: "WCDMA",
|
|
281
|
+
3: "4G LTE",
|
|
282
|
+
4: "TD-SCDMA",
|
|
283
|
+
5: "CDMA 1x",
|
|
284
|
+
6: "CDMA 1x Ev-Do",
|
|
285
|
+
7: "4G+ LTE"
|
|
286
|
+
}
|
|
287
|
+
sim_statuses = {
|
|
288
|
+
0: "No SIM card detected or SIM card error.",
|
|
289
|
+
1: "No SIM card detected.",
|
|
290
|
+
2: "SIM card error.",
|
|
291
|
+
3: "SIM card prepared.",
|
|
292
|
+
4: "SIM locked.",
|
|
293
|
+
5: "SIM unlocked. Authentication succeeded.",
|
|
294
|
+
6: "PIN locked.",
|
|
295
|
+
7: "SIM card is locked permanently.",
|
|
296
|
+
8: "suspension of transmission",
|
|
297
|
+
9: "Unopened"
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@property
|
|
301
|
+
def network_type_info(self) -> str:
|
|
302
|
+
return self.network_types.get(self.network_type, "Unknown network type")
|
|
303
|
+
|
|
304
|
+
@property
|
|
305
|
+
def sim_status_info(self) -> str:
|
|
306
|
+
return self.sim_statuses.get(self.sim_status, "Unknown SIM status")
|
|
277
307
|
|
|
278
308
|
|
|
279
309
|
@dataclass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tplinkrouterc6u
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.10.1
|
|
4
4
|
Summary: TP-Link Router API (supports also Mercusys Router)
|
|
5
5
|
Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
|
|
6
6
|
Author: Alex Erohin
|
|
@@ -258,7 +258,9 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
258
258
|
| enable | is enabled | int |
|
|
259
259
|
| connect_status | connect status | int |
|
|
260
260
|
| network_type | network type | int |
|
|
261
|
+
| network_type_info | Example: 4G LTE | str |
|
|
261
262
|
| sim_status | sim status | int |
|
|
263
|
+
| sim_status_info | Example: SIM locked. | str |
|
|
262
264
|
| total_statistics | total statistics in bytes | int |
|
|
263
265
|
| cur_rx_speed | current download speed in bytes per second | int |
|
|
264
266
|
| cur_tx_speed | current upload speed in bytes per second | int |
|
|
@@ -268,6 +270,8 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
268
270
|
| rsrq | RSRQ | int |
|
|
269
271
|
| snr | SNR | int |
|
|
270
272
|
| isp_name | ISP name | str |
|
|
273
|
+
| network_types | All possible network types - {0: "No Service", 1: "GSM", 2: "WCDMA", 3: "4G LTE", 4: "TD-SCDMA", 5: "CDMA 1x", 6: "CDMA 1x Ev-Do", 7: "4G+ LTE"} | dict |
|
|
274
|
+
| sim_statuses | All possible sim statuses - {0: "No SIM card detected or SIM card error.", 1: "No SIM card detected.", 2: "SIM card error.", 3: "SIM card prepared.", 4: "SIM locked.", 5: "SIM unlocked. Authentication succeeded.", 6: "PIN locked.", 7: "SIM card is locked permanently.", 8: "suspension of transmission", 9: "Unopened"} | dict |
|
|
271
275
|
|
|
272
276
|
## Enum
|
|
273
277
|
### <a id="connection">Connection</a>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
test/__init__.py,sha256=McQmUjeN3AwmwdS6QNfwGXXE77OKoPK852I2BM9XsrU,210
|
|
2
2
|
test/test_client_c1200.py,sha256=Sl-85JGqINNg-ckBZCIVqY0CC-V1UOc-yiIUljtePRM,7582
|
|
3
|
-
test/test_client_c6u.py,sha256=
|
|
3
|
+
test/test_client_c6u.py,sha256=j9IpkZaWAedqkSktIGhjK8YZMhCkQhHnhqAmAWzEAYc,40399
|
|
4
4
|
test/test_client_c80.py,sha256=RY_1SgRVcQQdN9h0_IXA0YW4_0flEB_uel05QvDDfws,42359
|
|
5
5
|
test/test_client_deco.py,sha256=YPLKRD8GoyDYHfRgdXvCk8iVNw8zdMJW-AHVnNbpdTM,31719
|
|
6
6
|
test/test_client_ex.py,sha256=Kg6svEKtyGAfyF9yrLh2qZa2tK1mlEBJJwXRsq1MAjo,26591
|
|
@@ -13,7 +13,7 @@ tplinkrouterc6u/provider.py,sha256=bzH0WW2peC66f8NqfiI3t_niX6MFO8SAdKP9WZL-IV4,2
|
|
|
13
13
|
tplinkrouterc6u/client/__init__.py,sha256=KBy3fmtA9wgyFrb0Urh2x4CkKtWVnESdp-vxmuOvq0k,27
|
|
14
14
|
tplinkrouterc6u/client/c1200.py,sha256=4XEYidEGmVIJk0YQLvmTnd0Gqa7glH2gUWvjreHpWrk,3178
|
|
15
15
|
tplinkrouterc6u/client/c5400x.py,sha256=9E0omBSbWY_ljrs5MTCMu5brmrLtzsDB5O62Db8lP8Q,4329
|
|
16
|
-
tplinkrouterc6u/client/c6u.py,sha256=
|
|
16
|
+
tplinkrouterc6u/client/c6u.py,sha256=n4OMAxg0NXChYaVpWCvx3ZFUxVfynTMy-pyd1CTj9s4,19694
|
|
17
17
|
tplinkrouterc6u/client/c80.py,sha256=ArVhza_fnXcEO-_fsQOd1l2QvmSfsswtohKxrZxEnoU,18568
|
|
18
18
|
tplinkrouterc6u/client/deco.py,sha256=cpKRggKD2RvSmMZuD6tzsZmehAUCU9oLiTTHcZBW81Y,8898
|
|
19
19
|
tplinkrouterc6u/client/ex.py,sha256=gXWsVKAMo4CsX_Qeihb2iCARcsA3E9m2vgIWiJB3sjs,13197
|
|
@@ -22,13 +22,13 @@ tplinkrouterc6u/client/vr.py,sha256=7Tbu0IrWtr4HHtyrnLFXEJi1QctzhilciL7agtwQ0R8,
|
|
|
22
22
|
tplinkrouterc6u/client/wdr.py,sha256=i54PEifjhfOScDpgNBXygw9U4bfsVtle846_YjnDoBs,21679
|
|
23
23
|
tplinkrouterc6u/client/xdr.py,sha256=QaZ_5vCaf8BV_JEs3S2Nz-QDREBYHGh3OUWIVS-fefY,10406
|
|
24
24
|
tplinkrouterc6u/common/__init__.py,sha256=pCTvVZ9CAwgb7MxRnLx0y1rI0sTKSwT24FfxWfQXeTM,33
|
|
25
|
-
tplinkrouterc6u/common/dataclass.py,sha256=
|
|
25
|
+
tplinkrouterc6u/common/dataclass.py,sha256=mIQFJoDmKZccV5M3NjguIGm7N9ROEt71Weg0ExYWrEQ,7709
|
|
26
26
|
tplinkrouterc6u/common/encryption.py,sha256=4HelTxzN6esMfDZRBt3m8bwB9Nj_biKijnCnrGWPWKg,6228
|
|
27
27
|
tplinkrouterc6u/common/exception.py,sha256=_0G8ZvW5__CsGifHrsZeULdl8c6EUD071sDCQsQgrHY,140
|
|
28
28
|
tplinkrouterc6u/common/helper.py,sha256=23b04fk9HuVinrZXMCS5R1rmF8uZ7eM-Cdnp7Br9NR0,572
|
|
29
29
|
tplinkrouterc6u/common/package_enum.py,sha256=4ykL_2Pw0nDEIH_qR9UJlFF6stTgSfhPz32r8KT-sh8,1624
|
|
30
|
-
tplinkrouterc6u-5.
|
|
31
|
-
tplinkrouterc6u-5.
|
|
32
|
-
tplinkrouterc6u-5.
|
|
33
|
-
tplinkrouterc6u-5.
|
|
34
|
-
tplinkrouterc6u-5.
|
|
30
|
+
tplinkrouterc6u-5.10.1.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
|
|
31
|
+
tplinkrouterc6u-5.10.1.dist-info/METADATA,sha256=oiaqPd4N9hGpncj_Zm7WWQNi7w3orZbIRuTOqrEYhBE,16373
|
|
32
|
+
tplinkrouterc6u-5.10.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
33
|
+
tplinkrouterc6u-5.10.1.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
|
|
34
|
+
tplinkrouterc6u-5.10.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|