-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Support stdout file redirects in session.run() #218
Comments
Hi, we added this in #180. You can do with open("pipenv-log.txt", "w") as out:
session.run("pipenv", "lock", "-r", stdout=out) |
Maybe dumb question: is there a way to get the output directly in a variable, without a file? I don't seem to be get a StringIO/BytesIO to work here, or a |
Also, I don't think this was ever documented? |
Ahh, output is returned if this is silent. I thought I'd done this somewhere before. (Ironically, probably for something very similar to what I'm doing now, grabbing a version). |
How would this feature be useful?
When building projects, I find myself having to use commands which generate output to stdout (such as
pipenv lock -r
) which I want to redirect to a file (e.g.>docs/requirements.txt
). This currently is not possible withsession.run()
, because, as I understand it, special characters such as>
are being escaped before they are run.Describe the solution you'd like
It would be handy if
session.run()
would accept something likesession.run("echo", "hello", ">hello.txt")
orsession.run("echo", "hello", ">", "hello.txt")
and pass the redirect through so it gets executed when running the command.Describe alternatives you've considered
I am using
Makefile
s and, for cross-platform reasons,make.bat
. I also played around with task-specific shell/batch files. Havingnox
at hand, I am hoping I can centralize all my test-, but also more general build-related processes into one neat and tidy script, replacing non-Windows-compatibleMakefile
s and reducing clutter.The text was updated successfully, but these errors were encountered: