Command execution

async pglift.system.cmd.run(args, *, input=None, capture_output=True, timeout=None, check=False, log_stdout=False, **kwargs)
Parameters:
Return type:

CompletedProcess

pglift.system.cmd.start_program(cmd, *, pidfile, logfile, timeout=1, env=None, fs=<object object>)

Start program described by ‘cmd’, in the background, and possibly store its PID in ‘pidfile’.

Raises:
  • SystemError – if the program is already running.

  • CommandError – in case program unexpectedly terminates before timeout.

Parameters:
  • cmd (Sequence[str])

  • pidfile (Path | None)

  • logfile (Path | None)

  • timeout (float)

  • env (Mapping[str, str] | None)

  • fs (Annotated[AbstractFS[PurePath] | AbstractFS[Path], Dependency(var=<ContextVar name='FileSystem' default=<pglift.system.fs.LocalFS object at 0x7bfc81a096a0> at 0x7bfc818849f0>)])

Return type:

Popen[bytes]

pglift.system.cmd.terminate_program(pidfile, *, fs=<object object>)

Terminate program matching PID in ‘pidfile’.

Upon successful termination, the ‘pidfile’ is removed. No-op if no process matching PID from ‘pidfile’ is running.

Parameters:
  • pidfile (Path)

  • fs (Annotated[AbstractFS[PurePath] | AbstractFS[Path], Dependency(var=<ContextVar name='FileSystem' default=<pglift.system.fs.LocalFS object at 0x7bfc81a096a0> at 0x7bfc818849f0>)])

Return type:

None

pglift.system.cmd.status_program(pidfile, *, fs=<object object>)

Return the status of a program which PID is in ‘pidfile’.

Raises:
  • SystemError – if the program is already running.

  • CommandError – in case program execution terminates after timeout.

Parameters:
  • pidfile (Path)

  • fs (Annotated[AbstractFS[PurePath] | AbstractFS[Path], Dependency(var=<ContextVar name='FileSystem' default=<pglift.system.fs.LocalFS object at 0x7bfc81a096a0> at 0x7bfc818849f0>)])

Return type:

Status