Skip to content

Add example of Popen to expect on a process #3

@nastevens

Description

@nastevens

The following example was generated in a Reddit discussion and would make an excellent example for the repo:

import streamexpect
from subprocess import Popen, PIPE

pipe = Popen(r'net accounts', shell=True, stdout=PIPE).stdout

with streamexpect.wrap(pipe) as stream:
    match = stream.expect_regex(r'Computer role:\s+(\S+)')
    print('Computer role: ' + match.groups[0])

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions