pypeit.dashboard.launcher module
Launch PypeIt’s external tools as subprocesses.
Uses Qt’s QProcess so launches are non-blocking and integrate
with the event loop: stdout/stderr/return code are captured and the
ActivityBar is updated on start and
finish, so every launch is observable in the GUI.
- class pypeit.dashboard.launcher.Launcher(activity=None, run_lock=None)[source]
Bases:
objectLaunches external tools as non-blocking subprocesses and reports progress/outcome to the activity bar.
Two kinds of subprocess are distinguished:
launch()— a fire-and-forget inspection viewer (e.g.ginga,pypeit_chk_*). It does not touch the run lock, and its progress is reported on the activity bar’s Inspection channel.run()— a PypeIt reduction run (e.g.run_pypeit,pypeit_run_to_calibstep). It holds the single-run lock while active (so a second run cannot be launched), reports on the Build channel, and invokes a completion callback so the views can refresh the reduction state.
- Parameters:
activity (
ActivityBar, optional) – The status/activity bar to report to (may beNone).run_lock (
RunLock, optional) – The single-run lock; a run launched viarun()holds it while active. May beNone.
- _drop(proc)[source]
Release a finished process reference.
- Parameters:
proc (
QProcess) – The process to release.
- _on_error(proc, cmd)[source]
Handle an inspection process that failed to start (e.g. command not found).
- Parameters:
proc (
QProcess) – The failed process.cmd (
str) – The quoted command line.
- _on_finished(proc, cmd, code, hint='viewer window')[source]
Handle inspection-process completion: report the outcome and capture output. The exact command stays shown after finishing so the user can copy and rerun it.
- _on_run_error(proc, cmd, on_finished)[source]
Handle a run that failed to start: release the lock and report.
- Parameters:
proc (
QProcess) – The failed process.cmd (
str) – The quoted command line.on_finished (callable) – Called as
on_finished(-1)(orNone).
- _on_run_finished(proc, cmd, code, on_finished)[source]
Handle a finished run: release the lock, report, refresh.
- _report(message, busy=False, build=True)[source]
Report a message to the activity bar (and the log), on the Build channel (reduction runs) or the Inspection channel (viewer launches) per
build.
- launch(argv, description=None, hint='viewer window')[source]
Launch an inspection viewer as a fire-and-forget subprocess.
Unlike
run(), this never engages the single-run lock: any number of viewers may be open at once, and their outcome is reported on the activity bar’s Inspection channel.- Parameters:
- Returns:
True if the process was started, False if it could not be launched (e.g. the target file is missing).
- Return type:
- run(argv, description='Rebuilding', on_finished=None)[source]
Launch a PypeIt reduction run (e.g.
pypeit_run_to_calibstep).Unlike
launch()(inspection viewers), a run engages therun_lockfor its duration — so the launch controls disable while it executes and a second run is refused — and callson_finishedwhen it ends so the views can re-read the reduction state. Progress is reported on the activity bar’s Build channel.- Parameters:
- Returns:
True if the process was started, False otherwise.
- Return type: