6.1.3.6. Log commands

Being an interactive program, SPEX has facilities to save commands, execute lists of commands and save outputs to files. This is arranged through the log commands.

6.1.3.6.1. Log execute

Executing lists of SPEX commands can be done using the log_exe method, similar to the log exe command in SPEX:

Session.log_exe(filename)[source]

Execute log file.

Parameters

filename (str) – Filename of the ASCII file with the SPEX commands (including .com extension).

The filename should include a .com extension.

Example:

>>> s.log_exe('mysource.com')

6.1.3.6.2. Log save

To save the commands typed into SPEX (or passed through the command function in PYSPEX or the API), one can use the log_save command.

Session.log_save(savefile, status=None)[source]

Save the commands for a session in an ascii file. The status is optional and either overwrite or append.

Parameters
  • savefile (str) – Filename of the output command file (including .com extension).

  • status (str) – (Optional) Overwrite or append an existing file name. String can be ‘overwrite’ or ‘append’.

The savefile should have the .com extension included in the name. Optionally, the status overwrite or append can be added.

Example:

>>> s.log_save('mycommands.com')
>>> s.log_save('session_01.com', status='append')

6.1.3.6.3. Log output

The terminal output can be saved in another file with the .out extension using the method log_out:

Session.log_out(outfile, status=None)[source]

Save SPEX terminal output to file.

Parameters
  • outfile (str) – Filename of the output file (including .out extension).

  • status (str) – (Optional) Overwrite or append an existing file name. String can be ‘overwrite’ or ‘append’.

The outfile should have the .out extension included in the name. Optionally, the status overwrite or append can be added.

Examples:

>>> s.log_out('session.out')
>>> s.log_out('mylog.out', status='overwrite')

6.1.3.6.4. Log close

The logging done by the log_save or log_out methods can be stopped by calling the log_close method:

Session.log_close(logtype)[source]

Close the save or output file.

Parameters

logtype (str) – String indicating the type of log to close (‘save’ or ‘out’).

where logtype is either save or out.

Examples:

>>> s.log_close('out')
>>> s.log_close('save')