Commit 6e009a48 authored by augustin_s's avatar augustin_s 🐍
Browse files

switched to printed_exception contextmanager

parent 4c745a6b
import wx
from slic.utils.registry import instances
from slic.utils import Marker, Shortcut, printable_exception
from slic.utils import Marker, Shortcut, printed_exception
from ..widgets import STRETCH, make_filled_vbox, make_filled_hbox
from .tools import run
......@@ -112,10 +112,8 @@ class MarkerGoToLine(wx.BoxSizer):
def on_go(self, _event):
def wait():
try:
with printed_exception:
self.marker.goto().wait()
except Exception as e:
print(printable_exception(e))
wx.CallAfter(self.btn_go.SetValue, False)
run(wait)
......@@ -140,10 +138,8 @@ class ShortcutGoToLine(wx.BoxSizer):
def on_go(self, _event):
def wait():
try:
with printed_exception:
self.shortcut.run().wait()
except Exception as e:
print(printable_exception(e))
wx.CallAfter(self.btn_go.SetValue, False)
run(wait)
......
import wx
from slic.utils import printable_exception
from slic.utils import printed_exception
from slic.utils.reprate import get_pvname_reprate
from ..widgets import STRETCH, TwoButtons, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, post_event
......@@ -74,10 +74,8 @@ class RunPanel(wx.Panel):
self.task = self.acquisition.acquire(filename, n_pulses=n_pulses, continuous=continuous, wait=False)
def wait():
try:
with printed_exception:
self.task.wait()
except Exception as e:
print(printable_exception(e))
self.task = None
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
......
import wx
from slic.utils import nice_arange, printable_exception
from slic.utils import nice_arange, printed_exception
from slic.utils.reprate import get_pvname_reprate
from ..widgets import STRETCH, TwoButtons, LabeledEntry, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, make_filled_hbox, post_event
......@@ -124,10 +124,8 @@ class ScanPanel(wx.Panel):
self.scan = self.scanner.scan1D(adjustable, start_pos, end_pos, step_size, n_pulses, filename, relative=relative, return_to_initial_values=return_to_initial_values, repeat=n_repeat, start_immediately=False)
def wait():
try:
with printed_exception:
self.scan.run()
except Exception as e:
print(printable_exception(e))
self.scan = None
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
......
import numpy as np
import wx
from slic.utils import printable_exception
from slic.utils import printed_exception
from slic.utils.reprate import get_pvname_reprate
from ..widgets import LabeledMathEntry, LabeledEntry, LabeledFilenameEntry, TwoButtons, make_filled_hbox, make_filled_vbox, STRETCH, EXPANDING
......@@ -151,10 +151,8 @@ class SpecialScanPanel(wx.Panel):
self.scan = self.scanner.ascan_list(adjustable, steps, n_pulses, filename, return_to_initial_values=return_to_initial_values, repeat=n_repeat, start_immediately=False)
def wait():
try:
with printed_exception:
self.scan.run()
except Exception as e:
print(printable_exception(e))
self.scan = None
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
......
import wx
from slic.utils import printable_exception
from slic.utils import printed_exception
from slic.utils.reprate import get_pvname_reprate
from ..widgets import STRETCH, TwoButtons, LabeledMathEntry, LabeledFilenameEntry, make_filled_vbox, post_event
......@@ -52,10 +52,8 @@ class StaticPanel(wx.Panel):
self.task = self.acquisition.acquire(filename, n_pulses=n_pulses, wait=False)
def wait():
try:
with printed_exception:
self.task.wait()
except Exception as e:
print(printable_exception(e))
self.task = None
post_event(wx.EVT_BUTTON, self.btn_go.btn2)
......
......@@ -2,7 +2,7 @@ from collections import defaultdict
from datetime import datetime
import wx
from slic.utils import printable_exception
from slic.utils import printed_exception
from ..widgets import EXPANDING, TwoButtons, LabeledTweakEntry, LabeledMathEntry, make_filled_vbox, post_event, AutoWidthListCtrl, copy_to_clipboard
from ..widgets.plotting import PlotDialog
......@@ -104,10 +104,8 @@ class TweakPanel(wx.Panel):
self.task = adjustable.set_target_value(target)
def wait():
try:
with printed_exception:
self.task.wait()
except Exception as e:
print(printable_exception(e))
self.task = None
# self.on_change_adj(None) # cannot change widget from thread, post event instead:
post_event(wx.EVT_COMBOBOX, self.cb_adjs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment