quarchpy 2.1.24.dev5__py2.py3-none-any.whl → 2.1.26__py2.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.
- quarchpy/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/__pycache__/_version.cpython-311.pyc +0 -0
- quarchpy/__pycache__/connection.cpython-311.pyc +0 -0
- quarchpy/__pycache__/run.cpython-311.pyc +0 -0
- quarchpy/_version.py +1 -1
- quarchpy/config_files/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/config_files/__pycache__/quarch_config_parser.cpython-311.pyc +0 -0
- quarchpy/connection_specific/QPS/qis/qis.jar +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/{CInterface-1.7.9.jar → CInterface-1.8.2.jar} +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/{CInterface-1.8.0.jar → CInterface-1.9.jar} +0 -0
- quarchpy/connection_specific/QPS/{qps_lib/QuarchCommon-0.2.12.jar → qis/qis_lib/QuarchCommon-0.2.13.jar} +0 -0
- quarchpy/connection_specific/QPS/qps.jar +0 -0
- quarchpy/connection_specific/QPS/{qis/qis_lib/QuarchCommon-0.2.12.jar → qps_lib/QuarchCommon-0.2.13.jar} +0 -0
- quarchpy/connection_specific/QPS/qps_lib/{qis-1.41.jar → qis-1.43.jar} +0 -0
- quarchpy/connection_specific/QPS/resources/InstallBanner.bmp +0 -0
- quarchpy/connection_specific/QPS/resources/QPS.ico +0 -0
- quarchpy/connection_specific/QPS/resources/QPS.png +0 -0
- quarchpy/connection_specific/QPS/resources/QuarchIcon_128x128.png +0 -0
- quarchpy/connection_specific/QPS/resources/QuarchIcon_16x16.png +0 -0
- quarchpy/connection_specific/QPS/resources/QuarchIcon_256x256.png +0 -0
- quarchpy/connection_specific/QPS/resources/QuarchIcon_32x32.png +0 -0
- quarchpy/connection_specific/QPS/resources/QuarchIcon_64x64.png +0 -0
- quarchpy/connection_specific/QPS/scriptCommands.txt +17 -2
- quarchpy/connection_specific/__pycache__/StreamChannels.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/connection_QIS.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/connection_QPS.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/connection_ReST.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/connection_Serial.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/connection_TCP.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/connection_USB.cpython-311.pyc +0 -0
- quarchpy/connection_specific/__pycache__/mDNS.cpython-311.pyc +0 -0
- quarchpy/connection_specific/connection_QPS.py +52 -0
- quarchpy/connection_specific/mDNS.py +126 -0
- quarchpy/connection_specific/serial/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/connection_specific/serial/__pycache__/serialutil.cpython-311.pyc +0 -0
- quarchpy/connection_specific/serial/__pycache__/serialwin32.cpython-311.pyc +0 -0
- quarchpy/connection_specific/serial/__pycache__/win32.cpython-311.pyc +0 -0
- quarchpy/connection_specific/serial/tools/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/connection_specific/serial/tools/__pycache__/list_ports.cpython-311.pyc +0 -0
- quarchpy/connection_specific/serial/tools/__pycache__/list_ports_common.cpython-311.pyc +0 -0
- quarchpy/connection_specific/serial/tools/__pycache__/list_ports_windows.cpython-311.pyc +0 -0
- quarchpy/debug/SystemTest.py +2 -6
- quarchpy/debug/SystemTest.py.bak +200 -0
- quarchpy/debug/__pycache__/SystemTest.cpython-311.pyc +0 -0
- quarchpy/debug/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/debug/__pycache__/module_debug.cpython-311.pyc +0 -0
- quarchpy/debug/__pycache__/simple_terminal.cpython-311.pyc +0 -0
- quarchpy/debug/__pycache__/upgrade_quarchpy.cpython-311.pyc +0 -0
- quarchpy/debug/__pycache__/versionCompare.cpython-311.pyc +0 -0
- quarchpy/device/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/device/__pycache__/device.cpython-311.pyc +0 -0
- quarchpy/device/__pycache__/quarchArray.cpython-311.pyc +0 -0
- quarchpy/device/__pycache__/quarchPPM.cpython-311.pyc +0 -0
- quarchpy/device/__pycache__/quarchQPS.cpython-311.pyc +0 -0
- quarchpy/device/__pycache__/scanDevices.cpython-311.pyc +0 -0
- quarchpy/device/device.py +72 -22
- quarchpy/device/scanDevices.py +26 -11
- quarchpy/disk_test/__pycache__/AbsDiskFinder.cpython-311.pyc +0 -0
- quarchpy/disk_test/__pycache__/DiskTargetSelection.cpython-311.pyc +0 -0
- quarchpy/disk_test/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/disk_test/__pycache__/iometerDiskFinder.cpython-311.pyc +0 -0
- quarchpy/docs/CHANGES.rst +13 -0
- quarchpy/docs/_build/doctrees/CHANGES.doctree +0 -0
- quarchpy/docs/_build/doctrees/environment.pickle +0 -0
- quarchpy/docs/_build/doctrees/source/changelog.doctree +0 -0
- quarchpy/docs/_build/doctrees/source/quarchpy.connection_specific.doctree +0 -0
- quarchpy/docs/_build/doctrees/source/quarchpy.device.doctree +0 -0
- quarchpy/docs/_build/doctrees/source/quarchpy.qps.doctree +0 -0
- quarchpy/docs/_build/html/CHANGES.html +138 -119
- quarchpy/docs/_build/html/_sources/CHANGES.rst.txt +13 -0
- quarchpy/docs/_build/html/genindex.html +4 -0
- quarchpy/docs/_build/html/index.html +63 -60
- quarchpy/docs/_build/html/objects.inv +0 -0
- quarchpy/docs/_build/html/readme.html +6 -7
- quarchpy/docs/_build/html/searchindex.js +1 -1
- quarchpy/docs/_build/html/source/changelog.html +201 -179
- quarchpy/docs/_build/html/source/licenses.html +6 -7
- quarchpy/docs/_build/html/source/quarchpy.connection_specific.html +10 -0
- quarchpy/docs/_build/html/source/quarchpy.device.html +1 -1
- quarchpy/docs/_build/html/source/quarchpy.html +2 -0
- quarchpy/docs/_build/html/source/quarchpy.iometer.html +6 -7
- quarchpy/docs/_build/html/source/quarchpy.qps.html +2 -2
- quarchpy/docs/_build/html/source/quarchpy.utilities.html +6 -7
- quarchpy/docs/_build/html/source/readme.html +6 -7
- quarchpy/fio/__pycache__/FIO_interface.cpython-311.pyc +0 -0
- quarchpy/fio/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/iometer/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/iometer/__pycache__/gen_iometer_template.cpython-311.pyc +0 -0
- quarchpy/iometer/__pycache__/iometerFuncs.cpython-311.pyc +0 -0
- quarchpy/qis/__pycache__/StreamHeaderInfo.cpython-311.pyc +0 -0
- quarchpy/qis/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/qis/__pycache__/qisFuncs.cpython-311.pyc +0 -0
- quarchpy/qps/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/qps/__pycache__/qpsFuncs.cpython-311.pyc +0 -0
- quarchpy/qps/qpsFuncs.py +20 -10
- quarchpy/qps/qpsFuncs.py.bak +281 -0
- quarchpy/user_interface/__pycache__/__init__.cpython-311.pyc +0 -0
- quarchpy/user_interface/__pycache__/user_interface.cpython-311.pyc +0 -0
- quarchpy/user_interface/user_interface.py +3 -1
- quarchpy/utilities/__pycache__/TestCenter.cpython-311.pyc +0 -0
- quarchpy/utilities/__pycache__/TimeValue.cpython-311.pyc +0 -0
- quarchpy/utilities/__pycache__/Version.cpython-311.pyc +0 -0
- quarchpy/utilities/__pycache__/__init__.cpython-311.pyc +0 -0
- {quarchpy-2.1.24.dev5.dist-info → quarchpy-2.1.26.dist-info}/METADATA +15 -2
- {quarchpy-2.1.24.dev5.dist-info → quarchpy-2.1.26.dist-info}/RECORD +108 -58
- {quarchpy-2.1.24.dev5.dist-info → quarchpy-2.1.26.dist-info}/WHEEL +1 -1
- quarchpy/connection_specific/QPS/qis/qis_lib/CInterface-1.7.04.jar +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/CInterface-1.7.8.jar +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/CInterface-1.8.1.jar +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/QuarchCommon-0.2.6.jar +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/QuarchCommon-0.2.9.jar +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/commons-csv-1.8.jar +0 -0
- quarchpy/connection_specific/QPS/qis/qis_lib/commons-lang3-3.2.1.jar +0 -0
- quarchpy/connection_specific/QPS/qis/resources/filters/filters.csv +0 -1004
- quarchpy/connection_specific/QPS/qps_lib/QuarchCommon-0.2.6.jar +0 -0
- quarchpy/connection_specific/QPS/qps_lib/QuarchCommon-0.2.9.jar +0 -0
- quarchpy/connection_specific/QPS/qps_lib/commons-lang3-3.12.0.jar +0 -0
- quarchpy/connection_specific/QPS/qps_lib/jfxtras-labs-8.0-r6.jar +0 -0
- quarchpy/connection_specific/QPS/qps_lib/opencsv-5.9.jar +0 -0
- quarchpy/connection_specific/QPS/qps_lib/qis-1.39.jar +0 -0
- quarchpy/connection_specific/QPS/qps_lib/qis-1.40.jar +0 -0
- quarchpy/connection_specific/connection_mDNS.py +0 -40
- {quarchpy-2.1.24.dev5.dist-info → quarchpy-2.1.26.dist-info}/top_level.txt +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
quarchpy/_version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "2.1.
|
1
|
+
__version__ = "2.1.26"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,7 +1,7 @@
|
|
1
1
|
QPS Command Summary
|
2
2
|
Copyright (c) Quarch Ltd
|
3
|
-
QPS v1.39
|
4
|
-
Generated:
|
3
|
+
QPS v1.39.13
|
4
|
+
Generated: 13-May-2024
|
5
5
|
|
6
6
|
|
7
7
|
*** Commands ***
|
@@ -345,6 +345,19 @@ Default value: NONE
|
|
345
345
|
Examples:
|
346
346
|
$open recording qpsFile="C:\quarch\recordings\AC\AC_Gen_test\AC_Gen_Test.qps"
|
347
347
|
|
348
|
+
Command: $progress check
|
349
|
+
Description: Checks the progress of a specific QPS task
|
350
|
+
Version: 2
|
351
|
+
Arguments
|
352
|
+
Argument: task
|
353
|
+
Description: The task to be checked
|
354
|
+
Index: 0
|
355
|
+
Type: STRING
|
356
|
+
Default value: NONE
|
357
|
+
Acceptable values: [open recording]
|
358
|
+
Examples:
|
359
|
+
$progress check task="open recording"
|
360
|
+
|
348
361
|
Command: $qis launch
|
349
362
|
Description: Launches new QIS instance
|
350
363
|
Version: 2
|
@@ -992,6 +1005,8 @@ $module scan ~ Scans for available devices
|
|
992
1005
|
|
993
1006
|
$open recording ~ Opens a recording
|
994
1007
|
|
1008
|
+
$progress check ~ Checks the progress of a specific QPS task
|
1009
|
+
|
995
1010
|
$qis launch ~ Launches new QIS instance
|
996
1011
|
|
997
1012
|
$qis shutdown ~ Shuts down current QIS instance
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -140,6 +140,17 @@ class QpsInterface:
|
|
140
140
|
time.sleep(
|
141
141
|
sleep) # Time must be allowed for QPS to Scan. If another scan request is sent it will time out and throw an error.
|
142
142
|
|
143
|
+
def get_list_details(self, sock=None):
|
144
|
+
if sock == None:
|
145
|
+
sock = self.sock
|
146
|
+
devString = self.sendCmdVerbose("$module list details")
|
147
|
+
#devString = self.sendAndReceiveText(sock, '$list details')
|
148
|
+
devString = devString.replace('>', '')
|
149
|
+
devString = devString.replace(r'\d+\) ', '')
|
150
|
+
devString = devString.split('\r\n')
|
151
|
+
devString = [x for x in devString if x] # remove empty elements
|
152
|
+
return devString
|
153
|
+
|
143
154
|
def getDeviceList(self, scan = True, ipAddress = None):
|
144
155
|
deviceList = []
|
145
156
|
scanWait = 2
|
@@ -182,4 +193,45 @@ class QpsInterface:
|
|
182
193
|
#return list of devices
|
183
194
|
return deviceList
|
184
195
|
|
196
|
+
|
197
|
+
def open_recording(self, file_path, cmdTimeout=5, pollInterval=3, startOpenTimout=5):
|
198
|
+
"""
|
199
|
+
|
200
|
+
"""
|
201
|
+
#print("Open recording at file : \""+str(file_path)+"\"")
|
202
|
+
self.sendCmdVerbose("$open recording qpsFile=\""+str(file_path)+"\"",timeout=cmdTimeout)
|
203
|
+
loadingStarted=False
|
204
|
+
message=""
|
205
|
+
startTime=time.time()
|
206
|
+
notLoadingMessageStartTime=None
|
207
|
+
while(1):
|
208
|
+
update=self.sendCmdVerbose("$progress check \"open recording\"",timeout=cmdTimeout)
|
209
|
+
#print(update)
|
210
|
+
m = re.search('\d+(\.\d+)?%', update)
|
211
|
+
if m: # A percentage was found
|
212
|
+
loadingStarted=True
|
213
|
+
found = float(m.group(0)[:-1])
|
214
|
+
user_interface.progressBar(found,100)
|
215
|
+
if found > 99.9: # This will catch the case we have 99.9999% or 100% loaded. recording with less that 1mill records auto return 100%
|
216
|
+
message = "Passed, Recording opened, loading detected and complete."
|
217
|
+
break
|
218
|
+
elif("Chart window is open but no loading is in progress." in update):
|
219
|
+
if loadingStarted ==True:
|
220
|
+
# Loading started and has now ended, so we can exit the loop.
|
221
|
+
message="Passed, Recording opened, loading detected and complete."
|
222
|
+
break
|
223
|
+
else: # QPS has not started loading a recording.
|
224
|
+
if notLoadingMessageStartTime == None:
|
225
|
+
# Start a timer from now so that if loading doesn't take place between now and a timeout value,
|
226
|
+
# we exit, stating that no loading started within the desired time.
|
227
|
+
notLoadingMessageStartTime = time.time()
|
228
|
+
elif time.time() - notLoadingMessageStartTime> startOpenTimout:
|
229
|
+
message = "No detection that QPS started loading the recording within "+str(startOpenTimout)+"s."
|
230
|
+
break
|
231
|
+
|
232
|
+
time.sleep(pollInterval) #Sleep pollInterval time, so we are not hammering QPS for updates while its busy loading.
|
233
|
+
time.sleep(1) #sleep outside the loop as there is a
|
234
|
+
return message
|
235
|
+
|
236
|
+
|
185
237
|
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import platform # For getting the operating system name
|
2
|
+
import subprocess # For executing a shell command
|
3
|
+
|
4
|
+
from zeroconf import Zeroconf
|
5
|
+
|
6
|
+
|
7
|
+
def ping(host):
|
8
|
+
"""
|
9
|
+
Returns True if host (str) responds to a ping request.
|
10
|
+
"""
|
11
|
+
# Option for the number of packets as a function of
|
12
|
+
param = '-n' if platform.system().lower() == 'windows' else '-c'
|
13
|
+
|
14
|
+
# Building the command. Ex: "ping -c 1 google.com"
|
15
|
+
command = ['ping', param, '1', host]
|
16
|
+
|
17
|
+
# Execute the ping command and capture the output and return code
|
18
|
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
19
|
+
|
20
|
+
# Check the return code and output to determine the result
|
21
|
+
if result.returncode == 0 and ("destination host unreachable" not in str(result.stdout).lower()):
|
22
|
+
return True # Ping successful
|
23
|
+
else:
|
24
|
+
return False # Ping failed
|
25
|
+
|
26
|
+
|
27
|
+
class MyListener:
|
28
|
+
"""
|
29
|
+
MyListener class to handle service updates, removals, and additions in Zeroconf
|
30
|
+
"""
|
31
|
+
|
32
|
+
_instance = None
|
33
|
+
|
34
|
+
@classmethod
|
35
|
+
def get_instance(cls):
|
36
|
+
"""
|
37
|
+
Get an instance of MyListener class. If none exists, create one.
|
38
|
+
"""
|
39
|
+
if cls._instance is None:
|
40
|
+
cls._instance = MyListener()
|
41
|
+
return cls._instance
|
42
|
+
|
43
|
+
def __init__(self):
|
44
|
+
"""
|
45
|
+
Initialize MyListener instance.
|
46
|
+
"""
|
47
|
+
self.found_devices = {}
|
48
|
+
self.mdns_service_running = False
|
49
|
+
self.zeroconf = None
|
50
|
+
self.target_conn = None
|
51
|
+
|
52
|
+
def update_service(self, zc, type_, name):
|
53
|
+
"""
|
54
|
+
Handle service update event.
|
55
|
+
"""
|
56
|
+
info = zc.get_service_info(type_, name)
|
57
|
+
if "Quarch:" in str(info):
|
58
|
+
# decode the incoming properties from mdns
|
59
|
+
decoded_properties = {key.decode('utf-8'): value.decode('utf-8') for key, value in info.properties.items()}
|
60
|
+
decoded_ip = ".".join(str(byte) for byte in info.addresses[0])
|
61
|
+
self.get_instance().add_device(decoded_properties, decoded_ip)
|
62
|
+
|
63
|
+
def remove_service(self, zc, type_, name):
|
64
|
+
"""
|
65
|
+
Handle service removal event.
|
66
|
+
"""
|
67
|
+
return None
|
68
|
+
|
69
|
+
def add_service(self, zc, type_, name):
|
70
|
+
"""
|
71
|
+
Handle service addition event.
|
72
|
+
"""
|
73
|
+
info = zc.get_service_info(type_, name)
|
74
|
+
if "Quarch:" in str(info):
|
75
|
+
# decode the incoming properties from mdns
|
76
|
+
decoded_properties = {key.decode('utf-8'): value.decode('utf-8') for key, value in info.properties.items()}
|
77
|
+
decoded_ip = ".".join(str(byte) for byte in info.addresses[0])
|
78
|
+
self.get_instance().add_device(decoded_properties, decoded_ip)
|
79
|
+
|
80
|
+
def add_device(self, properties_dict, ip_address):
|
81
|
+
"""
|
82
|
+
Add a device to the found devices dictionary.
|
83
|
+
"""
|
84
|
+
qtl_num = "QTL" + properties_dict['86'] if '86' in properties_dict else None
|
85
|
+
# Check if module contains REST connection
|
86
|
+
if '84' in properties_dict:
|
87
|
+
# Check the user specified connection type
|
88
|
+
if self.get_instance().target_conn == "all" or self.get_instance().target_conn == "rest":
|
89
|
+
if properties_dict['84'] == '80':
|
90
|
+
# print("Rest connection exists for device: " + qtl_num)
|
91
|
+
# Updates the found devices dict
|
92
|
+
self.get_instance().update_device_dict(device_dict={"REST:" + ip_address: qtl_num})
|
93
|
+
# Check if module contains TCP connection
|
94
|
+
if '85' in properties_dict:
|
95
|
+
# Check the user specified connection type
|
96
|
+
if self.get_instance().target_conn == "all" or self.get_instance().target_conn == "tcp":
|
97
|
+
if properties_dict['85'] == "9760":
|
98
|
+
# print("TCP connection exists for device: " + qtl_num)
|
99
|
+
# Updates the found devices dict
|
100
|
+
self.get_instance().update_device_dict(device_dict={"TCP:" + ip_address: qtl_num})
|
101
|
+
|
102
|
+
def update_device_dict(self, device_dict):
|
103
|
+
"""
|
104
|
+
Update the found devices dictionary.
|
105
|
+
"""
|
106
|
+
self.get_instance().found_devices.update(device_dict)
|
107
|
+
|
108
|
+
def get_found_devices(self):
|
109
|
+
"""
|
110
|
+
Get the found devices and perform ping check.
|
111
|
+
"""
|
112
|
+
temp_dict = self.get_instance().found_devices
|
113
|
+
for key, value in list(temp_dict.items()):
|
114
|
+
result = ping(key[key.index(":") + 1:])
|
115
|
+
if not result or self.get_instance().target_conn not in key.lower():
|
116
|
+
del self.get_instance().found_devices[key]
|
117
|
+
print(str(self.get_instance().found_devices))
|
118
|
+
return self.get_instance().found_devices
|
119
|
+
|
120
|
+
def get_zeroconf(self):
|
121
|
+
"""
|
122
|
+
Get the Zeroconf instance. If none exists, create one.
|
123
|
+
"""
|
124
|
+
if self.get_instance().zeroconf is None:
|
125
|
+
self.get_instance().zeroconf = Zeroconf()
|
126
|
+
return self.get_instance().zeroconf
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
quarchpy/debug/SystemTest.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
from quarchpy import *
|
2
|
+
from quarchpy.device import *
|
3
3
|
try:
|
4
4
|
from importlib.metadata import distribution
|
5
5
|
except:
|
@@ -7,11 +7,7 @@ except:
|
|
7
7
|
from importlib_metadata import distribution
|
8
8
|
except Exception as e:
|
9
9
|
print("Failed to import distribution from importlib_metadata")
|
10
|
-
try:
|
11
10
|
|
12
|
-
from importlib_metadata import distribution
|
13
|
-
except:
|
14
|
-
print("here")
|
15
11
|
import os
|
16
12
|
import platform
|
17
13
|
import sys
|
@@ -0,0 +1,200 @@
|
|
1
|
+
from quarchpy import *
|
2
|
+
from quarchpy.device import *
|
3
|
+
try:
|
4
|
+
from importlib.metadata import distribution
|
5
|
+
except:
|
6
|
+
try:
|
7
|
+
from importlib_metadata import distribution
|
8
|
+
except Exception as e:
|
9
|
+
print("Failed to import distribution from importlib_metadata")
|
10
|
+
|
11
|
+
import os
|
12
|
+
import platform
|
13
|
+
import sys
|
14
|
+
import subprocess
|
15
|
+
from quarchpy._version import __version__
|
16
|
+
|
17
|
+
def test_communication():
|
18
|
+
print("")
|
19
|
+
print("DEVICE COMMUNICATION TEST")
|
20
|
+
print("-------------------------")
|
21
|
+
print("")
|
22
|
+
deviceList = scanDevices('all', favouriteOnly=False)
|
23
|
+
print("Devices visible:\r\n" + str(deviceList))
|
24
|
+
print("")
|
25
|
+
moduleStr = userSelectDevice(deviceList, nice=True, additionalOptions=["Rescan", "Quit", "All Conn Types"])
|
26
|
+
if moduleStr == "quit":
|
27
|
+
print("User selected quit")
|
28
|
+
return 0
|
29
|
+
print("Selected module is: " + moduleStr)
|
30
|
+
# Create a device using the module connection string
|
31
|
+
myDevice = getQuarchDevice(moduleStr)
|
32
|
+
QuarchSimpleIdentify(myDevice)
|
33
|
+
# Close the module before exiting the script
|
34
|
+
myDevice.closeConnection()
|
35
|
+
|
36
|
+
def test_system_info():
|
37
|
+
print("")
|
38
|
+
print("SYSTEM INFORMATION")
|
39
|
+
print("------------------")
|
40
|
+
print("OS Name: " + os.name)
|
41
|
+
print("Platform System: " + platform.system())
|
42
|
+
print("Platform: " + platform.platform())
|
43
|
+
|
44
|
+
if "nt" in os.name:
|
45
|
+
print("Platform Architecture: " + platform.architecture()[0])
|
46
|
+
else:
|
47
|
+
print(str(bytes(subprocess.check_output(['cat', '/etc/os-release'], stderr=subprocess.STDOUT)).decode()))
|
48
|
+
print("Platform Release: " + platform.release())
|
49
|
+
|
50
|
+
try:
|
51
|
+
print("Quarchpy Version: " + get_quarchpy_version())
|
52
|
+
except:
|
53
|
+
print("Unable to detect Quarchpy version")
|
54
|
+
try:
|
55
|
+
print("Quarchpy info Location: " + str(distribution("quarchpy")._path))
|
56
|
+
except Exception as e:
|
57
|
+
print(e)
|
58
|
+
print("Unable to detect Quarchpy location")
|
59
|
+
try:
|
60
|
+
print("Python Version: " + sys.version)
|
61
|
+
except:
|
62
|
+
print("Unable to detect Python version")
|
63
|
+
try:
|
64
|
+
print("QIS version number: " + get_QIS_version())
|
65
|
+
except:
|
66
|
+
print("Unable to detect QIS version")
|
67
|
+
try:
|
68
|
+
javaVersion = bytes(subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT)).decode()
|
69
|
+
print("Java Version: " + str(javaVersion))
|
70
|
+
except:
|
71
|
+
print("Unable to detect java version"
|
72
|
+
"If Java is not installed then QIS and QPS will NOT run")
|
73
|
+
try:
|
74
|
+
javaLocation = get_java_location()
|
75
|
+
print("Java Location: " + str(javaLocation))
|
76
|
+
except:
|
77
|
+
print("Unable to detect java location"
|
78
|
+
"If Java is not installed then QIS and QPS will NOT run")
|
79
|
+
|
80
|
+
# Scan for all quarch devices on the system
|
81
|
+
|
82
|
+
def QuarchSimpleIdentify(device1):
|
83
|
+
"""
|
84
|
+
Prints basic identification test data on the specified module, compatible with all Quarch devices
|
85
|
+
|
86
|
+
Parameters
|
87
|
+
----------
|
88
|
+
device1: quarchDevice
|
89
|
+
Open connection to a quarch device
|
90
|
+
|
91
|
+
"""
|
92
|
+
# Print the module name
|
93
|
+
print("MODULE IDENTIFY TEST")
|
94
|
+
print("--------------------")
|
95
|
+
print("")
|
96
|
+
print("Module Name: "),
|
97
|
+
print(device1.sendCommand("hello?"))
|
98
|
+
print("")
|
99
|
+
# Print the module identify and version information
|
100
|
+
print("Module Identity Information: ")
|
101
|
+
print(device1.sendCommand("*idn?"))
|
102
|
+
|
103
|
+
def get_QIS_version():
|
104
|
+
"""
|
105
|
+
Returns the version of QIS. This is the version of QIS currenty running on the local system if one exists.
|
106
|
+
Otherwise the local version within quarchpy will be exectued and its version returned.
|
107
|
+
|
108
|
+
Returns
|
109
|
+
-------
|
110
|
+
version: str
|
111
|
+
String representation of the QIS version number
|
112
|
+
|
113
|
+
"""
|
114
|
+
|
115
|
+
qis_version = ""
|
116
|
+
my_close_qis = False
|
117
|
+
if isQisRunning() == False:
|
118
|
+
my_close_qis = True
|
119
|
+
startLocalQis(headless=True)
|
120
|
+
|
121
|
+
myQis = qisInterface()
|
122
|
+
qis_version = myQis.sendAndReceiveCmd(cmd="$version")
|
123
|
+
if "No Target Device Specified" in qis_version:
|
124
|
+
qis_version = myQis.sendAndReceiveCmd(cmd="$help").split("\r\n")[0]
|
125
|
+
if my_close_qis:
|
126
|
+
myQis.sendAndReceiveCmd(cmd = "$shutdown")
|
127
|
+
return qis_version
|
128
|
+
|
129
|
+
def get_java_location():
|
130
|
+
"""
|
131
|
+
Returns the location of java.
|
132
|
+
|
133
|
+
Returns
|
134
|
+
-------
|
135
|
+
location: str
|
136
|
+
String representation of the java location.
|
137
|
+
"""
|
138
|
+
if "windows" in platform.platform().lower():
|
139
|
+
location = bytes(subprocess.check_output(['where', 'java'], stderr=subprocess.STDOUT)).decode()
|
140
|
+
elif "linux" in platform.platform().lower():
|
141
|
+
location = bytes(subprocess.check_output(['whereis', 'java'], stderr=subprocess.STDOUT)).decode()
|
142
|
+
else:
|
143
|
+
location = "Unable to detect OS to check java version."
|
144
|
+
return location
|
145
|
+
|
146
|
+
def get_quarchpy_version():
|
147
|
+
try:
|
148
|
+
return __version__
|
149
|
+
except:
|
150
|
+
return "Unknown"
|
151
|
+
|
152
|
+
def fix_usb():
|
153
|
+
content_to_write = "SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"16d0\", MODE=\"0666\"" \
|
154
|
+
"SUBSYSTEM==\"usb_device\", ATTRS{idVendor}==\"16d0\", MODE=\"0666\""
|
155
|
+
|
156
|
+
if "centos" in str(platform.platform()).lower():
|
157
|
+
content_to_write = "SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"16d0\", MODE=\"0666\", GROUP=*\n " \
|
158
|
+
"SUBSYSTEM==\"usb_device\", ATTRS{idVendor}==\"16d0\", MODE=\"0666\", GROUP=*"
|
159
|
+
|
160
|
+
destination = "/etc/udev/rules.d/20-quarchmodules.rules"
|
161
|
+
|
162
|
+
f = open("/etc/udev/rules.d/20-quarchmodules.rules", "w")
|
163
|
+
f.write(content_to_write)
|
164
|
+
f.close()
|
165
|
+
|
166
|
+
os.system("udevadm control --reload")
|
167
|
+
os.system("udevadm trigger")
|
168
|
+
|
169
|
+
print("USB rule added to file : /etc/udev/rules.d/20-quarchmodules.rules")
|
170
|
+
|
171
|
+
|
172
|
+
def main (args=None):
|
173
|
+
"""
|
174
|
+
Main function to allow the system test to be called direct from the command line
|
175
|
+
"""
|
176
|
+
bool_test_system_info = True
|
177
|
+
bool_test_communication = True
|
178
|
+
bool_fixusb=False
|
179
|
+
if args is not None and len(args)>0:
|
180
|
+
for arg in args:
|
181
|
+
if "--fixusb" in str(arg).lower():
|
182
|
+
bool_fixusb=True
|
183
|
+
# todo: Should we still be running the debug info stuff after this?
|
184
|
+
if "--skipsysteminfo" in str(arg).lower():
|
185
|
+
bool_test_system_info=False
|
186
|
+
if "--skipcommstest" in str(arg).lower():
|
187
|
+
bool_test_communication=False
|
188
|
+
|
189
|
+
if bool_fixusb:
|
190
|
+
fix_usb()
|
191
|
+
if bool_test_system_info:
|
192
|
+
test_system_info()
|
193
|
+
if bool_test_communication:
|
194
|
+
test_communication()
|
195
|
+
|
196
|
+
|
197
|
+
if __name__ == "__main__":
|
198
|
+
main([])
|
199
|
+
#main(["--skipSystemInfo","--skipCommsTest"])
|
200
|
+
#main(["--fixusb"])
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|