Skip to content

pfun.subprocess.Subprocess dataclass

Module that enables running commands in the shell

run_in_shell(self, cmd, stdin=-1, stdout=-1, stderr=-1)

Get an Effect that runs cmd in the shell

Examples:

1
2
>>> Subprocess().run_in_shell('cat foo.txt').run(None)
(b'contents of foo.txt', b'')

Parameters:

Name Type Description Default
cmd str

the command to run

required
stdin Union[IO, int]

input pipe for the subprocess

-1
stdout Union[IO, int]

output pipe for the subprocess

-1
stderr Union[IO, int]

error pipe for the subprocess

-1

Returns:

Type Description
pfun.effect.Effect[object, subprocess.CalledProcessError, Tuple[bytes, bytes]]

Effect that runs cmd in the shell and produces a tuple of (stdout, stderr)

pfun.subprocess.HasSubprocess

Module provider providing the subprocess module

pfun.subprocess.run_in_shell(cmd, stdin=-1, stdout=-1, stderr=-1)

Get an Effect that runs cmd in the shell

Examples:

1
2
3
4
>>> class Env:
...     subprocess = Subprocess()
>>> run_in_shell('cat foo.txt').run(Env())
(b'contents of foo.txt', b'')

Parameters:

Name Type Description Default
cmd str

the command to run

required
stdin Union[IO, int]

input pipe for the subprocess

-1
stdout Union[IO, int]

output pipe for the subprocess

-1
stderr Union[IO, int]

error pipe for the subprocess

-1

Returns:

Type Description
pfun.effect.Effect[pfun.subprocess.HasSubprocess, subprocess.CalledProcessError, Tuple[bytes, bytes]]

Effect that runs cmd in the shell and produces a tuple of (stdout, stderr)