happyscript 0.0.8__tar.gz → 0.0.10__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.
- {happyscript-0.0.8 → happyscript-0.0.10}/PKG-INFO +1 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/__init__.py +1 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/forms/form_main.py +3 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/panels/panel_log.py +3 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/panels/panel_messages.py +3 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/panels/panel_tests.py +2 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptcontrol.py +8 -11
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptgui.py +15 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptmanager.py +3 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptparams.py +1 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptrunner.py +64 -17
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript.egg-info/PKG-INFO +1 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/pyproject.toml +1 -1
- {happyscript-0.0.8 → happyscript-0.0.10}/README.md +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/copy_code.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/__init__.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/chart.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/histogram_chart.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/histogram_series.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/matplotlib_chart.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/panel_charts.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/scatter_chart.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/scatter_series.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/time_chart.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/charts/time_series.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/forms/form_askchoice.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/forms/form_askimage.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/forms/form_ontestfailure.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/forms/form_serials.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/forms/form_stop.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/forms/formsbase.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/imglib.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/panels/panel_scripts2.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/panels/panelsbase.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptartwork.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptexceptions.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptinfo.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/scriptreader.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/testlog/global_log_handler.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/testlog/log_to_text.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/testlog/logtoxml.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript/testlog/printredirect.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript.egg-info/SOURCES.txt +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript.egg-info/dependency_links.txt +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/happyscript.egg-info/top_level.txt +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/increment_version.py +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/publish.bat +0 -0
- {happyscript-0.0.8 → happyscript-0.0.10}/setup.cfg +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.10"
|
|
2
2
|
from .scriptmanager import ScriptManager
|
|
@@ -10,8 +10,10 @@ class PanelLog( PanelLog_Base ):
|
|
|
10
10
|
self.first_time_in_commandline = True
|
|
11
11
|
self.loglevel = logging.INFO
|
|
12
12
|
self._stop_log = False
|
|
13
|
-
def
|
|
13
|
+
def clear(self):
|
|
14
14
|
self.wx_txtLog.Clear()
|
|
15
|
+
def OnBtnClearLog( self, event ):
|
|
16
|
+
self.clear()
|
|
15
17
|
def HandleLog(self, logdata):
|
|
16
18
|
if logdata.levelno < self.loglevel:
|
|
17
19
|
return
|
|
@@ -11,6 +11,8 @@ class PanelMessages( PanelMessages_Base ):
|
|
|
11
11
|
self.lstMessages.SetColumnWidth(1, 70)
|
|
12
12
|
self.lstMessages.SetColumnWidth(2, 100)
|
|
13
13
|
self.loglevel = logging.WARN+1
|
|
14
|
+
def clear(self):
|
|
15
|
+
self.lstMessages.DeleteAllItems()
|
|
14
16
|
def OnListSize( self, event ):
|
|
15
17
|
width = self.GetClientSize().width
|
|
16
18
|
if width<160:
|
|
@@ -40,7 +42,7 @@ class PanelMessages( PanelMessages_Base ):
|
|
|
40
42
|
self.lstMessages.EnsureVisible(cnt - 1)
|
|
41
43
|
self.lstMessages.Update()
|
|
42
44
|
def OnBtnClearList( self, event ):
|
|
43
|
-
self.
|
|
45
|
+
self.clear()
|
|
44
46
|
def OnSelectLogLevel( self, event ):
|
|
45
47
|
sel = self.m_cboLogLevel.GetStringSelection().lower()
|
|
46
48
|
if sel=="warning":
|
|
@@ -237,12 +237,13 @@ class PanelTests( PanelTests_Base):
|
|
|
237
237
|
num_fails = sum( 1 for x in self.tests if not x.passed)
|
|
238
238
|
if num_fails==0:
|
|
239
239
|
self.m_txtStatus.Label = "All test OK"
|
|
240
|
+
self.m_txtStatus.SetForegroundColour(wx.Colour( 0, 128, 0 ))
|
|
240
241
|
elif num_fails==1:
|
|
241
242
|
self.m_txtStatus.Label = "1 test failed !"
|
|
242
243
|
self.m_txtStatus.SetForegroundColour(wx.RED)
|
|
243
244
|
else:
|
|
244
245
|
self.m_txtStatus.Label = "%d tests failed !" % num_fails
|
|
245
|
-
|
|
246
|
+
self.m_txtStatus.SetForegroundColour(wx.RED)
|
|
246
247
|
self.state = RunState.IDLE
|
|
247
248
|
self.m_btnStart.Enabled = True
|
|
248
249
|
self.m_btnStop.Enabled = False
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import wx
|
|
2
1
|
import time
|
|
3
2
|
from .scriptexceptions import ScriptUserAbortException
|
|
4
3
|
class ScriptControl:
|
|
5
4
|
def __init__(self):
|
|
6
5
|
self.m_stop_script = False
|
|
7
6
|
self._is_busy = False
|
|
8
|
-
self.
|
|
7
|
+
self._script_runner = None
|
|
8
|
+
def set_script_runner(self, runner):
|
|
9
|
+
self._script_runner = runner
|
|
9
10
|
def set_busy(self, is_busy):
|
|
10
11
|
self._is_busy = is_busy
|
|
11
12
|
self.m_stop_script = False
|
|
@@ -18,26 +19,22 @@ class ScriptControl:
|
|
|
18
19
|
print("Normally no script is active, but I'll set the 'stop' flag anyway.")
|
|
19
20
|
self.m_stop_script = True
|
|
20
21
|
def ok(self):
|
|
21
|
-
wx.Yield()
|
|
22
22
|
return not self.m_stop_script
|
|
23
23
|
def check(self):
|
|
24
|
-
wx.Yield()
|
|
25
24
|
if self.m_stop_script:
|
|
26
25
|
raise ScriptUserAbortException( "Script stopping on user request" )
|
|
27
26
|
def sleep(self, time_in_seconds):
|
|
28
27
|
t = time_in_seconds
|
|
29
|
-
wx.Yield()
|
|
30
28
|
while t>0:
|
|
31
29
|
if t > 0.5:
|
|
32
30
|
time.sleep(0.5)
|
|
33
31
|
else:
|
|
34
32
|
time.sleep(t)
|
|
35
|
-
t = t-0.5
|
|
36
|
-
wx.Yield()
|
|
33
|
+
t = t-0.5
|
|
37
34
|
if self.m_stop_script:
|
|
38
35
|
raise ScriptUserAbortException( "Script stopping on user request" )
|
|
39
36
|
def run(self, script_name, **argv):
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
assert self._script_runner is not None, "Internal error: scriptrunner is not set"
|
|
38
|
+
return self._script_runner.run_script(script_name, **argv)
|
|
39
|
+
def run_parallel(self, func, parname, parvalues, **extra_params):
|
|
40
|
+
return self._script_runner.run_parallel(func, parname, parvalues, **extra_params)
|
|
@@ -29,6 +29,7 @@ class ScriptGui:
|
|
|
29
29
|
raise self.__reply
|
|
30
30
|
return self.__reply
|
|
31
31
|
def do_func(self, func, *params):
|
|
32
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
32
33
|
if func is None or not callable(func):
|
|
33
34
|
raise Exception("Given function to execute is not something callable.")
|
|
34
35
|
if threading.currentThread().getName()=="ScriptThread":
|
|
@@ -36,6 +37,7 @@ class ScriptGui:
|
|
|
36
37
|
else:
|
|
37
38
|
return func(*params)
|
|
38
39
|
def ask(self, message, default_value="" ):
|
|
40
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
39
41
|
if threading.currentThread().getName()=="ScriptThread":
|
|
40
42
|
return self.__run_with_timer(self.ask, message, default_value )
|
|
41
43
|
result = None
|
|
@@ -47,6 +49,7 @@ class ScriptGui:
|
|
|
47
49
|
raise ScriptUserAbortException( "User did not provide value in dialog" )
|
|
48
50
|
return result
|
|
49
51
|
def ask_number(self, message, default_value=None ):
|
|
52
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
50
53
|
if threading.currentThread().getName()=="ScriptThread":
|
|
51
54
|
return self.__run_with_timer(self.ask_number, message, default_value )
|
|
52
55
|
result = None
|
|
@@ -69,6 +72,7 @@ class ScriptGui:
|
|
|
69
72
|
raise ScriptUserAbortException( "User did not provide value in dialog" )
|
|
70
73
|
return result
|
|
71
74
|
def ask_yesno(self, message, cancel = False):
|
|
75
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
72
76
|
if threading.currentThread().getName()=="ScriptThread":
|
|
73
77
|
return self.__run_with_timer(self.ask_yesno, message, cancel )
|
|
74
78
|
style = wx.YES_NO|wx.CANCEL if cancel else wx.YES_NO
|
|
@@ -81,6 +85,7 @@ class ScriptGui:
|
|
|
81
85
|
return False
|
|
82
86
|
raise ScriptUserAbortException( "User did not answer yes/no dialog" )
|
|
83
87
|
def ask_image(self, message, filename, arrow_pos=None, yesno=False, cancel=False, numeric=False):
|
|
88
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
84
89
|
if threading.currentThread().getName()=="ScriptThread":
|
|
85
90
|
return self.__run_with_timer(self.ask_image, message, filename, arrow_pos, yesno, cancel, numeric )
|
|
86
91
|
form = FormAskImage(message, filename, arrow_pos, yesno, cancel, numeric )
|
|
@@ -91,6 +96,7 @@ class ScriptGui:
|
|
|
91
96
|
form.Destroy()
|
|
92
97
|
return result
|
|
93
98
|
def ask_choice(self, message, choices, do_assert = True):
|
|
99
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
94
100
|
if threading.currentThread().getName()=="ScriptThread":
|
|
95
101
|
return self.__run_with_timer(self.ask_choice, message, choices )
|
|
96
102
|
form = FormAskChoice(message, choices )
|
|
@@ -102,6 +108,7 @@ class ScriptGui:
|
|
|
102
108
|
form.Destroy()
|
|
103
109
|
return result
|
|
104
110
|
def ask_open_file(self, message, wildcard):
|
|
111
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
105
112
|
if threading.currentThread().getName() == "ScriptThread":
|
|
106
113
|
return self.__run_with_timer(self.ask_open_file, message, wildcard)
|
|
107
114
|
style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
|
|
@@ -111,6 +118,7 @@ class ScriptGui:
|
|
|
111
118
|
return None
|
|
112
119
|
return dlg.GetPath()
|
|
113
120
|
def show_stop_dialog(self, message=None ):
|
|
121
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
114
122
|
if threading.currentThread().getName() == "ScriptThread":
|
|
115
123
|
return self.__run_with_timer(self.show_stop_dialog, message)
|
|
116
124
|
if message is None:
|
|
@@ -121,6 +129,7 @@ class ScriptGui:
|
|
|
121
129
|
self.m_stop_dialog.update_message(message)
|
|
122
130
|
self.m_stop_dialog.Show()
|
|
123
131
|
def close_stop_dialog(self):
|
|
132
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
124
133
|
if self.m_stop_dialog is None:
|
|
125
134
|
return
|
|
126
135
|
if threading.currentThread().getName() == "ScriptThread":
|
|
@@ -128,24 +137,30 @@ class ScriptGui:
|
|
|
128
137
|
self.m_stop_dialog.Destroy()
|
|
129
138
|
self.m_stop_dialog = None
|
|
130
139
|
def add_scatter_chart(self, name):
|
|
140
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
131
141
|
if threading.currentThread().getName() == "ScriptThread":
|
|
132
142
|
return self.__run_with_timer(self.add_scatter_chart, name)
|
|
133
143
|
return self._mngr.charts.add_scatter_chart(name)
|
|
134
144
|
def add_time_chart(self, name):
|
|
145
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
135
146
|
if threading.currentThread().getName() == "ScriptThread":
|
|
136
147
|
return self.__run_with_timer(self.add_time_chart, name)
|
|
137
148
|
return self._mngr.charts.add_time_chart(name)
|
|
138
149
|
def add_histogram(self, name, binsize):
|
|
150
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
139
151
|
if threading.currentThread().getName() == "ScriptThread":
|
|
140
152
|
return self.__run_with_timer(self.add_histogram, name, binsize)
|
|
141
153
|
return self._mngr.charts.add_histogram(name, binsize)
|
|
142
154
|
def add_matplotlib(self, name):
|
|
155
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
143
156
|
if threading.currentThread().getName() == "ScriptThread":
|
|
144
157
|
return self.__run_with_timer(self.add_matplotlib, name)
|
|
145
158
|
return self._mngr.charts.add_matplotlib(name)
|
|
146
159
|
def get_chart(self, name):
|
|
160
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
147
161
|
return self._mngr.charts.get_chart(name)
|
|
148
162
|
def delete_chart(self, name):
|
|
163
|
+
assert not threading.currentThread().getName().startswith("Parallel"), "GUI functions cannot be called from a parallel thread"
|
|
149
164
|
if threading.currentThread().getName() == "ScriptThread":
|
|
150
165
|
return self.__run_with_timer(self.delete_chart, name)
|
|
151
166
|
self._mngr.charts.delete_chart(name)
|
|
@@ -63,7 +63,7 @@ class ScriptManager(object):
|
|
|
63
63
|
self._script_params.on_add_object = self._on_add_object
|
|
64
64
|
self._script_readers = dict()
|
|
65
65
|
self._script_runner = ScriptRunner(self._script_params, self._script_readers, self.ctrl)
|
|
66
|
-
self.ctrl.
|
|
66
|
+
self.ctrl.set_script_runner( self._script_runner )
|
|
67
67
|
self._script_params.add_objects( ctrl=self.ctrl, gui=self.gui, info=self.info )
|
|
68
68
|
self.dialog.pnlTests.on_sequence_start_callback = self.handle_batch_start
|
|
69
69
|
self.dialog.pnlTests.on_sequence_end_callback = self.handle_batch_end
|
|
@@ -96,6 +96,8 @@ class ScriptManager(object):
|
|
|
96
96
|
self.logfiles_defined = False
|
|
97
97
|
def stop_scripts(self):
|
|
98
98
|
self.ctrl.stop()
|
|
99
|
+
def clear_log(self):
|
|
100
|
+
self.dialog.ClearLogs()
|
|
99
101
|
def add_object(self, objName, theObject):
|
|
100
102
|
self._script_params.add_object( objName, theObject)
|
|
101
103
|
def add_objects(self, *args, **kwargs):
|
|
@@ -2,7 +2,7 @@ import datetime, logging, threading
|
|
|
2
2
|
from .scriptexceptions import ScriptUserAbortException
|
|
3
3
|
from .scriptexceptions import ScriptRecursiveAbortException
|
|
4
4
|
class ScriptThreadRunner:
|
|
5
|
-
logger = logging.getLogger("happyscript.
|
|
5
|
+
logger = logging.getLogger("happyscript.scriptrunner")
|
|
6
6
|
MARKER_LEVEL = 25
|
|
7
7
|
def __init__(self, ctrl):
|
|
8
8
|
self._ctrl = ctrl
|
|
@@ -56,6 +56,29 @@ class ScriptThreadRunner:
|
|
|
56
56
|
self.last_result = test_passed
|
|
57
57
|
self._ctrl.set_busy(False)
|
|
58
58
|
self.busy = False
|
|
59
|
+
class ScriptParallelThread(threading.Thread):
|
|
60
|
+
thread_counter = 0
|
|
61
|
+
def __init__(self, ctrl, func, arg_list):
|
|
62
|
+
thread_name = "Parallel" + str(ScriptParallelThread.thread_counter)
|
|
63
|
+
threading.Thread.__init__(self, name=thread_name)
|
|
64
|
+
ScriptParallelThread.thread_counter += 1
|
|
65
|
+
self._ctrl = ctrl
|
|
66
|
+
self.the_func = func
|
|
67
|
+
self.arg_list = arg_list
|
|
68
|
+
self.success = False
|
|
69
|
+
self.stopped_by_user = False
|
|
70
|
+
self.start()
|
|
71
|
+
def run(self):
|
|
72
|
+
try:
|
|
73
|
+
self.the_func( *self.arg_list )
|
|
74
|
+
self.success = True
|
|
75
|
+
except ScriptUserAbortException as _:
|
|
76
|
+
pass
|
|
77
|
+
except Exception as e:
|
|
78
|
+
if self._ctrl.m_stop_script:
|
|
79
|
+
self.stopped_by_user = True
|
|
80
|
+
else:
|
|
81
|
+
logging.error(str(e), exc_info = e)
|
|
59
82
|
class ScriptRunner:
|
|
60
83
|
logger = logging.getLogger("happyscript.runner")
|
|
61
84
|
def __init__(self, script_params, script_readers, script_control):
|
|
@@ -63,6 +86,7 @@ class ScriptRunner:
|
|
|
63
86
|
self._readers = script_readers
|
|
64
87
|
self._recurse_count = 0
|
|
65
88
|
self.start_ok = False
|
|
89
|
+
self._ctrl = script_control
|
|
66
90
|
self.thread_runner = ScriptThreadRunner(script_control)
|
|
67
91
|
@property
|
|
68
92
|
def test_passed(self):
|
|
@@ -70,29 +94,52 @@ class ScriptRunner:
|
|
|
70
94
|
@property
|
|
71
95
|
def busy(self):
|
|
72
96
|
return self.thread_runner.busy
|
|
73
|
-
def
|
|
97
|
+
def find_scriptfunct(self, script_name):
|
|
74
98
|
parts = script_name.split(".")
|
|
75
99
|
if len(parts) != 3:
|
|
76
100
|
self.logger.error("Must provide script name as dirname.filename.scriptname")
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if not group_name in self._readers:
|
|
83
|
-
self.logger.error("Cannot start %s : group %s not found" % (scriptname, group_name))
|
|
84
|
-
return
|
|
85
|
-
func = self._readers[group_name].get_func(filename, funcname)
|
|
101
|
+
return None
|
|
102
|
+
if not parts[0] in self._readers:
|
|
103
|
+
self.logger.error("Cannot start %s : group %s not found", script_name, parts[0])
|
|
104
|
+
return None
|
|
105
|
+
func = self._readers[parts[0]].get_func(parts[1], parts[2])
|
|
86
106
|
if func is None:
|
|
87
|
-
self.logger.error("Cannot start %s : function not found"
|
|
107
|
+
self.logger.error("Cannot start %s : function not found", script_name)
|
|
108
|
+
return func
|
|
109
|
+
def run_script(self, script_name, **extra_params):
|
|
110
|
+
self.start_ok = False
|
|
111
|
+
if threading.currentThread().getName().startswith("Parallel"):
|
|
112
|
+
self.logger.error("You cannot start other scripts in a parallel thread.")
|
|
88
113
|
return
|
|
89
|
-
|
|
90
|
-
|
|
114
|
+
func = self.find_scriptfunct(script_name)
|
|
115
|
+
if func is None: return
|
|
91
116
|
(argvalues, missing) = self.script_params.get_parameters(func, extra_params)
|
|
92
117
|
if len(missing)>0:
|
|
93
118
|
self.logger.error( "Error : missing value for parameter(s) %s" % ("".join(missing) ) )
|
|
94
|
-
self.logger.error( " Make sure to use valid names as parameters for your function.")
|
|
95
|
-
self.logger.log(self.MARKER_LEVEL, "\\_________%s_________ ERROR ______/" % scriptname )
|
|
96
119
|
return
|
|
97
|
-
self.thread_runner.execute_script(
|
|
120
|
+
self.thread_runner.execute_script(script_name, func, argvalues)
|
|
98
121
|
self.start_ok = True
|
|
122
|
+
def run_parallel(self, func, parname, parvalues, **extra_params):
|
|
123
|
+
assert threading.currentThread().getName()=="ScriptThread", "run_parallel() can only be executed from within a (non-parallel) script function"
|
|
124
|
+
if not callable(func):
|
|
125
|
+
func = self.find_scriptfunct(func)
|
|
126
|
+
assert func is not None, f"Parameter 'func' of run_parallel is no function or script name."
|
|
127
|
+
threads = list()
|
|
128
|
+
for val in parvalues:
|
|
129
|
+
extra_params[parname] = val
|
|
130
|
+
(argvalues, missing) = self.script_params.get_parameters(func, extra_params)
|
|
131
|
+
if len(missing)>0:
|
|
132
|
+
self.logger.error( "Error : missing value for parameter(s) %s" % ("".join(missing) ) )
|
|
133
|
+
return
|
|
134
|
+
threads.append( ScriptParallelThread(self._ctrl, func, argvalues) )
|
|
135
|
+
fail_count = 0
|
|
136
|
+
stopped_by_user = 0
|
|
137
|
+
for thread in threads:
|
|
138
|
+
thread.join()
|
|
139
|
+
if not thread.success:
|
|
140
|
+
fail_count += 1
|
|
141
|
+
if thread.stopped_by_user:
|
|
142
|
+
stopped_by_user += 1
|
|
143
|
+
if stopped_by_user>0:
|
|
144
|
+
self.logger.error(f"{stopped_by_user} scripts stopped by user")
|
|
145
|
+
assert fail_count==0, f"Parallel executiong failed on {fail_count} threads"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|