pypeit.setup_gui.controller module

The controller portion of the PypeIt Setup GUI.

class pypeit.setup_gui.controller.MetadataOperation(name, model)[source]

Bases: QObject

Base class for Metadata operations that take long enough that they should take place in a background thread.

Parameters:

model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.

_addedMetadata(name, match)[source]

Callback used to report progress on reading files when building metadata.

_buildingMetadata(name, match)[source]

Callback used to find the total number of files being read when building metadata.

postRun(canceled, exc_info)[source]

Clean up steps after the operations has run.

Parameters:
  • canceled (bool) – True if the operation was canceled.

  • exc_info (tuple) – The exception information (as returned by sys.exc_info()) for any errors that occurred.

preRun()[source]

Perform setup required before running the operation. This involves watching the log for files being added to the metadata.

progressMade

Signal emitted emit when progress has been made. This will be reflected in the view’s progress dialog.

run()[source]

Performs the steps of the MetadataOperation. This is an abstract method overridden by child classes.

class pypeit.setup_gui.controller.MetadataPasteAction(controller, menu_text, handler, shortcut=None)[source]

Bases: QAction

An action (caused by the right click menu in the GUI, a button, or keyboard short cut) for pasting metadata into a PypeItMetadataModel object.

Parameters:
  • controller (PypeItMetadataController) – The controller for the PypeItMetadataModel/PypeItMetadataView MVC triplet.

  • menu_text (str) – The text name for the menu/button that triggers the action.

  • handler (Callable) – The signal handler to enact the action. This receives the “triggered” event from the parent class.

  • shortcut (PySide2.QtGui.QKeySequence.StandardKey, Optional) – The keyboard shortcut to initiate the action.

updateEnabledStatus()[source]

Enable/disable the action based on whether any metadata rows are selected AND there are rows to paste in the clipboard.

class pypeit.setup_gui.controller.MetadataReadOnlyAction(controller, menu_text, handler, shortcut=None)[source]

Bases: QAction

An action (caused by the right click menu in the GUI, a button, or keyboard short cut) that is read only and therefore can be performed on the ObsLog.

Parameters:
  • controller (PypeItMetadataController) – The controller for the PypeItMetadataModel/PypeItMetadataView MVC triplet.

  • menu_text (str) – The text name for the menu/button that triggers the action.

  • handler (Callable) – The signal handler to enact the action. This receives the “triggered” event from the parent class.

  • shortcut (PySide2.QtGui.QKeySequence.StandardKey, Optional) – The keyboard shortcut to initiate the action.

updateEnabledStatus()[source]

Enable/disable the action based on whether any metadata rows are selected.

class pypeit.setup_gui.controller.MetadataWriteAction(controller, menu_text, handler, shortcut=None)[source]

Bases: QAction

An action (caused by the right click menu in the GUI, a button, or keyboard short cut) that can change the file metadata and therefore can only be performed on a PypeItFileModel.

Parameters:
  • controller (PypeItMetadataController) – The controller for the PypeItMetadataModel/PypeItMetadataView MVC triplet.

  • menu_text (str) – The text name for the menu/button that triggers the action.

  • handler (Callable) – The signal handler to enact the action. This receives the “triggered” event from the parent class.

  • shortcut (PySide2.QtGui.QKeySequence.StandardKey, Optional) – The keyboard shortcut to initiate the action.

updateEnabledStatus()[source]

Enable/disable the action based on whether any metadata rows are selected.

exception pypeit.setup_gui.controller.OpCanceledError[source]

Bases: Exception

Exception thrown when a background operation has been canceled.

class pypeit.setup_gui.controller.OpenFileOperation(model, file)[source]

Bases: MetadataOperation

Background operation to open a PypeIt file

Parameters:
  • model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.

  • () (file) – The file to open.

run()[source]

Opens a pypeit file and reads metadata for all of the files in it.

class pypeit.setup_gui.controller.OperationThread[source]

Bases: QThread

Thread to run a background operation.

_cancel_op()[source]

Cancels an in progress background operation when the user cancels the progress dialog.

_op_complete(canceled, exc_info)[source]

Signal handler that is notified when a background operation completes.

Parameters:
  • canceled (bool) – Whether or not the operation was canceled.

  • exc_info (tuple) – The exception information if the operation failed. None if it succeeded

_op_progress(max_progress, progress_message=None)[source]

Signal handler that receives progress information from a background operation as it proceeds. It passes this to the view to increase the value showing in the progress dialog.

completed

Signal send the operation has completed.

run()[source]

Runs an operation in a background thread.

startOperation(operation)[source]

Start a background operation.

Parameters:

operation (MetadataOperation) – The MetadataOperation to start in the background thread.

class pypeit.setup_gui.controller.PypeItFileController(model)[source]

Bases: QObject

PypeItFileController responsible for responding to user interaction as part of a MVC triplet with PypeItFileView and PypeItFileModel

Parameters:
  • main_window (UserPromptDelegate) – A view object that can prompt the user.

  • model (PypeItFileModel) – The model for the obs log.

