pyGuardPoint 2.1.0__tar.gz → 2.1.1__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.
Files changed (68) hide show
  1. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/PKG-INFO +1 -1
  2. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/guardpoint_connection_asyncio.py +56 -40
  3. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/guardpoint_connection.py +2 -2
  4. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/guardpoint_dataclasses.py +10 -8
  5. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint.egg-info/PKG-INFO +1 -1
  6. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/setup.py +1 -1
  7. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/LICENSE.txt +0 -0
  8. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/README.rst +0 -0
  9. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/CustomWebsocketTransport.py +0 -0
  10. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/CustomWebsocketTransportOld.py +0 -0
  11. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/__init__.py +0 -0
  12. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_accessgroups.py +0 -0
  13. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_alarmstates.py +0 -0
  14. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_alarmzones.py +0 -0
  15. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_areas.py +0 -0
  16. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_cardholders.py +0 -0
  17. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_cardholdertypes.py +0 -0
  18. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_cards.py +0 -0
  19. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_controllers.py +0 -0
  20. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_customizedfields.py +0 -0
  21. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_departments.py +0 -0
  22. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_diagnostic.py +0 -0
  23. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_events.py +0 -0
  24. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_genericinformation.py +0 -0
  25. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_inputs.py +0 -0
  26. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_manualevents.py +0 -0
  27. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_ouputs.py +0 -0
  28. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_personaldetails.py +0 -0
  29. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_readers.py +0 -0
  30. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_scheduledmags.py +0 -0
  31. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_securitygroups.py +0 -0
  32. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_sites.py +0 -0
  33. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_guardpoint_weeklyprograms.py +0 -0
  34. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_odata_filter.py +0 -0
  35. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/_str_match_algo.py +0 -0
  36. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/__init__.py +0 -0
  37. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_accessgroups.py +0 -0
  38. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_alarmstates.py +0 -0
  39. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_alarmzones.py +0 -0
  40. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_areas.py +0 -0
  41. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_cardholders.py +0 -0
  42. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_cardholdertypes.py +0 -0
  43. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_cards.py +0 -0
  44. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_controllers.py +0 -0
  45. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_customizedfields.py +0 -0
  46. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_departments.py +0 -0
  47. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_diagnostic.py +0 -0
  48. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_events.py +0 -0
  49. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_genericinformation.py +0 -0
  50. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_manualevents.py +0 -0
  51. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_ouputs.py +0 -0
  52. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_personaldetails.py +0 -0
  53. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_readers.py +0 -0
  54. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_scheduledmags.py +0 -0
  55. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_securitygroups.py +0 -0
  56. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_sites.py +0 -0
  57. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/gp_asyncio/_async_guardpoint_weeklyprograms.py +0 -0
  58. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/guardpoint.py +0 -0
  59. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/guardpoint_asyncio.py +0 -0
  60. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/guardpoint_error.py +0 -0
  61. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/guardpoint_threaded.py +0 -0
  62. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint/guardpoint_utils.py +0 -0
  63. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint.egg-info/SOURCES.txt +0 -0
  64. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint.egg-info/dependency_links.txt +0 -0
  65. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint.egg-info/not-zip-safe +0 -0
  66. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint.egg-info/requires.txt +0 -0
  67. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/pyGuardPoint.egg-info/top_level.txt +0 -0
  68. {pyguardpoint-2.1.0 → pyguardpoint-2.1.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyGuardPoint
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: Python wrapper for GuardPoint 10 Access Control System
5
5
  Author: John Owen
6
6
  Maintainer-email: sales@sensoraccess.co.uk
@@ -172,11 +172,11 @@ class GuardPointConnection:
172
172
  if code != 200:
173
173
  return code, auth_body
174
174
  if self.auto_renew:
175
- if self.token_expiry < (time.time() - (20 * 60)): # If Token will expire within 20 minutes
175
+ if self.token_expiry < (time.time() + (20 * 60)) and self.token_expiry > time.time():
176
176
  code, auth_body = await self._renew_token()
177
177
  if code != 200:
178
178
  return code, auth_body
179
- if self.token_expiry < time.time():
179
+ elif self.token_expiry < time.time():
180
180
  code, auth_body = await self._new_token()
181
181
  if code != 200:
182
182
  return code, auth_body
@@ -220,54 +220,70 @@ class GuardPointConnection:
220
220
  json_body = None
221
221
  except InvalidURL as e:
222
222
  log.error(str(e))
223
- return
223
+ return 400, {"error": str(e)}
224
224
  except Exception as e:
225
225
  log.error(str(e))
226
- return
226
+ return 500, {"error": str(e)}
227
227
 
228
228
  elif method.lower() == "post":
229
- async with self.session.post(url, data=raw_body, headers=headers) as response:
230
- body = await response.text()
231
- try:
232
- json_body = json.loads(body)
233
- except JSONDecodeError:
234
- json_body = None
235
- except Exception as e:
236
- log.error(e)
237
- json_body = None
229
+ try:
230
+ async with self.session.post(url, data=raw_body, headers=headers) as response:
231
+ body = await response.text()
232
+ try:
233
+ json_body = json.loads(body)
234
+ except JSONDecodeError:
235
+ json_body = None
236
+ except Exception as e:
237
+ log.error(e)
238
+ json_body = None
239
+ except Exception as e:
240
+ log.error(str(e))
241
+ return 500, {"error": str(e)}
238
242
 
239
243
  elif method.lower() == "patch":
240
- async with self.session.patch(url, data=raw_body, headers=headers) as response:
241
- body = await response.text()
242
- try:
243
- json_body = json.loads(body)
244
- except JSONDecodeError:
245
- json_body = None
246
- except Exception as e:
247
- log.error(e)
248
- json_body = None
244
+ try:
245
+ async with self.session.patch(url, data=raw_body, headers=headers) as response:
246
+ body = await response.text()
247
+ try:
248
+ json_body = json.loads(body)
249
+ except JSONDecodeError:
250
+ json_body = None
251
+ except Exception as e:
252
+ log.error(e)
253
+ json_body = None
254
+ except Exception as e:
255
+ log.error(str(e))
256
+ return 500, {"error": str(e)}
249
257
 
250
258
  elif method.lower() == "delete":
251
- async with self.session.delete(url, data=raw_body, headers=headers) as response:
252
- body = await response.text()
253
- try:
254
- json_body = json.loads(body)
255
- except JSONDecodeError:
256
- json_body = None
257
- except Exception as e:
258
- log.error(e)
259
- json_body = None
259
+ try:
260
+ async with self.session.delete(url, data=raw_body, headers=headers) as response:
261
+ body = await response.text()
262
+ try:
263
+ json_body = json.loads(body)
264
+ except JSONDecodeError:
265
+ json_body = None
266
+ except Exception as e:
267
+ log.error(e)
268
+ json_body = None
269
+ except Exception as e:
270
+ log.error(str(e))
271
+ return 500, {"error": str(e)}
260
272
 
261
273
  elif method.lower() == "put":
262
- async with self.session.put(url, data=raw_body, headers=headers) as response:
263
- body = await response.text()
264
- try:
265
- json_body = json.loads(body)
266
- except JSONDecodeError:
267
- json_body = None
268
- except Exception as e:
269
- log.error(e)
270
- json_body = None
274
+ try:
275
+ async with self.session.put(url, data=raw_body, headers=headers) as response:
276
+ body = await response.text()
277
+ try:
278
+ json_body = json.loads(body)
279
+ except JSONDecodeError:
280
+ json_body = None
281
+ except Exception as e:
282
+ log.error(e)
283
+ json_body = None
284
+ except Exception as e:
285
+ log.error(str(e))
286
+ return 500, {"error": str(e)}
271
287
 
272
288
  else:
273
289
  raise ValueError("Method Not Supported")
@@ -185,11 +185,11 @@ class GuardPointConnection:
185
185
  if code != 200:
186
186
  return code, auth_body
187
187
  if self.auto_renew:
188
- if self.token_expiry < (time.time() - (20 * 60)): # If Token will expire within 20 minutes
188
+ if self.token_expiry < (time.time() + (20 * 60)) and self.token_expiry > time.time():
189
189
  code, auth_body = self._renew_token()
190
190
  if code != 200:
191
191
  return code, auth_body
192
- if self.token_expiry < time.time():
192
+ elif self.token_expiry < time.time():
193
193
  code, auth_body = self._new_token()
194
194
  if code != 200:
195
195
  return code, auth_body
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ import threading
2
3
  from collections import defaultdict
3
4
  from dataclasses import dataclass, asdict, field
4
5
  from enum import Enum
@@ -18,20 +19,21 @@ class EventOrder(Enum):
18
19
 
19
20
 
20
21
  class Observable:
21
- # A set of all attributes which get changed
22
- changed_attributes = set()
23
-
24
22
  def __init__(self):
25
- self.observed = defaultdict(list)
23
+ super().__setattr__('changed_attributes', set())
24
+ super().__setattr__('observed', defaultdict(list))
25
+ super().__setattr__('_observer_lock', threading.RLock())
26
26
 
27
27
  def __setattr__(self, name, value):
28
28
  super().__setattr__(name, value)
29
29
 
30
- for observer in self.observed.get(name, []):
31
- observer(name)
30
+ with self._observer_lock:
31
+ for observer in self.observed.get(name, []):
32
+ observer(name)
32
33
 
33
34
  def add_observer(self, name):
34
- self.observed[name].append(lambda name: self.changed_attributes.add(name))
35
+ with self._observer_lock:
36
+ self.observed[name].append(lambda name: self.changed_attributes.add(name))
35
37
 
36
38
 
37
39
  def sanitise_args(obj: Observable, args, kwargs):
@@ -1219,7 +1221,7 @@ class Cardholder(Observable):
1219
1221
  try:
1220
1222
  if isinstance(getattr(self, property_name), str):
1221
1223
  value = str(value)
1222
- except:
1224
+ except AttributeError:
1223
1225
  pass
1224
1226
 
1225
1227
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyGuardPoint
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: Python wrapper for GuardPoint 10 Access Control System
5
5
  Author: John Owen
6
6
  Maintainer-email: sales@sensoraccess.co.uk
@@ -5,7 +5,7 @@ long_description = open('README.rst').read()
5
5
  setup(name="pyGuardPoint",
6
6
  python_requires='>3.9.0',
7
7
  packages=find_packages(),
8
- version="2.1.0",
8
+ version="2.1.1",
9
9
  author="John Owen",
10
10
  description="Python wrapper for GuardPoint 10 Access Control System",
11
11
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes