CK-InoDrive-API 0.2.9__py3-none-any.whl → 1.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CK-InoDrive-API
3
- Version: 0.2.9
3
+ Version: 1.0.1
4
4
  Summary: InoDrive API Library
5
5
  Home-page: https://cardinalkinetic.com
6
6
  Author: Cardinal Kinetic
@@ -18,9 +18,9 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE.txt
20
20
  License-File: README.txt
21
- Requires-Dist: websocket-client ==1.6.4
21
+ Requires-Dist: websocket-client ==1.8.0
22
22
  Requires-Dist: ifaddr ==0.2.0
23
- Requires-Dist: msgpack ==1.0.7
23
+ Requires-Dist: msgpack ==1.1.0
24
24
 
25
25
  #### **Installation**
26
26
 
@@ -19,14 +19,14 @@ of the license associated with each component.
19
19
  SECTION 1: Apache License, V2.0
20
20
 
21
21
  >>> bleach-5.0.1
22
- >>> importlib-metadata-6.8.0
23
- >>> msgpack-1.0.7
24
- >>> readme-renderer-42.0
25
- >>> requests-2.31.0
22
+ >>> importlib-metadata-8.6.1
23
+ >>> msgpack-1.1.0
24
+ >>> readme-renderer-44.0
25
+ >>> requests-2.32.3
26
26
  >>> requests-toolbelt-1.0.0
27
27
  >>> rfc3986-2.0.0
28
- >>> twine-4.0.2
29
- >>> websocket-client-1.6.4
28
+ >>> twine-5.1.1
29
+ >>> websocket-client-1.8.0
30
30
 
31
31
  SECTION 2: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
32
32
 
@@ -35,32 +35,34 @@ SECTION 2: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
35
35
  >>> click-8.1.7
36
36
  >>> colorama-0.4.6
37
37
  >>> commonmark-0.9.1
38
- >>> docutils-0.20.1
38
+ >>> docutils-0.21.2
39
39
  >>> flask-3.0.0
40
40
  >>> greenlet-3.0.1
41
- >>> idna-3.6
41
+ >>> idna-3.8
42
42
  >>> ifaddr-0.2.0
43
43
  >>> itsdangerous-2.1.2
44
- >>> jaraco.classes-3.3.0
44
+ >>> jaraco.classes-3.4.0
45
+ >>> jaraco.context-6.0.1
46
+ >>> jaraco.functools-4.0.2
45
47
  >>> jinja2-3.1.2
46
- >>> keyring-24.3.0
48
+ >>> keyring-25.3.0
47
49
  >>> markdown-it-py-3.0.0
48
50
  >>> markupsafe-2.1.3
49
51
  >>> mdurl-0.1.2
50
- >>> more-itertools-10.1.0
51
- >>> nh3-0.2.14
52
- >>> pkginfo-1.9.6
53
- >>> pygments-2.17.2
52
+ >>> more-itertools-10.6.0
53
+ >>> nh3-0.2.21
54
+ >>> pkginfo-1.10.0
55
+ >>> pygments-2.18.0
54
56
  >>> pycryptodome-3.19.0
55
- >>> pywin32-ctypes-0.2.2
56
- >>> rich-13.7.0
57
- >>> setuptools-68.2.2
57
+ >>> pywin32-ctypes-0.2.3
58
+ >>> rich-13.9.4
59
+ >>> setuptools-74.1.2
58
60
  >>> six-1.16.0
59
61
  >>> sqlalchemy-2.0.23
60
- >>> urllib3-2.1.0
62
+ >>> urllib3-2.3.0
61
63
  >>> webencodings-0.5.1
62
64
  >>> werkzeug-3.0.1
63
- >>> zipp-3.17.0
65
+ >>> zipp-3.21.0
64
66
 
65
67
  SECTION 3: GNU General Public License, V2.0
66
68
 
@@ -68,22 +70,24 @@ SECTION 3: GNU General Public License, V2.0
68
70
 
69
71
  SECTION 4: Mozilla Public License, V2.0
70
72
 
71
- >>> certifi-2023.11.17
73
+ >>> certifi-2024.8.30
72
74
 
73
75
  SECTION 5: Python License, V2.0
74
76
 
75
- >>> datetime
76
77
  >>> ipaddress-1.0
77
78
  >>> json-2.0.9
78
79
  >>> logging-0.5.1.2
80
+ >>> os
81
+ >>> pathlib
79
82
  >>> select
80
83
  >>> socket
84
+ >>> ssl
81
85
  >>> struct
82
86
  >>> random-3
83
87
  >>> re-2.2.1
84
88
  >>> threading
85
89
  >>> time
86
- >>> typing-extensions-4.8.0
90
+ >>> typing-extensions-4.12.2
87
91
  >>> uuid
88
92
  >>> weakref
89
93
 
@@ -107,7 +111,7 @@ Copyright (c) 2014-2017, Mozilla Foundation
107
111
  See the License for the specific language governing permissions and
108
112
  limitations under the License.
109
113
 
110
- >>> msgpack-1.0.7
114
+ >>> msgpack-1.1.0
111
115
 
112
116
  Found in: msgpack-python/COPYING
113
117
 
@@ -157,11 +161,11 @@ Copyright 2014 Ian Cordasco, Rackspace
157
161
  See the License for the specific language governing permissions and
158
162
  limitations under the License.
159
163
 
160
- >>> importlib-metadata-6.8.0
161
- >>> readme-renderer-42.0
162
- >>> requests-2.31.0
163
- >>> twine-4.0.2
164
- >>> websocket-client-1.6.4
164
+ >>> importlib-metadata-8.6.1
165
+ >>> readme-renderer-44.0
166
+ >>> requests-2.32.3
167
+ >>> twine-5.1.1
168
+ >>> websocket-client-1.8.0
165
169
 
166
170
  Apache License
167
171
  Version 2.0, January 2004
@@ -342,7 +346,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
342
346
  =============== SECTION 2. BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES ===============
343
347
 
344
348
 
345
- >>> blinker-1.0.0
349
+ >>> blinker-1.7.0
346
350
 
347
351
  Copyright 2010 Jason Kirtland
348
352
 
@@ -365,7 +369,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
365
369
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
366
370
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
367
371
 
368
- >>> charset-normalizer-3.3.2
372
+ >>> charset-normalizer-3.4.1
369
373
 
370
374
  MIT License
371
375
 
@@ -485,7 +489,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
485
489
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
486
490
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
487
491
 
488
- >>> docutils-0.20.1
492
+ >>> docutils-0.21.2
489
493
 
490
494
  .. include:: docs/header0.txt
491
495
 
@@ -711,7 +715,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
711
715
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
712
716
  THE SOFTWARE.
713
717
 
714
- >>> idna-3.6
718
+ >>> idna-3.10
715
719
 
716
720
  BSD 3-Clause License
717
721
 
@@ -935,7 +939,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
935
939
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
936
940
  IN THE SOFTWARE.
937
941
 
938
- >>> more-itertools-10.1.0
942
+ >>> more-itertools-10.6.0
939
943
 
940
944
  Copyright (c) 2012 Erik Rose
941
945
 
@@ -957,7 +961,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
957
961
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
958
962
  SOFTWARE.
959
963
 
960
- >>> nh3-0.2.14
964
+ >>> nh3-0.2.21
961
965
 
962
966
  The MIT License (MIT)
963
967
 
@@ -981,7 +985,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
981
985
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
982
986
  SOFTWARE.
983
987
 
984
- >>> pkginfo-1.9.6
988
+ >>> pkginfo-1.10.0
985
989
 
986
990
  MIT License
987
991
 
@@ -1069,7 +1073,7 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1069
1073
  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1070
1074
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1071
1075
 
1072
- >>> pygments-2.17.2
1076
+ >>> pygments-2.18.0
1073
1077
 
1074
1078
  Copyright (c) 2006-2022 by the respective authors (see AUTHORS file).
1075
1079
  All rights reserved.
@@ -1097,7 +1101,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1097
1101
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1098
1102
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1099
1103
 
1100
- >>> pywin32-ctypes-0.2.2
1104
+ >>> pywin32-ctypes-0.2.3
1101
1105
 
1102
1106
  This software is OSI Certified Open Source Software.
1103
1107
  OSI Certified is a certification mark of the Open Source Initiative.
@@ -1128,7 +1132,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1128
1132
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1129
1133
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1130
1134
 
1131
- >>> rich-13.7.0
1135
+ >>> rich-13.9.4
1132
1136
 
1133
1137
  Copyright (c) 2020 Will McGugan
1134
1138
 
@@ -1193,7 +1197,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1193
1197
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1194
1198
  SOFTWARE.
1195
1199
 
1196
- >>> urllib3-2.1.0
1200
+ >>> urllib3-2.3.0
1197
1201
 
1198
1202
  MIT License
1199
1203
 
@@ -1282,10 +1286,12 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1282
1286
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1283
1287
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1284
1288
 
1285
- >>> jaraco.classes-3.3.0
1286
- >>> keyring-24.3.0
1287
- >>> setuptools-68.2.2
1288
- >>> zipp-3.17.0
1289
+ >>> jaraco.classes-3.4.0
1290
+ >>> jaraco.context-6.0.1
1291
+ >>> jaraco.functools-4.0.2
1292
+ >>> keyring-25.6.0
1293
+ >>> setuptools-74.1.2
1294
+ >>> zipp-3.21.0
1289
1295
 
1290
1296
  Permission is hereby granted, free of charge, to any person obtaining a copy
1291
1297
  of this software and associated documentation files (the "Software"), to
@@ -1655,7 +1661,7 @@ Public License instead of this License.
1655
1661
  =============== SECTION 4. Mozilla Public License, V2.0 ===============
1656
1662
 
1657
1663
 
1658
- >>> certifi-2023.11.17
1664
+ >>> certifi-2024.8.30
1659
1665
 
1660
1666
  This package contains a modified version of ca-bundle.crt:
1661
1667
 
@@ -1681,19 +1687,20 @@ one at http://mozilla.org/MPL/2.0/.
1681
1687
 
1682
1688
  =============== SECTION 5. Python License, V2.0 ===============
1683
1689
 
1684
-
1685
- >>> datetime
1686
1690
  >>> ipaddress-1.0
1687
1691
  >>> json-2.0.9
1688
1692
  >>> logging-0.5.1.2
1693
+ >>> os
1694
+ >>> pathlib
1689
1695
  >>> select
1690
1696
  >>> socket
1697
+ >>> ssl
1691
1698
  >>> struct
1692
1699
  >>> random-3
1693
1700
  >>> re-2.2.1
1694
1701
  >>> threading
1695
1702
  >>> time
1696
- >>> typing-extensions-4.8.0
1703
+ >>> typing-extensions-4.12.2
1697
1704
  >>> uuid
1698
1705
  >>> weakref
1699
1706
 
@@ -1975,4 +1982,4 @@ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1975
1982
  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1976
