happyscript 0.0.51__tar.gz → 0.0.53__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {happyscript-0.0.51 → happyscript-0.0.53}/PKG-INFO +1 -1
  2. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/__init__.py +1 -1
  3. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/panels/panel_log.py +3 -0
  4. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptcontrol.py +12 -2
  5. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptparams.py +11 -5
  6. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptrunner.py +14 -6
  7. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/testlog/global_log_handler.py +2 -0
  8. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript.egg-info/PKG-INFO +1 -1
  9. {happyscript-0.0.51 → happyscript-0.0.53}/pyproject.toml +1 -1
  10. {happyscript-0.0.51 → happyscript-0.0.53}/README.md +0 -0
  11. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/__init__.py +0 -0
  12. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/chart.py +0 -0
  13. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/histogram_chart.py +0 -0
  14. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/histogram_series.py +0 -0
  15. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/matplotlib_chart.py +0 -0
  16. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/panel_charts.py +0 -0
  17. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/scatter_chart.py +0 -0
  18. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/scatter_series.py +0 -0
  19. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/time_chart.py +0 -0
  20. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/charts/time_series.py +0 -0
  21. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/form_askchoice.py +0 -0
  22. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/form_askimage.py +0 -0
  23. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/form_main.py +0 -0
  24. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/form_ontestfailure.py +0 -0
  25. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/form_serials.py +0 -0
  26. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/form_settings.py +0 -0
  27. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/form_stop.py +0 -0
  28. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/forms/formsbase.py +0 -0
  29. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/imglib.py +0 -0
  30. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/inifile.py +0 -0
  31. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/modulereader.py +0 -0
  32. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/panels/panel_messages.py +0 -0
  33. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/panels/panel_scripts2.py +0 -0
  34. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/panels/panel_tests.py +0 -0
  35. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/panels/panelsbase.py +0 -0
  36. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptartwork.py +0 -0
  37. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptexceptions.py +0 -0
  38. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptgui.py +0 -0
  39. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptinfo.py +0 -0
  40. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptmanager.py +0 -0
  41. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/scriptreader.py +0 -0
  42. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/splashmenu/exit.png +0 -0
  43. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/splashmenu/forms.py +0 -0
  44. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/splashmenu/splashmenuform.py +0 -0
  45. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/splashmenu/splashmenumain.py +0 -0
  46. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/staticscriptmanager.py +0 -0
  47. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/testlog/log_to_text.py +0 -0
  48. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/testlog/logtoxml.py +0 -0
  49. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/testlog/printredirect.py +0 -0
  50. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/testloghandler.py +0 -0
  51. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/userpanel/userpanel.py +0 -0
  52. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript/userpanel/userpanelvalue.py +0 -0
  53. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript.egg-info/SOURCES.txt +0 -0
  54. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript.egg-info/dependency_links.txt +0 -0
  55. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript.egg-info/requires.txt +0 -0
  56. {happyscript-0.0.51 → happyscript-0.0.53}/happyscript.egg-info/top_level.txt +0 -0
  57. {happyscript-0.0.51 → happyscript-0.0.53}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: happyscript
3
- Version: 0.0.51
3
+ Version: 0.0.53
4
4
  Summary: Framework for running scripts
5
5
  Requires-Python: >=3.5
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  """HappyScript - handy script launcher"""
2
2
 
3
- __version__ = "0.0.51"
3
+ __version__ = "0.0.53"
4
4
 
5
5
  # With these statements, after doing 'import happyscript' you can do 'xxx = happyscript.ScriptManager()'
6
6
  #from .scriptmanager import ScriptManager
@@ -55,6 +55,9 @@ class PanelLog( PanelLog_Base ):
55
55
  self.wx_txtLog.AppendText(logdata.msg+"\r\n")
56
56
 
57
57
  if logdata.exc_info is not None:
58
+ # with open("log_exception.txt", "w") as f:
59
+ # import traceback
60
+ # traceback.print_stack(file=f)
58
61
  self.wx_txtLog.AppendText(logdata.exc_info)
59
62
 
60
63
  def OnSelectLogLevel( self, event ):
@@ -95,7 +95,17 @@ class ScriptControl:
95
95
  assert self._script_runner is not None, "Internal error: scriptrunner is not set"
96
96
  return self._script_runner.run_script(script_name, **argv)
97
97
 
98
- def run_parallel(self, func, parname, parvalues, **extra_params):
98
+ def do(self, script_name:str, **argv) -> str:
99
+ ''' Similar to run(), but doesn't throw an exception. Instead, it returns the error
100
+ message if an error occurs, or None if the script runs successfully.
101
+ '''
102
+ try:
103
+ self.run(script_name, **argv)
104
+ return None
105
+ except Exception as e:
106
+ return str(e)
107
+
108
+ def do_parallel(self, func:str, parname:str, parvalues:list, **extra_params) -> list[str]:
99
109
  ''' excecute a function in parallel using different values for a given parameter
100
110
  '''
101
- return self._script_runner.run_parallel(func, parname, parvalues, **extra_params)
111
+ return self._script_runner.do_parallel(func, parname, parvalues, **extra_params)
@@ -67,9 +67,12 @@ class ScriptParams(object):
67
67
  return None
68
68
 
69
69
  def get_parameters(self, scriptObject, extraParams=None):
70
- ''' Executes a script function provided by a script treeview panel.
70
+ ''' Investigates which parameters a function needs, and returns a list of values for these parameters.
71
+ Parameter names should match the names of objects added to the script manager.
72
+ Additional parameters can be provided; they will override any existing objects with the same name
73
+ (except for the reserved names 'mngr', 'ctrl', 'gui', 'info' which are always taken from the script manager).
71
74
 
72
- @param scriptObject : the function to execute, as an object
75
+ @param scriptObject : the function to analyze, as an object
73
76
  @param extraParams : dictionary of extra parameters that may be passed to the test function
74
77
  '''
75
78
 
@@ -80,12 +83,15 @@ class ScriptParams(object):
80
83
  argnames = inspect.getfullargspec(scriptObject)[0] # get list of arguments
81
84
  doctxt = inspect.getdoc( scriptObject ) # comment for the function
82
85
  argvalues = list()
86
+
83
87
  for x in argnames:
84
- if x in self.argumentList:
88
+ if x in ["mngr", "ctrl", "gui", "info" ]: # these are reserved names for happyscript built-in objects
85
89
  argvalues.append( self.argumentList[x] )
86
- elif x in extraParams:
90
+ elif x in extraParams: # if parameter provided in extraParams, take that first
87
91
  argvalues.append( extraParams[x] )
88
- elif self._ask_gui is not None:
92
+ elif x in self.argumentList: # otherwise look in added objects
93
+ argvalues.append( self.argumentList[x] )
94
+ elif self._ask_gui is not None: # if still not found, maybe they must be asked from the operator
89
95
  argvalues.append( self._find_missing_parameter(x, doctxt) )
90
96
  else:
91
97
  argvalues.append( None )
@@ -68,7 +68,9 @@ class ScriptThreadRunner:
68
68
  if self._ctrl.m_stop_script:
69
69
  self.logger.error("Script stopped by user")
70
70
  else:
71
- logging.error(str(e), exc_info = e)
71
+ logging.error(str(e))
72
+ logging.debug("", exc_info = e)
73
+ # logging.error(str(e), exc_info = e)
72
74
  finally:
73
75
  self._recurse_count -= 1 # keep track of script recursion counter
74
76
  if self._recurse_count<=0:
@@ -104,7 +106,7 @@ class ScriptParallelThread(threading.Thread):
104
106
  self.arg_list = arg_list
105
107
  self.success = False
106
108
  self.stopped_by_user = False
107
- # self.exc = None
109
+ self.error_msg = None
108
110
  self.start()
109
111
 
110
112
  def run(self):
@@ -119,8 +121,9 @@ class ScriptParallelThread(threading.Thread):
119
121
  if self._ctrl.m_stop_script:
120
122
  self.stopped_by_user = True
121
123
  else:
122
- logging.error(str(e), exc_info = e)
123
- # self.exc = e
124
+ self.error_msg = str(e)
125
+ logging.error(self.error_msg)
126
+ logging.debug("", exc_info = e)
124
127
 
125
128
 
126
129
  class ScriptRunner:
@@ -190,7 +193,7 @@ class ScriptRunner:
190
193
  self.thread_runner.execute_script(script_name, func, argvalues)
191
194
  self.start_ok = True
192
195
 
193
- def run_parallel(self, func, parname, parvalues, **extra_params):
196
+ def do_parallel(self, func, parname, parvalues, **extra_params):
194
197
  ''' Run a method in parallel, supplying different values to the given parameter.
195
198
  '''
196
199
  assert threading.currentThread().getName()=="ScriptThread", "run_parallel() can only be executed from within a (non-parallel) script function"
@@ -212,15 +215,20 @@ class ScriptRunner:
212
215
 
213
216
  fail_count = 0
214
217
  stopped_by_user = 0
218
+ error_list = list()
215
219
  for thread in threads: # wait for all the threats to finish
216
220
  thread.join()
217
221
  if not thread.success: # count how many failed
218
222
  fail_count += 1
219
223
  if thread.stopped_by_user: # count how many have been manually stopped
220
224
  stopped_by_user += 1
225
+ error_list.append(thread.error_msg)
221
226
 
222
227
  if stopped_by_user>0:
223
228
  self.logger.error(f"{stopped_by_user} scripts stopped by user")
224
- assert fail_count==0, f"Parallel executiong failed on {fail_count} threads"
229
+ # assert fail_count==0, f"Parallel executiong failed on {fail_count} threads"
230
+ return error_list
231
+
232
+
225
233
 
226
234
 
@@ -80,6 +80,7 @@ class GlobalLogHandler(logging.StreamHandler):
80
80
  if record.exc_info and str(record.exc_info[1])!="'Stopping parent script...'":
81
81
  exc_info = None
82
82
  tb = traceback.format_exception(record.exc_info[0], record.exc_info[1], record.exc_info[2])
83
+
83
84
  for line in tb[:-1 or None]:
84
85
  if line.startswith("Traceback "):
85
86
  continue
@@ -90,6 +91,7 @@ class GlobalLogHandler(logging.StreamHandler):
90
91
  exc_info = line
91
92
  else:
92
93
  exc_info += "\r\n" + line
94
+
93
95
  data.exc_info = exc_info
94
96
 
95
97
  self._queue.put(data) # put log on queue for later processing
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: happyscript
3
- Version: 0.0.51
3
+ Version: 0.0.53
4
4
  Summary: Framework for running scripts
5
5
  Requires-Python: >=3.5
6
6
  Description-Content-Type: text/markdown
@@ -20,7 +20,7 @@ build-backend = "setuptools.build_meta"
20
20
  [project]
21
21
  name = "happyscript"
22
22
  description = "Framework for running scripts"
23
- version = "0.0.51"
23
+ version = "0.0.53"
24
24
  readme = "README.md"
25
25
  requires-python = ">=3.5"
26
26
  dependencies = [ "wxpython", "numpy" ]
File without changes
File without changes