happyscript 0.0.6__tar.gz → 0.0.8__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 (48) hide show
  1. {happyscript-0.0.6 → happyscript-0.0.8}/PKG-INFO +1 -1
  2. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/__init__.py +1 -1
  3. happyscript-0.0.8/happyscript/charts/matplotlib_chart.py +82 -0
  4. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/panel_charts.py +10 -0
  5. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/forms/form_main.py +1 -0
  6. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptgui.py +4 -0
  7. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptinfo.py +24 -10
  8. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptmanager.py +3 -3
  9. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript.egg-info/PKG-INFO +1 -1
  10. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript.egg-info/SOURCES.txt +2 -0
  11. happyscript-0.0.8/publish.bat +6 -0
  12. {happyscript-0.0.6 → happyscript-0.0.8}/pyproject.toml +1 -1
  13. {happyscript-0.0.6 → happyscript-0.0.8}/README.md +0 -0
  14. {happyscript-0.0.6 → happyscript-0.0.8}/copy_code.py +0 -0
  15. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/__init__.py +0 -0
  16. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/chart.py +0 -0
  17. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/histogram_chart.py +0 -0
  18. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/histogram_series.py +0 -0
  19. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/scatter_chart.py +0 -0
  20. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/scatter_series.py +0 -0
  21. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/time_chart.py +0 -0
  22. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/charts/time_series.py +0 -0
  23. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/forms/form_askchoice.py +0 -0
  24. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/forms/form_askimage.py +0 -0
  25. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/forms/form_ontestfailure.py +0 -0
  26. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/forms/form_serials.py +0 -0
  27. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/forms/form_stop.py +0 -0
  28. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/forms/formsbase.py +0 -0
  29. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/imglib.py +0 -0
  30. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/panels/panel_log.py +0 -0
  31. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/panels/panel_messages.py +0 -0
  32. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/panels/panel_scripts2.py +0 -0
  33. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/panels/panel_tests.py +0 -0
  34. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/panels/panelsbase.py +0 -0
  35. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptartwork.py +0 -0
  36. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptcontrol.py +0 -0
  37. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptexceptions.py +0 -0
  38. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptparams.py +0 -0
  39. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptreader.py +0 -0
  40. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/scriptrunner.py +0 -0
  41. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/testlog/global_log_handler.py +0 -0
  42. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/testlog/log_to_text.py +0 -0
  43. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/testlog/logtoxml.py +0 -0
  44. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript/testlog/printredirect.py +0 -0
  45. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript.egg-info/dependency_links.txt +0 -0
  46. {happyscript-0.0.6 → happyscript-0.0.8}/happyscript.egg-info/top_level.txt +0 -0
  47. {happyscript-0.0.6 → happyscript-0.0.8}/increment_version.py +0 -0
  48. {happyscript-0.0.6 → happyscript-0.0.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: happyscript
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Framework for running scripts
5
5
  Requires-Python: >=3.5
6
6
  Description-Content-Type: text/markdown
@@ -1,2 +1,2 @@
1
- __version__ = "0.0.6"
1
+ __version__ = "0.0.8"
2
2
  from .scriptmanager import ScriptManager
@@ -0,0 +1,82 @@
1
+ import logging
2
+ import wx
3
+ try:
4
+ from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
5
+ from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
6
+ from matplotlib.figure import Figure
7
+ import matplotlib.pyplot as plt
8
+ HAVE_MATPLOTLIB = True
9
+ except ImportError:
10
+ HAVE_MATPLOTLIB = False
11
+ class MatPlotLibChart(wx.Panel):
12
+ def __init__(self, parent_control, name):
13
+ super().__init__(parent_control, -1)
14
+ self.__name = name
15
+ self.__dirty = False
16
+ self.__on_update_func = None
17
+ if not HAVE_MATPLOTLIB:
18
+ logging.error("Matplotlib is not installed.")
19
+ self.__figure = None
20
+ return
21
+ self.__figure = Figure(dpi=None, figsize=(2, 2))
22
+ self.__figure.set_tight_layout(True)
23
+ self.canvas = FigureCanvas(self, -1, self.__figure)
24
+ self.__toolbar = NavigationToolbar(self.canvas)
25
+ self.__toolbar.Realize()
26
+ sizer = wx.BoxSizer(wx.VERTICAL)
27
+ sizer.Add(self.canvas, 1, wx.EXPAND)
28
+ sizer.Add(self.__toolbar, 0, wx.LEFT | wx.EXPAND)
29
+ self.SetSizer(sizer)
30
+ @property
31
+ def name(self):
32
+ return self.__name
33
+ @property
34
+ def figure(self):
35
+ return self.__figure
36
+ def configure(self, /, x_label=None, y_label=None, title=None,
37
+ y_log=None, x_log=None, x_range=None, y_range=None):
38
+ if not HAVE_MATPLOTLIB: return
39
+ if title is not None and isinstance(title, str):
40
+ if len(self.figure.axes)>0:
41
+ self.figure.axes[0].set_title(title)
42
+ self.update()
43
+ @property
44
+ def on_update(self):
45
+ return self.__on_update_func
46
+ @on_update.setter
47
+ def on_update(self, value):
48
+ if value is None or callable(value):
49
+ self.__on_update_func = value
50
+ @property
51
+ def dirty(self):
52
+ return self.__dirty
53
+ def update(self, / , antialiasing=False):
54
+ if antialiasing:
55
+ logging.warn("Antialiasing not supported for matplotlib chart")
56
+ self.__dirty = True
57
+ if self.__on_update_func is not None:
58
+ self.__on_update_func()
59
+ def redraw(self):
60
+ self.antiAlias = False
61
+ self.do_redraw()
62
+ self.__dirty = False
63
+ def do_redraw(self):
64
+ if not HAVE_MATPLOTLIB: return
65
+ self.canvas.draw()
66
+ def clear(self):
67
+ if not HAVE_MATPLOTLIB: return
68
+ try:
69
+ self.figure.clf()
70
+ except:
71
+ pass
72
+ pass
73
+ def delete_series(self, name):
74
+ logging.error("Deleting series not supported for matplotlib charts")
75
+ def add_series(self, name):
76
+ logging.error("Use matplotlib API for adding series")
77
+ def get_series(self, name):
78
+ logging.error("Getting series not supported for matplotlib charts")
79
+ return None
80
+ def get_data_as_text(self):
81
+ logging.error("Getting series not supported for matplotlib charts")
82
+ return "Data not available for matplotlib charts"
@@ -1,9 +1,11 @@
1
1
  import wx
2
2
  import os
3
+ import logging
3
4
  from ..panels.panelsbase import PanelCharts_Base
4
5
  from ..charts.scatter_chart import ScatterChart
5
6
  from ..charts.time_chart import TimeChart
6
7
  from ..charts.histogram_chart import HistogramChart
8
+ from ..charts.matplotlib_chart import MatPlotLibChart
7
9
  class PanelCharts( PanelCharts_Base):
8
10
  def __init__( self, parent):
9
11
  super().__init__(parent)
@@ -98,3 +100,11 @@ class PanelCharts( PanelCharts_Base):
98
100
  self.charts[name] = chart
99
101
  self.m_nbkPlots.AddPage( chart, name, True)
100
102
  return chart
103
+ def add_matplotlib(self, name ):
104
+ self.delete_chart(name)
105
+ chart = MatPlotLibChart(self.m_nbkPlots, name)
106
+ assert chart.figure is not None, "Could not add matplotlib chart."
107
+ chart.on_update = self.update
108
+ self.charts[name] = chart
109
+ self.m_nbkPlots.AddPage( chart, name, True)
110
+ return chart
@@ -69,6 +69,7 @@ class FormMain(FormMain_Base):
69
69
  args["parent"] = self._nbk_control_panels
70
70
  newPanel = panelType(**args)
71
71
  self._nbk_control_panels.AddPage( newPanel, title, False)
72
+ return newPanel
72
73
  def HideCustomPanels(self):
73
74
  if self._nbk_control_panels.GetPageCount()==0:
74
75
  info = self.m_mgr.GetPaneByName("ControlPanels")
@@ -139,6 +139,10 @@ class ScriptGui:
139
139
  if threading.currentThread().getName() == "ScriptThread":
140
140
  return self.__run_with_timer(self.add_histogram, name, binsize)
141
141
  return self._mngr.charts.add_histogram(name, binsize)
142
+ def add_matplotlib(self, name):
143
+ if threading.currentThread().getName() == "ScriptThread":
144
+ return self.__run_with_timer(self.add_matplotlib, name)
145
+ return self._mngr.charts.add_matplotlib(name)
142
146
  def get_chart(self, name):
143
147
  return self._mngr.charts.get_chart(name)
144
148
  def delete_chart(self, name):
@@ -1,10 +1,10 @@
1
1
  import logging, os, time
2
- import yaml
3
2
  class ScriptInfo(object):
4
3
  logger = logging.getLogger('happyscript')
5
- def __init__(self, testlist):
4
+ def __init__(self, testlist, use_yaml:bool):
6
5
  self.clear()
7
6
  self.__dict__["xx_testlist"] = testlist
7
+ self.__dict__["xx_use_yaml"] = use_yaml
8
8
  def clear(self):
9
9
  self.__dict__["xx_info"] = dict()
10
10
  self.__dict__["xx_serials"] = list()
@@ -33,14 +33,28 @@ class ScriptInfo(object):
33
33
  fname = self.xx_filename
34
34
  if fname is None:
35
35
  return
36
- fname = os.path.splitext(fname)[0] + ".yml"
37
- file = open(fname, "w")
38
- if len(self.serials)>0:
39
- serials_dict = { 'serials': self.serials }
40
- yaml.dump(serials_dict, file)
41
- if len(self.xx_info)>0:
42
- yaml.dump(self.xx_info, file)
43
- file.close()
36
+ if self.xx_use_yaml:
37
+ import yaml
38
+ fname = os.path.splitext(fname)[0] + ".yml"
39
+ with open(fname, "w") as file:
40
+ if len(self.serials)>0:
41
+ serials_dict = { 'serials': self.serials }
42
+ yaml.dump(serials_dict, file)
43
+ if len(self.xx_info)>0:
44
+ yaml.dump(self.xx_info, file)
45
+ else:
46
+ import json
47
+ fname = os.path.splitext(fname)[0] + ".json"
48
+ with open(fname, "w", encoding="utf-8") as file:
49
+ if len(self.serials)>0 and len(self.xx_info)>0:
50
+ self.xx_info["serials"] = self.serials
51
+ json.dump(self.xx_info, file, ensure_ascii=False, indent=4)
52
+ del self.xx_info["serials"]
53
+ elif len(self.serials)>0:
54
+ serials_dict = { 'serials': self.serials }
55
+ json.dump(serials_dict, file, ensure_ascii=False, indent=4)
56
+ elif len(self.xx_info)>0:
57
+ json.dump(self.xx_info, file, ensure_ascii=False, indent=4)
44
58
  def update_file(self, force=False):
45
59
  if len(self.xx_info)==0 and len(self.serials)==0:
46
60
  return
@@ -34,7 +34,7 @@ class TestLogHandler(logging.FileHandler):
34
34
  class ScriptManager(object):
35
35
  dialog = None
36
36
  logger = logging.getLogger("happyscript")
37
- def __init__(self, title=None, colors = None):
37
+ def __init__(self, title=None, colors = None, use_yaml=False):
38
38
  fixedcolors = [ (226, 239, 217), (222, 235, 246), (255, 242, 204), (237, 237, 237),
39
39
  (251, 229, 213), (217, 226, 243) ]
40
40
  self.on_batch_start = None
@@ -58,7 +58,7 @@ class ScriptManager(object):
58
58
  self.ctrl = ScriptControl()
59
59
  self.gui = ScriptGui(self)
60
60
  self.dialog.on_gui_timer = self.gui.on_gui_timer
61
- self.info = ScriptInfo( self.dialog.pnlTests )
61
+ self.info = ScriptInfo( self.dialog.pnlTests, use_yaml )
62
62
  self._script_params = ScriptParams(self.gui)
63
63
  self._script_params.on_add_object = self._on_add_object
64
64
  self._script_readers = dict()
@@ -154,7 +154,7 @@ class ScriptManager(object):
154
154
  self.info.set_serials(serials)
155
155
  return serials
156
156
  def add_custom_panel(self, title, panelType, **args):
157
- self.dialog.AddCustomPanel(title, panelType, **args)
157
+ return self.dialog.AddCustomPanel(title, panelType, **args)
158
158
  def run(self):
159
159
  self.dialog.BeforeShow()
160
160
  PrintRedirect.start_redirection(self.loghandler)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: happyscript
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Framework for running scripts
5
5
  Requires-Python: >=3.5
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,7 @@
1
1
  README.md
2
2
  copy_code.py
3
3
  increment_version.py
4
+ publish.bat
4
5
  pyproject.toml
5
6
  happyscript/__init__.py
6
7
  happyscript/imglib.py
@@ -21,6 +22,7 @@ happyscript/charts/__init__.py
21
22
  happyscript/charts/chart.py
22
23
  happyscript/charts/histogram_chart.py
23
24
  happyscript/charts/histogram_series.py
25
+ happyscript/charts/matplotlib_chart.py
24
26
  happyscript/charts/panel_charts.py
25
27
  happyscript/charts/scatter_chart.py
26
28
  happyscript/charts/scatter_series.py
@@ -0,0 +1,6 @@
1
+ python copy_code.py
2
+ python increment_version.py
3
+ python -m build
4
+ pause
5
+ twine upload dist/* --repository happyscript
6
+ pause
@@ -17,7 +17,7 @@ build-backend = "setuptools.build_meta"
17
17
  [project]
18
18
  name = "happyscript"
19
19
  description = "Framework for running scripts"
20
- version = "0.0.6"
20
+ version = "0.0.8"
21
21
  readme = "README.md"
22
22
  requires-python = ">=3.5"
23
23
  dependencies = [ ]
File without changes
File without changes
File without changes