drivecasa.interface - Casapy interface class

class drivecasa.interface.Casapy(casa_logfile=None, commands_logfile=None, casa_dir=None, working_dir='/tmp/drivecasa', timeout=600, log2term=True, echo_to_stdout=False)[source]

Handles the interface with casapy.

Simply instantiate, then use member function ‘run_script’ to pass valid casapy commands (i.e. python function calls) to casapy.

Note

Imported into the root of the drivecasa package to provide convenient instantiation, e.g:

casa = drivecasa.Casapy()
casa.run_script(['tasklist'])
load_subroutines()[source]
run_script(script, raise_on_severe=True, timeout=-1)[source]

Run the commands listed in script.

Parameters:
  • script – A list of commands to execute. (One command per list element.)
  • raise_on_severe – Raise a RuntimeError if SEVERE messages are encountered in the logging output. Set to False if you want to attempt to continue execution anyway (e.g. if you want to ignore errors caused by trying to re-import UVFITs data when the outputs are pre-existing from a previous run).
  • timeout – If -1 (the default, use the class default timeout). Otherwise, specifies timeout in seconds for this command. None implies no timeout (wait indefinitely).
Returns:

Tuple (casa_out, errors)

Where casa_out is a line-by-line list containing the contents of the casapy terminal output, and errors is a line-by-line list of ‘SEVERE’ error messages.

run_script_from_file(path_to_scriptfile, raise_on_severe=True, command_pre_logged=False, timeout=-1)[source]
Run the script at given path.
Parameters:
  • path_to_scriptfile – Can be relative or absolute, since we apply abspath conversion before passing to casapy.
  • raise_on_severe – Raise a RuntimeError if SEVERE messages are encountered in the logging output. Set to False if you want to attempt to continue execution anyway (e.g. if you want to ignore errors caused by trying to re-import UVFITs data when the outputs are pre-existing from a previous run).
  • timeout – If -1 (the default, use the class default timeout). Otherwise, specifies timeout in seconds for this command. None implies no timeout (wait indefinitely).
Returns:

Tuple (casa_out, errors)

Where casa_out is a line-by-line list containing the contents of the casapy terminal output, and errors is a line-by-line list of ‘SEVERE’ error messages.