Python-Unifi-Client 1.1.0__tar.gz → 1.1.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_unifi_client
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Home-page: https://github.com/compdat-llc/unifi-client-python
5
5
  Author: Michael Lapinski
6
6
  Author-email: michaellapinski787@gmail.com
@@ -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.get_debug:
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._request(f"/api/s/{self._site}/stat/sta")
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._request(f"/api/s/{self._site}/stat/device/{device_id}")
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.get_debug:
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.get_debug:
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.get_debug:
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.get_debug:
2527
+ if self.debug:
2527
2528
  # shows per-request wire logs
2528
2529
  logging.getLogger('urllib3').setLevel(logging.DEBUG)
2529
2530
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_unifi_client
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Home-page: https://github.com/compdat-llc/unifi-client-python
5
5
  Author: Michael Lapinski
6
6
  Author-email: michaellapinski787@gmail.com
@@ -1,7 +1,7 @@
1
1
  README.md
2
2
  setup.py
3
- python-unifi-client/__init__.py
4
- python-unifi-client/client.py
3
+ python_unifi_client/__init__.py
4
+ python_unifi_client/client.py
5
5
  python_unifi_client.egg-info/PKG-INFO
6
6
  python_unifi_client.egg-info/SOURCES.txt
7
7
  python_unifi_client.egg-info/dependency_links.txt
@@ -0,0 +1 @@
1
+ python_unifi_client
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="python_unifi_client",
8
- version="1.1.0",
8
+ version="1.1.2",
9
9
  author="Michael Lapinski",
10
10
  author_email="michaellapinski787@gmail.com",
11
11
  descripton="A python version of a github Art-of-Wifi/Unifi-API-Client",
@@ -1 +0,0 @@
1
- python-unifi-client