Foundry.ProcessLauncher

g Foundry.ProcessLauncher Foundry.ProcessLauncher GObject.Object GObject.Object GObject.Object->Foundry.ProcessLauncher

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_environ (environ)

add_minimal_environment ()

append_args (args)

append_args_parsed (args)

append_argv (arg)

create_stdio_stream ()

environ_to_argv ()

get_argv ()

get_cwd ()

get_environ ()

getenv (key)

merge_unix_fd_map (unix_fd_map)

prepend_args (args)

prepend_argv (arg)

push (handler, *handler_data)

push_at_base (handler, *handler_data)

push_error (error)

push_expansion (environ)

push_host ()

push_shell (shell)

push_user_shell (shell)

set_argv (argv)

set_cwd (cwd)

set_environ (environ)

set_pty_fd (consumer_fd)

setenv (key, value)

spawn ()

spawn_with_flags (flags)

take_fd (source_fd, dest_fd)

unsetenv (key)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Foundry.ProcessLauncher(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Foundry.ProcessLauncherClass

Manages process execution and subprocess launching.

Foundry.ProcessLauncher provides a unified interface for launching and managing subprocesses with proper environment setup, working directory configuration, and I/O handling. It supports both local and chained subprocesses that may either run remotely or in a remote context such as a container or virtual machine.

classmethod new()
Return type:

Foundry.ProcessLauncher

add_environ(environ)
Parameters:

environ (str) –

add_minimal_environment()

Adds a minimal set of environment variables.

This is useful to get access to things like the display or other expected variables.

append_args(args)
Parameters:

args (str) –

append_args_parsed(args)
Parameters:

args (str) –

Raises:

GLib.Error

Return type:

bool

append_argv(arg)
Parameters:

arg (str) –

create_stdio_stream()
Raises:

GLib.Error

Returns:

a Gio.IOStream if successful; otherwise None and error is set.

Return type:

Gio.IOStream

Creates a stream to communicate with the subprocess using stdin/stdout.

The stream is created using UNIX pipes which are attached to the stdin/stdout of the child process.

environ_to_argv()
get_argv()
Return type:

[str]

get_cwd()
Return type:

str

get_environ()
Return type:

[str]

getenv(key)
Parameters:

key (str) –

Return type:

str

merge_unix_fd_map(unix_fd_map)
Parameters:

unix_fd_map (Foundry.UnixFDMap) – a Foundry.UnixFDMap

Raises:

GLib.Error

Returns:

True if successful; otherwise False and error is set.

Return type:

bool

Merges the Foundry.UnixFDMap into the current layer.

If there are collisions in destination FDs, then that may cause an error and False is returned.

unix_fd_map will have the FDs stolen using Foundry.UnixFDMap.steal_from() which means that if successful, unix_fd_map will not have any open file-descriptors after calling this function.

prepend_args(args)
Parameters:

args (str) –

prepend_argv(arg)
Parameters:

arg (str) –

push(handler, *handler_data)
Parameters:
push_at_base(handler, *handler_data)
Parameters:
push_error(error)
Parameters:

error (GLib.Error) – a GLib.Error

Pushes a new layer that will always fail with error.

This is useful if you have an error when attempting to build a run command, but need it to deliver the error when attempting to create a subprocess launcher.

push_expansion(environ)
Parameters:

environ (str) –

Pushes a layer to expand known environment variables.

The command argv and cwd will have $FOO style environment variables expanded that are known. This can be useful to allow things like $BUILDDIR be expanded at this layer.

push_host()

Pushes handler to transform command to run on host.

If necessary, a layer is pushed to ensure the command is run on the host instead of the application container.

If Builder is running on the host already, this function does nothing.

push_shell(shell)
Parameters:

shell (Foundry.ProcessLauncherShell) – the kind of shell to be used

Pushes a shell which can run the upper layer command with -c.

push_user_shell(shell)
Parameters:

shell (Foundry.ProcessLauncherShell) –

set_argv(argv)
Parameters:

argv (str) –

set_cwd(cwd)
Parameters:

cwd (str) –

set_environ(environ)
Parameters:

environ (str) –

set_pty_fd(consumer_fd)
Parameters:

consumer_fd (int) – the FD of the PTY consumer

Sets up a PTY for the run context that will communicate with the consumer. The consumer is the generally the widget that is rendering the PTY contents and the producer is the FD that is connected to the subprocess.

setenv(key, value)
Parameters:
  • key (str) –

  • value (str) –

spawn()
Raises:

GLib.Error

Returns:

an Gio.Subprocess if successful; otherwise None and error is set.

Return type:

Gio.Subprocess

Spawns the run command.

If there is a failure to build the command into a subprocess launcher, then None is returned and error is set.

If the subprocess fails to launch, then None is returned and error is set.

spawn_with_flags(flags)
Parameters:

flags (Gio.SubprocessFlags) –

Raises:

GLib.Error

Returns:

a Gio.Subprocess or None upon error.

Return type:

Gio.Subprocess

Like Foundry.ProcessLauncher.spawn() but allows specifying the flags for the Gio.Subprocess which may override other settings.

take_fd(source_fd, dest_fd)
Parameters:
  • source_fd (int) –

  • dest_fd (int) –

unsetenv(key)
Parameters:

key (str) –