1983
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1977
1984
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1978
- PERFORMANCE OF THIS SOFTWARE.
1985
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,20 @@
1
+ CkInoDriveAPI/IO.py,sha256=NFWkNzsI08y46yCkunuRq2Ejuodl9GM_FGA3WKIO1_Q,10534
2
+ CkInoDriveAPI/__init__.py,sha256=V5-YDL556lySvBnT9rq4x0joH6rTKyBWZwFY-52pq_s,150
3
+ CkInoDriveAPI/_version.py,sha256=GUGIXjDASp9ptQMPrIhgmvX329wtZPhLXRjv_wUEJ1A,399
4
+ CkInoDriveAPI/callback.py,sha256=c0kjor6n-3VKsO_Kc3zRPV4d1GnNfvQl2as38A1f46g,2962
5
+ CkInoDriveAPI/ck_ca.crt,sha256=uopTpSLmrazZpYhrJ-79bMTFYIjiAMxhHhMo07hYsy4,878
6
+ CkInoDriveAPI/defines.py,sha256=ZbgVXIF9Ax-cKU3bXl7tsT6rVPUpr6p2rlVqmGvh1wc,12903
7
+ CkInoDriveAPI/discoverLan.py,sha256=BWjol34X2iZJCtwa5z6TqTSsEbZSjuIZg40jeFnxQ5M,11029
8
+ CkInoDriveAPI/discoverWs.py,sha256=Mf4n0x-5xOBLJgANHTcEnPH0_WIbb-WQHKNI12h4ZMY,1152
9
+ CkInoDriveAPI/file.py,sha256=Eo1he5tY5wnb10MviXZu4Tswc_N70w7jf9LmHmihi3w,6582
10
+ CkInoDriveAPI/inoDrive.py,sha256=ZFGsOlejk5Pxk0nlkoP7mnBggeaxB2Xh-g72f6PKZN8,6080
11
+ CkInoDriveAPI/sysControl.py,sha256=i41dW8DNrpE8afRdciNOFfc7bGvbzPGVdZxq46PK7No,3480
12
+ CkInoDriveAPI/userApp.py,sha256=0E87QhG1gdKzI_sysrRWxJcPepmCnhw7p3W3uccWhTo,24366
13
+ CkInoDriveAPI/utils.py,sha256=dJVIPxW2tLohBEn1w8KTBPx4YfkNbGyqn3aE4vHPROA,16003
14
+ CkInoDriveAPI/wsHandle.py,sha256=alHU-v8M_GRWzQht65r6ye85vESY5NcZMpeGhxQZqXU,19626
15
+ CK_InoDrive_API-1.0.1.dist-info/LICENSE.txt,sha256=Htz8K82ehzm2lkK44nZ_hU0M5I4W8YHipiiRYyRdH5o,1077
16
+ CK_InoDrive_API-1.0.1.dist-info/METADATA,sha256=lTd7V0IJm1bna4n1k8szKQMxw17lcqsWkdVH7abb8Qg,3127
17
+ CK_InoDrive_API-1.0.1.dist-info/README.txt,sha256=RFQtWK6ncVBblsph8W0C1i-GViHEBw5PkdPRrT80CbY,94553
18
+ CK_InoDrive_API-1.0.1.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
19
+ CK_InoDrive_API-1.0.1.dist-info/top_level.txt,sha256=HQb3X73ZpaiGH2dSziFYqzUFtsf1oG6A5_qUtF03xyQ,14
20
+ CK_InoDrive_API-1.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (74.1.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
CkInoDriveAPI/IO.py CHANGED
@@ -1,13 +1,16 @@
1
1
  import logging
2
2
 
3
- from .wsHandle import InoDriveWS
4
3
  from .defines import CK
5
4
  from .defines import OP_STATE
6
5
 
7
6
 
8
7
  class IO(object):
9
8
  def __init__(self, **kwargs):
10
- self._connection_handle: InoDriveWS = kwargs.get('connection_handle')
9
+ self._get_connection_handle = kwargs.get('getConnectionHandle')
10
+
11
+ @property
12
+ def _connection_handle(self):
13
+ return self._get_connection_handle()
11
14
 
12
15
  def dispose(self):
13
16
  return
@@ -17,7 +20,7 @@ class IO(object):
17
20
  response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_METRICS])
18
21
 
19
22
  if response.get('error'):
20
- return {'success': False, 'Error': f'InoDrive GetMetrics Error: {str(response.get("error"))}'}
23
+ return {'success': False, 'Error': f"InoDrive GetMetrics Error: {str(response.get('error'))}"}
21
24
 
22
25
  data = response['data'][0]
23
26
 
@@ -102,7 +105,7 @@ class IO(object):
102
105
  response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_INPUTS])
103
106
 
104
107
  if response.get('error'):
105
- return {'success': False, 'Error': f'InoDrive GetInputData Error: {str(response.get("error"))}'}
108
+ return {'success': False, 'Error': f"InoDrive GetInputData Error: {str(response.get('error'))}"}
106
109
 
107
110
  data = response['data'][0]
108
111
  data.update({'success': True})
@@ -130,7 +133,7 @@ class IO(object):
130
133
  logging.error(data['error'])
131
134
  return None
132
135
 
133
- if type(input) == int and input >= 0 and input <= 3:
136
+ if type(input) is int and 0 <= input <= 3:
134
137
  return 1 if (data['digital'] >> input) & 0x1 else 0
135
138
  else:
136
139
  return data['digital']
@@ -146,7 +149,7 @@ class IO(object):
146
149
  logging.error(data['error'])
147
150
  return None
148
151
 
149
- if type(input) == int and input >= 0 and input <= 1:
152
+ if type(input) is int and 0 <= input <= 1:
150
153
  return 1 if (data['safety'] >> input) & 0x1 else 0
151
154
  else:
152
155
  return data['safety']
@@ -173,25 +176,25 @@ class IO(object):
173
176
 
174
177
  if target == 'all' and state is not None:
175
178
  target = -1
176
- if type(state) == str:
179
+ if type(state) is str:
177
180
  state = 0xf if state.upper() == 'NPN' else 0x0
178
181
  else:
179
182
  state = 0xf if state else 0x0
180
- elif target == 'val' and type(state) == int:
183
+ elif target == 'val' and type(state) is int:
181
184
  target = -1
182
- elif type(target) == int and target >= 0 and target <= 3 and state is not None:
183
- if type(state) == str:
185
+ elif type(target) is int and 0 <= target <= 3 and state is not None:
186
+ if type(state) is str:
184
187
  state = 0x1 if state.upper() == 'NPN' else 0x0
185
188
  else:
186
189
  state = 0x1 if state else 0x0
187
190
  else:
188
- logging.error(f'InoDrive SetInputPolarity Error: target or state not supported...')
191
+ logging.error(f"InoDrive SetInputPolarity Error: target or state not supported...")
189
192
  return None
190
193
 
191
194
  response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_INPUT_POLARITY, target, state])
192
195
 
193
196
  if response.get('error'):
194
- logging.error(f'InoDrive SetInputPolarity Error: {str(response)}')
197
+ logging.error(f"InoDrive SetInputPolarity Error: {str(response)}")
195
198
  return None
196
199
 
197
200
  return True
@@ -207,7 +210,7 @@ class IO(object):
207
210
  logging.error(data['error'])
208
211
  return None
209
212
 
210
- if type(input) == int and input >= 0 and input <= 3:
213
+ if type(input) is int and 0 <= input <= 3:
211
214
  return 'NPN' if (data['polarity'] >> input) & 0x1 else 'PNP'
212
215
  else:
213
216
  return data['polarity']
@@ -221,7 +224,7 @@ class IO(object):
221
224
  response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_OUTPUTS])
222
225
 
223
226
  if response.get('error'):
224
- return {'success': False, 'Error': f'InoDrive GetOutputData Error: {str(response.get("error"))}'}
227
+ return {'success': False, 'Error': f"InoDrive GetOutputData Error: {str(response.get('error'))}"}
225
228
 
226
229
  data = response['data'][0]
227
230
  data.update({'success': True})
@@ -235,19 +238,19 @@ class IO(object):
235
238
  if target == 'all' and state is not None:
236
239
  target = -1
237
240
  state = 0x7 if state else 0x0
238
- elif target == 'val' and type(state) == int:
241
+ elif target == 'val' and type(state) is int:
239
242
  target = -1
240
- elif type(target) == int and target >= 0 and target <= 2 and state is not None:
243
+ elif type(target) is int and 0 <= target <= 2 and state is not None:
241
244
  state = 0x1 if state else 0x0
242
245
  else:
243
- logging.error(f'InoDrive SetOutput Error: target os state not supported...')
246
+ logging.error(f"InoDrive SetOutput Error: target os state not supported...")
244
247
  return None
245
248
 
246
249
  response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_OUTPUTS, target, state])
247
250
 
248
251
  if response.get('error'):
249
- logging.error(f'InoDrive SetOutput Error: {str(response)}')
250
- return None
252
+ logging.error(f"InoDrive SetOutput Error: {str(response)}")
253
+ return False
251
254
 
252
255
  return True
253
256
  except Exception as ex:
@@ -263,7 +266,7 @@ class IO(object):
263
266
  logging.error(data['error'])
264
267
  return None
265
268
 
266
- if type(output) == int and output >= 0 and output <= 2:
269
+ if type(output) is int and 0 <= output <= 2:
267
270
  return 1 if (data['digital'] >> output) & 0x1 else 0
268
271
  else:
269
272
  return data['digital']
@@ -281,7 +284,7 @@ class IO(object):
281
284
  logging.error(data['error'])
282
285
  return None
283
286
 
284
- if type(output) == int and output >= 0 and output <= 2:
287
+ if type(output) is int and 0 <= output <= 2:
285
288
  return 1 if (data['digital_faults'] >> output) & 0x1 else 0
286
289
  else:
287
290
  return data['digital_faults']
@@ -297,8 +300,8 @@ class IO(object):
297
300
  response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_HOLDING_BRAKE, True if state else False])
298
301
 
299
302
  if response.get('error'):
300
- logging.error(f'InoDrive GetOutputFault Error: {str(response)}')
301
- return None
303
+ logging.error(f"InoDrive SetHoldingBrake Error: {str(response)}")
304
+ return False
302
305
 
303
306
  return True
304
307
  except Exception as ex:
CkInoDriveAPI/__init__.py CHANGED
@@ -2,3 +2,5 @@ from .inoDrive import InoDrive
2
2
  from .discoverLan import id_discover_lan
3
3
 
4
4
  discover = id_discover_lan
5
+ __version__ = '1.0.1'
6
+ __version__ = '1.0.1'
@@ -0,0 +1,17 @@
1
+ from pathlib import Path
2
+ import sys
3
+ import os
4
+
5
+
6
+ def get_version_number():
7
+ try:
8
+ dir_path = str(Path(os.path.dirname(__file__)).parent)
9
+ sys.path.append(dir_path)
10
+
11
+ from versions import get_latest_number
12
+ version = get_latest_number()
13
+ except ImportError:
14
+ from .__init__ import __version__
15
+ version = __version__
16
+
17
+ return version
@@ -0,0 +1,87 @@
1
+ import logging
2
+
3
+
4
+ class Callback(object):
5
+ _context = None
6
+ _callbacks = {}
7
+
8
+ def __init__(self, **kwargs):
9
+ self._context = kwargs.get('context', self)
10
+
11
+ def on(self, name=None, func=None):
12
+ try:
13
+ callbacks = {}
14
+
15
+ if type(name) is dict:
16
+ callbacks = name
17
+ elif type(name) is str and callable(func):
18
+ callbacks[name] = func
19
+ else:
20
+ return
21
+
22
+ for callback_name, callback_function in callbacks.items():
23
+ if type(callback_name) is not str:
24
+ continue
25
+
26
+ if not callable(callback_function):
27
+ continue
28
+
29
+ if callback_name not in self._callbacks:
30
+ # Callback does not exist
31
+ self._callbacks[callback_name] = [callback_function]
32
+ continue
33
+
34
+ if callback_function not in self._callbacks[callback_name]:
35
+ # Function is not in callback group
36
+ self._callbacks[callback_name].append(callback_function)
37
+ continue
38
+
39
+ except Exception as ex:
40
+ logging.exception(ex)
41
+
42
+ def remove(self, name=None, func=None):
43
+ try:
44
+ if type(name) is not str:
45
+ return
46
+
47
+ if not callable(func):
48
+ return
49
+
50
+ if self._callbacks[name] and func in self._callbacks[name]:
51
+ # Function exist so we need to remove it - removing callback.
52
+ self._callbacks[name].pop(self._callbacks[name].index(func))
53
+
54
+ if len(self._callbacks[name]) == 0:
55
+ # There are no more functions in the group - remove the group
56
+ del self._callbacks[name]
57
+
58
+ except Exception as ex:
59
+ logging.exception(ex)
60
+
61
+ def dispatch(self, callback_name=None, *args):
62
+ try:
63
+ # Get call back group
64
+ if callback_name in self._callbacks:
65
+ callbacks = self._callbacks[callback_name]
66
+ if callbacks is not None:
67
+ for callback in callbacks:
68
+ # Call each callback
69
+ if callable(callback):
70
+ callback(*args)
71
+
72
+ except Exception as ex:
73
+ logging.exception(ex)
74
+
75
+ def dispatch_with_context(self, context=None, callback_name=None, *args):
76
+ try:
77
+ # Get call back group
78
+ if callback_name in self._callbacks:
79
+ callbacks = self._callbacks[callback_name]
80
+ if callbacks is not None:
81
+ for callback in callbacks:
82
+ # Call each callback
83
+ if callable(callback):
84
+ callback(context, *args)
85
+
86
+ except Exception as ex:
87
+ logging.exception(ex)
@@ -0,0 +1,15 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICUTCCAdigAwIBAgIUKSVqbARTYaxckTUEA7Gby+uWD8IwCgYIKoZIzj0EAwIw
3
+ VzELMAkGA1UEBhMCVVMxETAPBgNVBAgMCEtlbnR1Y2t5MRgwFgYDVQQKDA9DYXJk
4
+ aW5hbEtpbmV0aWMxGzAZBgNVBAMMEkNhcmRpbmFsS2luZXRpYy1DQTAgFw0yNDA3
5
+ MTUxODM1NTVaGA8yMDk5MDQxMzE4MzU1NVowVzELMAkGA1UEBhMCVVMxETAPBgNV
6
+ BAgMCEtlbnR1Y2t5MRgwFgYDVQQKDA9DYXJkaW5hbEtpbmV0aWMxGzAZBgNVBAMM
7
+ EkNhcmRpbmFsS2luZXRpYy1DQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvtdcSO
8
+ PH4qPKdA/wSbraw88KgoiBmJMaD3ko4Gaix6iZSBTEK1TU+Oxp0XwVuaQxa0J7hp
9
+ xcjuy3BLYDhfF5e5Fp/Tjc4qaQNDZs9Z0MbVytZeNtrm7u4lwKWsjIjhUqNjMGEw
10
+ HQYDVR0OBBYEFOQ3kaz6Bd2kAHicNWlIoWdSYclMMB8GA1UdIwQYMBaAFOQ3kaz6
11
+ Bd2kAHicNWlIoWdSYclMMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGG
12
+ MAoGCCqGSM49BAMCA2cAMGQCMFhAt55Z+O88sJ60Z2FcGmYztu6QF18tdj04YlQX
13
+ SBWZ8tdpWofMsJi6yHwKlhqqQgIwVEpeh5RSuVSGmZAfYNFLLSnAYV0LnkKEAmuZ
14
+ 2YwmOc7BTjgjgnZrhb9538baKIaG
15
+ -----END CERTIFICATE-----