Hmm... can't you do this? if encryptionEnabled: p = subprocess.Popen(["gpg", "--decrypt", "supersecret.html.gpg"], stdin = subprocess.PIPE) fileobj = p.stdin else: fileobj = open("notsosecret.html") I think that works. Is there something this way won't work for? You can also do the same thing to get stdout and stderr file objects. I guess a wrapper would simplify this process. -Devin On Wed, Jul 29, 2009 at 7:41 PM, Eric Pruitt<eric.pruitt at gmail.com> wrote: > My motivation came from an instance when I was using subprocess.Popen for a > Linux / Windows cross platform program. In part of the program, I was > writing and reading to a cron like object. On Windows, it was a text file > and on Linux it would be the crontab executable. Had I been able to > substitute the "open()" function with my wrapper, it would have been the > only change I had to make for cross platform compatibility; instead of > having to change numerous lines because Linux would need Popen and Windows > would need a regular file open(), I could simply make it so that if the > platform was Linux, my wrapper is used in place of that. Just another > example would be having an external program decrypt a file that can be in > plain text or encrypted that might go something like this: > > if encryptionEnabled: > fileobj = subprocess.ProcessIOWrapper("gpg --decrypt > supersecret.html.gpg") > else: > fileobj = open("notsosecret.html") >
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4