getMetadataController(model)[source]
setModel(model)[source]
class pypeit.setup_gui.controller.PypeItMetadataController(model, is_pypeit_file)[source]

Bases: QObject

A Controller object for performing actions iniitiated by the user file metadata. Part of a MVC triplet involving PypeItMetadataModel/PypeItMetadataController/PypeItMetadataView.

Parameters:
  • model (PypeItMetatadataModel) – The model this controller acts with.

  • is_pypeit_file (bool) – True if the model is for a PypeItFileModel (that is writeable model), False if it is from a PypeItObsLog model (read only)

_window_closed(id: int) None[source]

Clean up when a header viewer window is closed

comment_out_metadata_rows()[source]

Comment out one or more selected metadata rows.

copy_metadata_rows()[source]

Copy metadata rows into the clipboard.

cut_metadata_rows()[source]

Move metadata rows from the PypeItMetadataModel to the clipboard.

delete_metadata_rows()[source]

Remove one or more selected rows from the PypeItMetadataModel.

getActions(parent)[source]

Returns the actions that this controller supports.

Returns: (list of QAction): List of the actions that can be performed on the PypeItMetadataModel.

paste_metadata_rows()[source]

Insert rows from the clipboard into the PypeItMetadataModel

setView(view)[source]

Set the view that is responsible for displaying and receiving input for the PypeItMetadataModel.

Parameters:

view (PypeItMetadataView) – The view.

uncomment_metadata_rows()[source]

Uncomment previously commented out selected metadata rows.

updatedEnabledActions()[source]

Updates which actions are enabled/disabled.

view_file()[source]

View the selected files in the metadata using Ginga.

view_header()[source]

Display the header of one or more selected files in the metadata.

class pypeit.setup_gui.controller.PypeItObsLogController(model, setup_gui_controller)[source]

Bases: QObject

PypeItObsLogController responsible for responding to user interaction as part of a MVC triplet with PypeItObsLogView and PypeItObsLogModel

Parameters:
  • main_window (UserPromptDelegate) – A view object that can prompt the user.

  • model (PypeItObsLogModel) – The model for the obs log.

  • operation_thread (pypeit.setup_gui.controller.SetupGUIController) – The main Setup GUI controller.

addNewPath(new_path)[source]

Add a new path to the observation log

getMetadataController(model)[source]
removePaths(rows)[source]
setModel(model)[source]
setSpectrograph(spectrograph_name)[source]
class pypeit.setup_gui.controller.SetupGUIController(args)[source]

Bases: QObject

Controller for the PypeIt setup gui. It is responsible for initializing the GUI, and performing actions requested by the user.

Parameters:

args (argparse.Namespace) – The non-QT command line arguments used to start the GUI.

_save_tab(config_name)[source]
clear()[source]

Resets the GUI to it’s initial state. Called in response to the user clicking the “Clear” button. This will prompt the user if they want to save any unsaved changes first.

close(file_model)[source]
createNewFile(source_file_name, selectedRows)[source]
createNewPypeItFile()[source]
exit()[source]

Exits the GUI. Called in response to the user clicking the “Exit” button. This will prompt the user if they want to save any unsaved changes first.

getObsLogController(model)[source]

Create the PypeItObsLogController as part of a MVC triplet.

Parameters:
  • model (PypeItObsLogModel) – The model for the obs log.

  • main_window (SetupGUIMainWindow) – The mainwindow of the setup GUI.

getPypeItFileController(model)[source]

Create the PypeItObsLogController as part of a MVC triplet.

Parameters:

model (PypeItFileModel) – The model for the obs log.

main_window = None
model = <pypeit.setup_gui.model.PypeItSetupGUIModel object>
open_pypeit_file()[source]

Opens a PypeIt file. Called in response to the user the clicking the “Open” button. This method prompts the user to discard or save any current changes, prompts the user for a pypeit to open, and opens it.

run_setup()[source]

Runs setup on the currently selected raw data directories. Called in response to the user the clicking the “Run Setup” or changing the spectrograph. This will prompt the user if they want to save any unsaved changes first and start the operation in a background thread.

save_all()[source]

” Save all unique configurations as pypeit files. Called in response to the user clicking the “Save All” button.

save_one()[source]

Saves the currently selected configuration as a pypeit file. Called in response to the user clicking the “Save Tab” button.

start(app)[source]

Starts the PypeItSetupGUi event loop. Exits the GUI when the GUI is closed.

Parameters:

app (QApplication) – The Qt application object for the GUI. The caller is expected to pass any Qt specific command line arguments to this object before calling start().

class pypeit.setup_gui.controller.SetupOperation(model)[source]

Bases: MetadataOperation

Background operation to run pypeit setup.

Parameters:

model (PypeItSetupGUIModel) – The PypeIt Setup GUI’s model object.

run()[source]

Runs pypeit_setup on the current raw data directories.

pypeit.setup_gui.controller.lock_qt_mutex(mutex)[source]