Skip to content

Commit

Permalink
Added some icons to the plan actions and cleaned up application
Browse files Browse the repository at this point in the history
launching exceptions.
  • Loading branch information
canismarko committed Jun 7, 2024
1 parent 0eaaff8 commit be7a377
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 29 deletions.
20 changes: 14 additions & 6 deletions src/firefly/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ def setup_window_actions(self):
)
# Actions for executing plans
plans = [
# (plan_name, text, display file, shortcut)
("count", "&Count", "count.py", "Ctrl+Shift+C"),
("line_scan", "&Line scan", "line_scan.py", "Ctrl+Shift+L"),
("xafs_scan", "&XAFS Scan", "xafs_scan.py", "Ctrl+Shift+X"),
# (plan_name, text, display file, shortcut, icon)
("count", "&Count", "count.py", "Ctrl+Shift+C", "mdi.counter"),
("line_scan", "&Line scan", "line_scan.py", "Ctrl+Shift+L", None),
("xafs_scan", "&XAFS Scan", "xafs_scan.py", "Ctrl+Shift+X", None),
]
self.plan_actions = []
for plan_name, text, display_file, shortcut in plans:
for plan_name, text, display_file, shortcut, icon in plans:
slot = partial(
self.show_plan_window, name=plan_name, display_file=display_file
)
Expand All @@ -283,6 +283,8 @@ def setup_window_actions(self):
action.triggered.connect(slot)
if shortcut is not None:
action.setShortcut(QKeySequence(shortcut))
if icon is not None:
action.setIcon(qta.icon(icon))
self.plan_actions.append(action)
# Action for showing the run browser window
self._setup_window_action(
Expand Down Expand Up @@ -533,8 +535,14 @@ def prepare_queue_client(self, client=None, api=None):
queueserver API. Used for testing.
"""
# Load the API for controlling the queueserver.
if api is None:
api = queueserver_api()
try:
api = queueserver_api()
except InvalidConfiguration:
log.error("Could not load queueserver API "
"configuration from iconfig.toml file.")
return
# Create the client object
if client is None:
client = QueueClient(api=api)
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def main(default_fullscreen=False, default_display="status"):
asyncio.set_event_loop(event_loop)

# Define devices on the beamline (slow!)
app.setup_instrument()
app.setup_instrument(load_instrument=not pydm_args.no_instrument)

# Get rid of the splash screen now that we're ready to go
splash.close()
Expand Down
1 change: 0 additions & 1 deletion src/firefly/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def customize_ui(self):
if hasattr(app, "show_logs_window_action"):
self.ui.menuView.addAction(app.show_logs_window_action)
# Setup menu
print(type(self.ui.menubar))
self.ui.menuSetup = QtWidgets.QMenu(self.ui.menubar)
self.ui.menuSetup.setObjectName("menuSetup")
self.ui.menuSetup.setTitle("Set&up")
Expand Down
6 changes: 5 additions & 1 deletion src/firefly/queue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
from qtpy.QtCore import QObject, QTimer, Signal

from haven import load_config
from haven.exceptions import UnknownDeviceConfiguration, InvalidConfiguration

log = logging.getLogger()


def queueserver_api():
config = load_config()["queueserver"]
try:
config = load_config()["queueserver"]
except KeyError:
raise InvalidConfiguration("Could not load queueserver info from iconfig.toml file.")
ctrl_addr = f"tcp://{config['control_host']}:{config['control_port']}"
info_addr = f"tcp://{config['info_host']}:{config['info_port']}"
api = REManagerAPI(zmq_control_addr=ctrl_addr, zmq_info_addr=info_addr)
Expand Down
26 changes: 6 additions & 20 deletions src/haven/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,7 @@ class GainOverflow(RuntimeError):

...


# class ComponentNotFound(IndexError):
# """Registry looked for a component, but it wasn't registered."""

# ...


# class MultipleComponentsFound(IndexError):
# """Registry looked for a single component, but found more than one."""

# ...


# class InvalidComponentLabel(TypeError):
# """Registry looked for a component, but the label provided is not vlaid."""

# ...



class FileNotWritable(IOError):
"""Output file is available but does not have write intent."""

Expand Down Expand Up @@ -71,7 +53,11 @@ class IOCTimeout(RuntimeError):
...


class UnknownDeviceConfiguration(ValueError):
class InvalidConfiguration(ValueError):
"""The configuration files for Haven are missing keys."""
...

class UnknownDeviceConfiguration(InvalidConfiguration):
"""The configuration for a device does not match the known options."""

...
Expand Down

0 comments on commit be7a377

Please sign in to comment.