Python-Unifi-Client 1.1.0__py3-none-any.whl → 1.1.2__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.
- {python-unifi-client → python_unifi_client}/client.py +12 -11
- {python_unifi_client-1.1.0.dist-info → python_unifi_client-1.1.2.dist-info}/METADATA +1 -1
- python_unifi_client-1.1.2.dist-info/RECORD +6 -0
- python_unifi_client-1.1.2.dist-info/top_level.txt +1 -0
- python_unifi_client-1.1.0.dist-info/RECORD +0 -6
- python_unifi_client-1.1.0.dist-info/top_level.txt +0 -1
- {python-unifi-client → python_unifi_client}/__init__.py +0 -0
- {python_unifi_client-1.1.0.dist-info → python_unifi_client-1.1.2.dist-info}/WHEEL +0 -0
|
@@ -109,6 +109,7 @@ class Client:
|
|
|
109
109
|
self._last_results_raw = None
|
|
110
110
|
self._cookies_created_at = 0
|
|
111
111
|
self._exec_retries = 0
|
|
112
|
+
self.debug = False
|
|
112
113
|
|
|
113
114
|
self._curl_headers = {
|
|
114
115
|
'Accept': 'application/json',
|
|
@@ -198,7 +199,7 @@ class Client:
|
|
|
198
199
|
except RequestException as e:
|
|
199
200
|
raise CurlGeneralErrorException(str(e), None, None)
|
|
200
201
|
|
|
201
|
-
if self.
|
|
202
|
+
if self.debug:
|
|
202
203
|
print("\n-----------LOGIN-------------")
|
|
203
204
|
print("GET Options:", get_options)
|
|
204
205
|
print("POST Options:", post_options)
|
|
@@ -259,7 +260,7 @@ class Client:
|
|
|
259
260
|
return self.fetch_results(f"/api/s/{self._site}/stat/sysinfo")
|
|
260
261
|
|
|
261
262
|
def get_clients(self):
|
|
262
|
-
return self.
|
|
263
|
+
return self.fetch_results(f"/api/s/{self._site}/stat/sta")
|
|
263
264
|
|
|
264
265
|
def block_client(self, mac):
|
|
265
266
|
return self._request(f"/api/s/{self._site}/cmd/stamgr", method='POST', payload={'cmd': 'block-sta', 'mac': mac})
|
|
@@ -751,7 +752,7 @@ class Client:
|
|
|
751
752
|
return self.fetch_results(f"/api/s/{self._site}/stat/device", login_required=True, prefix_path=True)
|
|
752
753
|
|
|
753
754
|
def get_device(self, device_id):
|
|
754
|
-
return self.
|
|
755
|
+
return self.fetch_results(f"/api/s/{self._site}/stat/device/{device_id}")
|
|
755
756
|
|
|
756
757
|
def get_wlan(self, wlan_id: str):
|
|
757
758
|
"""
|
|
@@ -928,7 +929,7 @@ class Client:
|
|
|
928
929
|
'include_traffic_usage': include_traffic_usage,
|
|
929
930
|
'include_unifi_devices': include_unifi_devices,
|
|
930
931
|
})
|
|
931
|
-
return self.fetch_results(f"/v2/api/site/{self._site}/clients/active?{query}")
|
|
932
|
+
return self.fetch_results(f"/v2/api/site/{self._site}/clients/active?{query}", prefix_path=True)
|
|
932
933
|
|
|
933
934
|
def list_clients_history(self, only_non_blocked: bool = True, include_unifi_devices: bool = True, within_hours: int = 0):
|
|
934
935
|
"""Fetch offline client device history."""
|
|
@@ -2330,7 +2331,7 @@ class Client:
|
|
|
2330
2331
|
if isinstance(self._last_results_raw, str):
|
|
2331
2332
|
try:
|
|
2332
2333
|
response = json.loads(self._last_results_raw)
|
|
2333
|
-
print("Fetched response:", response)
|
|
2334
|
+
print("Fetched response:", response) if self.debug else None
|
|
2334
2335
|
except:
|
|
2335
2336
|
self._get_json_last_error()
|
|
2336
2337
|
raise
|
|
@@ -2340,8 +2341,8 @@ class Client:
|
|
|
2340
2341
|
self._last_error_message = ''
|
|
2341
2342
|
if 'data' in response:
|
|
2342
2343
|
if isinstance(response['data'], list):
|
|
2343
|
-
print("Response inside fetch_results():", response)
|
|
2344
|
-
print("Data:", response.get("data"))
|
|
2344
|
+
print("Response inside fetch_results():", response) if self.debug else None
|
|
2345
|
+
print("Data:", response.get("data")) if self.debug else None
|
|
2345
2346
|
return response['data'] if not boolean else True
|
|
2346
2347
|
return [response['data']] if not boolean else True
|
|
2347
2348
|
return True
|
|
@@ -2471,7 +2472,7 @@ class Client:
|
|
|
2471
2472
|
|
|
2472
2473
|
# 9) handle expired auth
|
|
2473
2474
|
if http_code == 401:
|
|
2474
|
-
if self.
|
|
2475
|
+
if self.debug:
|
|
2475
2476
|
print(f"exec_curl: 401 on {url}, need to re-login")
|
|
2476
2477
|
if self._exec_retries == 0:
|
|
2477
2478
|
# clear stored cookie/token
|
|
@@ -2485,14 +2486,14 @@ class Client:
|
|
|
2485
2486
|
# attempt re-login
|
|
2486
2487
|
from time import sleep
|
|
2487
2488
|
if self.login():
|
|
2488
|
-
if self.
|
|
2489
|
+
if self.debug:
|
|
2489
2490
|
print("exec_curl: re-login succeeded, retrying exec_curl")
|
|
2490
2491
|
return self.exec_curl(path, payload, prefix_path)
|
|
2491
2492
|
raise LoginFailedException('Cookie/Token expired and re-login failed.')
|
|
2492
2493
|
raise LoginFailedException('Login failed, check credentials.')
|
|
2493
2494
|
|
|
2494
2495
|
# 10) debug dump
|
|
2495
|
-
if self.
|
|
2496
|
+
if self.debug:
|
|
2496
2497
|
print("\n---------cURL INFO-----------")
|
|
2497
2498
|
print("Options:", opts)
|
|
2498
2499
|
print("URL & PAYLOAD:", url)
|
|
@@ -2523,7 +2524,7 @@ class Client:
|
|
|
2523
2524
|
}
|
|
2524
2525
|
|
|
2525
2526
|
# Verbose logging if debug
|
|
2526
|
-
if self.
|
|
2527
|
+
if self.debug:
|
|
2527
2528
|
# shows per-request wire logs
|
|
2528
2529
|
logging.getLogger('urllib3').setLevel(logging.DEBUG)
|
|
2529
2530
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
python_unifi_client/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
2
|
+
python_unifi_client/client.py,sha256=Z5tGhaFfbSNNAjNFWsdB9EBxtgBeXz1nCPuIgGB1UIQ,105575
|
|
3
|
+
python_unifi_client-1.1.2.dist-info/METADATA,sha256=x_l71rj78UPrAZNjiWwPnxijSdIMuWZ7IPcYw5bMd_Y,2483
|
|
4
|
+
python_unifi_client-1.1.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
5
|
+
python_unifi_client-1.1.2.dist-info/top_level.txt,sha256=675fDdb69Hi9X8pSEGl6f03ZpUXNiumV-s1B1gXEeYs,20
|
|
6
|
+
python_unifi_client-1.1.2.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
python_unifi_client
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
python-unifi-client/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
2
|
-
python-unifi-client/client.py,sha256=3pNuIzpj_vJq1fWlhcN5LeD0qhSiGGSsvVd10TZzoUk,105467
|
|
3
|
-
python_unifi_client-1.1.0.dist-info/METADATA,sha256=tZJVMbCVB5Zkzx_CFN2N-dxafafeHNneNTAXmey2JGY,2483
|
|
4
|
-
python_unifi_client-1.1.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
5
|
-
python_unifi_client-1.1.0.dist-info/top_level.txt,sha256=FCrLtqZd79PRI6eCtX4XfFzdf9_oh-wGEXlkhYyHxMs,20
|
|
6
|
-
python_unifi_client-1.1.0.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
python-unifi-client
|
|
File without changes
|
|
File without changes
|