Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'increasingly useful' case does not work #12

Open
peterjpxie opened this issue Sep 25, 2019 · 0 comments
Open

The 'increasingly useful' case does not work #12

peterjpxie opened this issue Sep 25, 2019 · 0 comments

Comments

@peterjpxie
Copy link

The 'increasingly useful' case in Readme.rst seems to show when we initialize bash object, it keeps the standard output as same input for all subsequent bash function calls. But it is not the case. Instead, each bash object initialization or bash function call will update the standard output as input for next bash call in a chain fashion.

Snippet from Readme.rst:
This becomes increasingly useful if you later need to reuse one such command::

>>> b = bash('ls . ')
>>> b.bash('grep ".pyc"')
bash.pyc
tests.pyc
>>> b.bash('grep ".py$"')
bash.py
tests.py

Actual Result:

>>> b = bash('ls tmp')
>>> b
a.txt
bash.py
bash.pyc
tests.py
tests.pyc
>>> b.bash('grep ".pyc"')
bash.pyc
tests.pyc
>>> b.bash('grep ".py$"')

[Note: The output is actually empty.]

code snippet:

    def sync(self, timeout=None):
        kwargs = {'input': self.stdout}  # 2. use previous stdout as input for next run
        if timeout:
            kwargs['timeout'] = timeout
            if not SUBPROCESS_HAS_TIMEOUT:
                raise ValueError(
                    "Timeout given but subprocess doesn't support it. "
                    "Install subprocess32 and try again."
                )
        self.stdout, self.stderr = self.p.communicate(**kwargs)  # 1. update self.stdout each run

Suggestion:
Revise this case in readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant