CK-InoDrive-API 1.0.0__tar.gz → 1.0.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.
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CK_InoDrive_API.egg-info/PKG-INFO +2 -2
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CK_InoDrive_API.egg-info/SOURCES.txt +2 -0
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CK_InoDrive_API.egg-info/requires.txt +1 -1
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/IO.py +11 -11
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/__init__.py +2 -0
- ck_inodrive_api-1.0.1/CkInoDriveAPI/_version.py +17 -0
- ck_inodrive_api-1.0.1/CkInoDriveAPI/callback.py +87 -0
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/discoverLan.py +1 -1
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/discoverWs.py +2 -2
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/file.py +11 -11
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/inoDrive.py +42 -28
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/sysControl.py +4 -4
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/userApp.py +132 -42
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/utils.py +7 -7
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/wsHandle.py +47 -30
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/PKG-INFO +2 -2
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/README.txt +25 -24
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/setup.py +25 -8
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CK_InoDrive_API.egg-info/dependency_links.txt +0 -0
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CK_InoDrive_API.egg-info/top_level.txt +0 -0
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/ck_ca.crt +0 -0
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/CkInoDriveAPI/defines.py +0 -0
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/LICENSE.txt +0 -0
- {ck_inodrive_api-1.0.0 → ck_inodrive_api-1.0.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: CK-InoDrive-API
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: InoDrive API Library
|
|
5
5
|
Home-page: https://cardinalkinetic.com
|
|
6
6
|
Author: Cardinal Kinetic
|
|
@@ -20,7 +20,7 @@ License-File: LICENSE.txt
|
|
|
20
20
|
License-File: README.txt
|
|
21
21
|
Requires-Dist: websocket-client==1.8.0
|
|
22
22
|
Requires-Dist: ifaddr==0.2.0
|
|
23
|
-
Requires-Dist: msgpack==1.0
|
|
23
|
+
Requires-Dist: msgpack==1.1.0
|
|
24
24
|
|
|
25
25
|
#### **Installation**
|
|
26
26
|
|
|
@@ -8,6 +8,8 @@ CK_InoDrive_API.egg-info/requires.txt
|
|
|
8
8
|
CK_InoDrive_API.egg-info/top_level.txt
|
|
9
9
|
CkInoDriveAPI/IO.py
|
|
10
10
|
CkInoDriveAPI/__init__.py
|
|
11
|
+
CkInoDriveAPI/_version.py
|
|
12
|
+
CkInoDriveAPI/callback.py
|
|
11
13
|
CkInoDriveAPI/ck_ca.crt
|
|
12
14
|
CkInoDriveAPI/defines.py
|
|
13
15
|
CkInoDriveAPI/discoverLan.py
|
|
@@ -6,7 +6,7 @@ from .defines import OP_STATE
|
|
|
6
6
|
|
|
7
7
|
class IO(object):
|
|
8
8
|
def __init__(self, **kwargs):
|
|
9
|
-
self._get_connection_handle = kwargs.get('
|
|
9
|
+
self._get_connection_handle = kwargs.get('getConnectionHandle')
|
|
10
10
|
|
|
11
11
|
@property
|
|
12
12
|
def _connection_handle(self):
|
|
@@ -20,7 +20,7 @@ class IO(object):
|
|
|
20
20
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_METRICS])
|
|
21
21
|
|
|
22
22
|
if response.get('error'):
|
|
23
|
-
return {'success': False, 'Error': f
|
|
23
|
+
return {'success': False, 'Error': f"InoDrive GetMetrics Error: {str(response.get('error'))}"}
|
|
24
24
|
|
|
25
25
|
data = response['data'][0]
|
|
26
26
|
|
|
@@ -105,7 +105,7 @@ class IO(object):
|
|
|
105
105
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_INPUTS])
|
|
106
106
|
|
|
107
107
|
if response.get('error'):
|
|
108
|
-
return {'success': False, 'Error': f
|
|
108
|
+
return {'success': False, 'Error': f"InoDrive GetInputData Error: {str(response.get('error'))}"}
|
|
109
109
|
|
|
110
110
|
data = response['data'][0]
|
|
111
111
|
data.update({'success': True})
|
|
@@ -188,13 +188,13 @@ class IO(object):
|
|
|
188
188
|
else:
|
|
189
189
|
state = 0x1 if state else 0x0
|
|
190
190
|
else:
|
|
191
|
-
logging.error(f
|
|
191
|
+
logging.error(f"InoDrive SetInputPolarity Error: target or state not supported...")
|
|
192
192
|
return None
|
|
193
193
|
|
|
194
194
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_INPUT_POLARITY, target, state])
|
|
195
195
|
|
|
196
196
|
if response.get('error'):
|
|
197
|
-
logging.error(f
|
|
197
|
+
logging.error(f"InoDrive SetInputPolarity Error: {str(response)}")
|
|
198
198
|
return None
|
|
199
199
|
|
|
200
200
|
return True
|
|
@@ -224,7 +224,7 @@ class IO(object):
|
|
|
224
224
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_OUTPUTS])
|
|
225
225
|
|
|
226
226
|
if response.get('error'):
|
|
227
|
-
return {'success': False, 'Error': f
|
|
227
|
+
return {'success': False, 'Error': f"InoDrive GetOutputData Error: {str(response.get('error'))}"}
|
|
228
228
|
|
|
229
229
|
data = response['data'][0]
|
|
230
230
|
data.update({'success': True})
|
|
@@ -243,14 +243,14 @@ class IO(object):
|
|
|
243
243
|
elif type(target) is int and 0 <= target <= 2 and state is not None:
|
|
244
244
|
state = 0x1 if state else 0x0
|
|
245
245
|
else:
|
|
246
|
-
logging.error(f
|
|
246
|
+
logging.error(f"InoDrive SetOutput Error: target os state not supported...")
|
|
247
247
|
return None
|
|
248
248
|
|
|
249
249
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_OUTPUTS, target, state])
|
|
250
250
|
|
|
251
251
|
if response.get('error'):
|
|
252
|
-
logging.error(f
|
|
253
|
-
return
|
|
252
|
+
logging.error(f"InoDrive SetOutput Error: {str(response)}")
|
|
253
|
+
return False
|
|
254
254
|
|
|
255
255
|
return True
|
|
256
256
|
except Exception as ex:
|
|
@@ -300,8 +300,8 @@ class IO(object):
|
|
|
300
300
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_HOLDING_BRAKE, True if state else False])
|
|
301
301
|
|
|
302
302
|
if response.get('error'):
|
|
303
|
-
logging.error(f
|
|
304
|
-
return
|
|
303
|
+
logging.error(f"InoDrive SetHoldingBrake Error: {str(response)}")
|
|
304
|
+
return False
|
|
305
305
|
|
|
306
306
|
return True
|
|
307
307
|
except Exception as ex:
|
|
@@ -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)
|
|
@@ -228,5 +228,5 @@ def id_discover_lan(net_adapter_ip=None, num_attempts=2):
|
|
|
228
228
|
|
|
229
229
|
# Return a stripped down version of the dictionary because the serial number key is no longer needed.
|
|
230
230
|
results = list(all_modules_on_all_ifs.values())
|
|
231
|
-
logging.info(f
|
|
231
|
+
logging.info(f"Total modules found: {len(results)}")
|
|
232
232
|
return results
|
|
@@ -6,7 +6,7 @@ from .utils import Utils
|
|
|
6
6
|
|
|
7
7
|
class DiscoverWs(object):
|
|
8
8
|
def __init__(self, **kwargs):
|
|
9
|
-
self._get_connection_handle = kwargs.get('
|
|
9
|
+
self._get_connection_handle = kwargs.get('getConnectionHandle')
|
|
10
10
|
|
|
11
11
|
@property
|
|
12
12
|
def _connection_handle(self):
|
|
@@ -21,7 +21,7 @@ class DiscoverWs(object):
|
|
|
21
21
|
resp = self._connection_handle.request(Utils.get_tlv(CK.SPECIAL.GET_DISCOVER_INFO))
|
|
22
22
|
|
|
23
23
|
if resp.get('error'):
|
|
24
|
-
logging.error(f
|
|
24
|
+
logging.error(f"Retrieving discover info failed...")
|
|
25
25
|
return None
|
|
26
26
|
|
|
27
27
|
result = None
|
|
@@ -7,7 +7,7 @@ from .utils import Utils
|
|
|
7
7
|
|
|
8
8
|
class File(object):
|
|
9
9
|
def __init__(self, **kwargs):
|
|
10
|
-
self._get_connection_handle = kwargs.get('
|
|
10
|
+
self._get_connection_handle = kwargs.get('getConnectionHandle')
|
|
11
11
|
|
|
12
12
|
@property
|
|
13
13
|
def _connection_handle(self):
|
|
@@ -19,7 +19,7 @@ class File(object):
|
|
|
19
19
|
def read(self, files=None, transfer_type=None):
|
|
20
20
|
try:
|
|
21
21
|
if files is None:
|
|
22
|
-
logging.error(f
|
|
22
|
+
logging.error(f"Files is None...")
|
|
23
23
|
return None
|
|
24
24
|
|
|
25
25
|
if type(files) is not list:
|
|
@@ -32,14 +32,14 @@ class File(object):
|
|
|
32
32
|
|
|
33
33
|
for file in files:
|
|
34
34
|
if type(file) is not dict:
|
|
35
|
-
logging.error(f
|
|
35
|
+
logging.error(f"File is not a dict...")
|
|
36
36
|
return None
|
|
37
37
|
|
|
38
38
|
file_path = file.get('path')
|
|
39
39
|
content = file.get('content', 'bytes')
|
|
40
40
|
|
|
41
41
|
if type(file_path) is not str:
|
|
42
|
-
logging.error(f
|
|
42
|
+
logging.error(f"File path is not a string...")
|
|
43
43
|
return None
|
|
44
44
|
|
|
45
45
|
file_path = file_path.replace('\\', '/')
|
|
@@ -48,7 +48,7 @@ class File(object):
|
|
|
48
48
|
file_path = file_path[1:]
|
|
49
49
|
|
|
50
50
|
if file_path[0] != '/':
|
|
51
|
-
file_path = f
|
|
51
|
+
file_path = f"/{file_path}"
|
|
52
52
|
|
|
53
53
|
file_path = file_path.replace('\\', '/')
|
|
54
54
|
|
|
@@ -83,7 +83,7 @@ class File(object):
|
|
|
83
83
|
def write(self, files=None, transfer_type=None):
|
|
84
84
|
try:
|
|
85
85
|
if files is None:
|
|
86
|
-
logging.error(f
|
|
86
|
+
logging.error(f"Files not provided...")
|
|
87
87
|
return False
|
|
88
88
|
|
|
89
89
|
if type(files) is not list:
|
|
@@ -94,7 +94,7 @@ class File(object):
|
|
|
94
94
|
|
|
95
95
|
for file in files:
|
|
96
96
|
if type(file) is not dict:
|
|
97
|
-
logging.error(f
|
|
97
|
+
logging.error(f"File is not a dict...")
|
|
98
98
|
return False
|
|
99
99
|
|
|
100
100
|
file_path = file.get('path')
|
|
@@ -105,7 +105,7 @@ class File(object):
|
|
|
105
105
|
file_path = file_path[1:]
|
|
106
106
|
|
|
107
107
|
if file_path[0] != '/':
|
|
108
|
-
file_path = f
|
|
108
|
+
file_path = f"/{file_path}"
|
|
109
109
|
|
|
110
110
|
file_path = file_path.replace('\\', '/')
|
|
111
111
|
|
|
@@ -118,7 +118,7 @@ class File(object):
|
|
|
118
118
|
file_content = bytes(file_content, 'utf-8')
|
|
119
119
|
|
|
120
120
|
if file_content is None or type(file_content) is not bytes:
|
|
121
|
-
logging.error(f
|
|
121
|
+
logging.error(f"File content is not bytes...")
|
|
122
122
|
return False
|
|
123
123
|
|
|
124
124
|
msg = b''
|
|
@@ -133,7 +133,7 @@ class File(object):
|
|
|
133
133
|
resp = self._connection_handle.request(msg)
|
|
134
134
|
|
|
135
135
|
if resp.get('error'):
|
|
136
|
-
logging.error(f
|
|
136
|
+
logging.error(f"File [{file_path}] write error: {resp.get('error')}")
|
|
137
137
|
return False
|
|
138
138
|
|
|
139
139
|
return True
|
|
@@ -148,7 +148,7 @@ class File(object):
|
|
|
148
148
|
resp = self._connection_handle.request(Utils.get_tlv(CK.SPECIAL.DELETE_UAPP))
|
|
149
149
|
|
|
150
150
|
if resp.get('error'):
|
|
151
|
-
logging.error(f
|
|
151
|
+
logging.error(f"Deleting User Application failed...")
|
|
152
152
|
return False
|
|
153
153
|
|
|
154
154
|
return True
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import weakref
|
|
3
|
+
from ._version import get_version_number
|
|
4
|
+
from .callback import Callback
|
|
3
5
|
|
|
4
6
|
from .wsHandle import InoDriveWS
|
|
5
7
|
from .file import File
|
|
@@ -10,23 +12,36 @@ from .sysControl import SysControl
|
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
class InoDrive(object):
|
|
15
|
+
version = None
|
|
13
16
|
_kwargs = None
|
|
14
|
-
_callbacks = {}
|
|
15
17
|
_connection_handle_instance = None
|
|
16
18
|
|
|
17
19
|
def __init__(self, **kwargs):
|
|
20
|
+
self.version = get_version_number()
|
|
18
21
|
self._kwargs = kwargs
|
|
19
22
|
logging.debug('Create InoDrive instance...')
|
|
20
23
|
self._auto_connect = kwargs.get('autoConnect', False)
|
|
21
24
|
|
|
25
|
+
# Callbacks
|
|
26
|
+
self._callback = Callback()
|
|
27
|
+
|
|
28
|
+
if 'callbacks' in self._kwargs:
|
|
29
|
+
if type(self._kwargs['callbacks']) is dict:
|
|
30
|
+
for name, functions in self._kwargs['callbacks'].items():
|
|
31
|
+
if type(functions) is not list:
|
|
32
|
+
functions = [functions]
|
|
33
|
+
for func in functions:
|
|
34
|
+
if callable(func):
|
|
35
|
+
self._callback.on(name, func)
|
|
36
|
+
|
|
22
37
|
# ==============================================================================================================
|
|
23
38
|
# MODULES BEGIN
|
|
24
39
|
# ==============================================================================================================
|
|
25
|
-
self.File = File(**kwargs,
|
|
26
|
-
self.Discover = DiscoverWs(**kwargs,
|
|
27
|
-
self.IO = IO(**kwargs,
|
|
28
|
-
self.UserApp = UserApp(**kwargs,
|
|
29
|
-
self.SysControl = SysControl(**kwargs,
|
|
40
|
+
self.File = File(**kwargs, getConnectionHandle=self._get_connection_handle, callback=self._callback)
|
|
41
|
+
self.Discover = DiscoverWs(**kwargs, getConnectionHandle=self._get_connection_handle, callback=self._callback)
|
|
42
|
+
self.IO = IO(**kwargs, getConnectionHandle=self._get_connection_handle, callback=self._callback)
|
|
43
|
+
self.UserApp = UserApp(**kwargs, getConnectionHandle=self._get_connection_handle, callback=self._callback)
|
|
44
|
+
self.SysControl = SysControl(**kwargs, getConnectionHandle=self._get_connection_handle, callback=self._callback)
|
|
30
45
|
# ==============================================================================================================
|
|
31
46
|
# MODULES END
|
|
32
47
|
# ==============================================================================================================
|
|
@@ -40,9 +55,9 @@ class InoDrive(object):
|
|
|
40
55
|
self._use_fallback = True
|
|
41
56
|
|
|
42
57
|
if "secureConnection" in self._kwargs:
|
|
43
|
-
False if self._kwargs["secureConnection"] == False else True
|
|
58
|
+
self._secure_connection = False if self._kwargs["secureConnection"] == False else True
|
|
44
59
|
else:
|
|
45
|
-
self.
|
|
60
|
+
self._secure_connection = True
|
|
46
61
|
|
|
47
62
|
if self._auto_connect:
|
|
48
63
|
self.connect()
|
|
@@ -56,6 +71,14 @@ class InoDrive(object):
|
|
|
56
71
|
def __del__(self):
|
|
57
72
|
self._finalizer()
|
|
58
73
|
|
|
74
|
+
@property
|
|
75
|
+
def callback(self):
|
|
76
|
+
return self._callback
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def on(self):
|
|
80
|
+
return self._callback.on
|
|
81
|
+
|
|
59
82
|
def dispose(self):
|
|
60
83
|
try:
|
|
61
84
|
if self.UserApp:
|
|
@@ -70,11 +93,16 @@ class InoDrive(object):
|
|
|
70
93
|
try:
|
|
71
94
|
if self._connection_handle_instance is None:
|
|
72
95
|
# Connection handle is not created yet
|
|
73
|
-
|
|
96
|
+
connection_handle = None
|
|
97
|
+
if self._secure_connection:
|
|
74
98
|
try:
|
|
75
|
-
connection_handle = InoDriveWS(
|
|
76
|
-
|
|
99
|
+
connection_handle = InoDriveWS(
|
|
100
|
+
**self._kwargs,
|
|
101
|
+
callback=self._callback,
|
|
102
|
+
secure=True
|
|
103
|
+
)
|
|
77
104
|
self._connection_handle_instance = connection_handle
|
|
105
|
+
connection_handle.connect()
|
|
78
106
|
except Exception as ex:
|
|
79
107
|
logging.exception(ex)
|
|
80
108
|
if connection_handle:
|
|
@@ -83,9 +111,9 @@ class InoDrive(object):
|
|
|
83
111
|
if not self._use_fallback:
|
|
84
112
|
return
|
|
85
113
|
else:
|
|
86
|
-
connection_handle = InoDriveWS(**self._kwargs,
|
|
87
|
-
connection_handle.connect()
|
|
114
|
+
connection_handle = InoDriveWS(**self._kwargs, callback=self._callback, secure=False)
|
|
88
115
|
self._connection_handle_instance = connection_handle
|
|
116
|
+
connection_handle.connect()
|
|
89
117
|
else:
|
|
90
118
|
self._connection_handle_instance.connect()
|
|
91
119
|
except Exception as ex:
|
|
@@ -98,7 +126,7 @@ class InoDrive(object):
|
|
|
98
126
|
except Exception as ex:
|
|
99
127
|
logging.exception(ex)
|
|
100
128
|
|
|
101
|
-
def set_target(self, target):
|
|
129
|
+
def set_target(self, target=None):
|
|
102
130
|
if type(target) is not str:
|
|
103
131
|
return
|
|
104
132
|
|
|
@@ -107,20 +135,6 @@ class InoDrive(object):
|
|
|
107
135
|
|
|
108
136
|
self._kwargs.host = target
|
|
109
137
|
|
|
110
|
-
def on(self, evt, func):
|
|
111
|
-
try:
|
|
112
|
-
match evt:
|
|
113
|
-
case "connect":
|
|
114
|
-
self._callbacks['onConnect'] = func if callable(func) else None
|
|
115
|
-
case "disconnect":
|
|
116
|
-
self._callbacks['onDisconnect'] = func if callable(func) else None
|
|
117
|
-
case "error":
|
|
118
|
-
self._callbacks['onError'] = func if callable(func) else None
|
|
119
|
-
case "message":
|
|
120
|
-
self._callbacks['onMessage'] = func if callable(func) else None
|
|
121
|
-
except Exception as ex:
|
|
122
|
-
logging.exception(ex)
|
|
123
|
-
|
|
124
138
|
@property
|
|
125
139
|
def connected(self):
|
|
126
140
|
if self._connection_handle_instance is not None:
|
|
@@ -6,7 +6,7 @@ from .utils import Utils
|
|
|
6
6
|
|
|
7
7
|
class SysControl(object):
|
|
8
8
|
def __init__(self, **kwargs):
|
|
9
|
-
self._get_connection_handle = kwargs.get('
|
|
9
|
+
self._get_connection_handle = kwargs.get('getConnectionHandle')
|
|
10
10
|
|
|
11
11
|
@property
|
|
12
12
|
def _connection_handle(self):
|
|
@@ -20,7 +20,7 @@ class SysControl(object):
|
|
|
20
20
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.CONSOLE_ENABLE, True if state else False])
|
|
21
21
|
|
|
22
22
|
if response.get('error'):
|
|
23
|
-
logging.error(f
|
|
23
|
+
logging.error(f"InoDrive ConsoleEnable Error: {str(response)}")
|
|
24
24
|
return None
|
|
25
25
|
|
|
26
26
|
return True
|
|
@@ -32,7 +32,7 @@ class SysControl(object):
|
|
|
32
32
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.TAKE_CONTROL, True if state else False])
|
|
33
33
|
|
|
34
34
|
if response.get('error'):
|
|
35
|
-
logging.error(f
|
|
35
|
+
logging.error(f"InoDrive TakeControl Error: {str(response)}")
|
|
36
36
|
return None
|
|
37
37
|
|
|
38
38
|
return True
|
|
@@ -44,7 +44,7 @@ class SysControl(object):
|
|
|
44
44
|
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.MODULE_INFO])
|
|
45
45
|
|
|
46
46
|
if response.get('error'):
|
|
47
|
-
logging.error(f
|
|
47
|
+
logging.error(f"InoDrive GetModuleInfo Error: {str(response)}")
|
|
48
48
|
return None
|
|
49
49
|
|
|
50
50
|
data = response['data'][0]
|