Skip to content

process.Run 'int' object is not subscriptable #624

@adanaja

Description

@adanaja

In e3.os.process.Run, the parameter input can by of type PIPE_VALUE => -2

    def __init__(
        self,
        cmds: AnyCmdLine,
        cwd: str | None = None,
        output: STDOUT_VALUE | DEVNULL_VALUE | PIPE_VALUE | str | IO | None = PIPE,
        error: STDOUT_VALUE | DEVNULL_VALUE | PIPE_VALUE | str | IO | None = STDOUT,
        input: DEVNULL_VALUE  # noqa: A002
+       | PIPE_VALUE
        | str
        | bytes
        | IO
        | None = None,  # noqa: A002

Then we have:

        # First resolve output, error and input
+       self.input_file = File(input, "r")
        self.output_file = File(output, "w")

Then in File:

    def __init__(self, name: Any, mode: str = "r"):
+       self.name = name

        if isinstance(name, bytes) and mode == "r" and name.startswith(b"|"):
            self.fd = subprocess.PIPE
        elif isinstance(name, str):
            ...
        else:
            # this is a file descriptor
+           self.fd = name
        ...
        
    def get_command(self) -> str | None:
        """Return the command to run to create the pipe."""
        if self.fd == subprocess.PIPE:
+           return self.name[1:]
        else:
            return None

So when doing Run(..., input=PIPE), the error 'int' object is not subscriptable is raised

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions