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: object

Launches 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 be None).

  • run_lock (RunLock, optional) – The single-run lock; a run launched via run() holds it while active. May be None.

_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.

Parameters:
  • proc (QProcess) – The finished process.

  • cmd (str) – The quoted command line.

  • code (int) – The exit code.

  • hint (str, optional) – Where the result appears.

_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) (or None).

_on_run_finished(proc, cmd, code, on_finished)[source]

Handle a finished run: release the lock, report, refresh.

Parameters:
  • proc (QProcess) – The finished process.

  • cmd (str) – The quoted command line.

  • code (int) – The exit code.

  • on_finished (callable) – Called as on_finished(code) (or None).

_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.

Parameters:
  • message (str) – The message.

  • busy (bool, optional) – Show the busy indicator.

  • build (bool, optional) – Route to the Build channel (True, default) or the Inspection channel (False).

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:
  • argv (list) – The command and its arguments.

  • description (str, optional) – Human description for the activity bar (defaults to the program name).

  • hint (str, optional) – Where the result appears (e.g. 'Ginga window'); shown in the finished message so the user knows where to look.

Returns:

True if the process was started, False if it could not be launched (e.g. the target file is missing).

Return type:

bool

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 the run_lock for its duration — so the launch controls disable while it executes and a second run is refused — and calls on_finished when it ends so the views can re-read the reduction state. Progress is reported on the activity bar’s Build channel.

Parameters:
  • argv (list) – The run command and its arguments.

  • description (str, optional) – Human label for the activity bar (e.g. '(Re)building wv_calib').

  • on_finished (callable, optional) – Called as on_finished(code) when the run ends (success or failure), for the refresh-on-completion.

Returns:

True if the process was started, False otherwise.

Return type:

bool