cape.sysutils: System utilities for using CAPE

This module provides various “system” utilities such as providing a universal Python method to open a PDF file for viewing.

cape.sysutils.get_pdf_viewer() → str

Get the preferred PDF viewer application based on system

Call:
>>> viewer = get_pdf_viewer()
Outputs:
viewer: str

Name of application to open PDF

Versions:
  • 2026-08-07 @ddalle: v1.0

cape.sysutils.open_pdf(fname: str, remote: str | None = None, wait: bool = False, pull: bool = False, local: bool | None = None) → Popen

Open a PDF file if found

Call:
>>> open_pdf(fname, wait=False)
Inputs:
fname: str

Name of file to open

remote: {None} | str

Absolute folder on remote host (or $PWD)

wait: True | {False}

Option to wait until PDF is closed

pull: True | {False}

Pull PDF from RemoteHost and open

local: {None} | True | False

Force “local” host instead of determining automatically

Output:
proc: subprocess.Popen

Subprocess handle

Versions:
  • 2026-08-07 @ddalle: v1.0

cape.sysutils.post_file(pat1: str, *pats, v: bool = False) → Tuple[int, list]

Collect file(s) in tar ball; send to RemoteHost if necessary

Call:
>>> ierr, filenames = post_file(pat1, *pats)
Outputs:
ierr: int

Return code

filenames: list[str]

List of posted file names

cape.sysutils.receive_file() → list

Receive the current cached tarball

Call:
>>> filenames = receive_file()
Outputs:
filenames: list[str]

List of unpacked files