Re: [Python-Dev] Implementing File Modes

2009-07-30 Thread Eric Pruitt
> On Tue, 28 Jul 2009 04:06:45 am Eric Pruitt wrote: > > I am implementing the file wrapper using changes to subprocess.Popen > > that also make it asynchronous and non-blocking so implementing "r+" > > should be trivial to do. How about handling stderr? I have the > > following ideas: leave out su

Re: [Python-Dev] Implementing File Modes

2009-07-29 Thread Eric Pruitt
Well, with a few changes to your code, that would indeed work (you are using stdin as your pipe. Correct me if I'm wrong but if you intend to read from it, you need to change it to "stdout = subprocess.PIPE" and the other lines as well to reflect this change). My Google Summer of Code modifications

Re: [Python-Dev] Implementing File Modes

2009-07-29 Thread Devin Cook
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 sa

Re: [Python-Dev] Implementing File Modes

2009-07-29 Thread Eric Pruitt
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

Re: [Python-Dev] Implementing File Modes

2009-07-28 Thread Gregory P. Smith
On Mon, Jul 27, 2009 at 5:32 PM, Glyph Lefkowitz wrote: > On Mon, Jul 27, 2009 at 3:04 PM, Paul Moore wrote: >> >> I like MRAB's idea of using a (non-standard) "e" flag to include >> stderr. So "r" reads from stdout, "re" reads from stdout+stderr. >> >> Anything more complicated probably should ju

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread Glyph Lefkowitz
On Mon, Jul 27, 2009 at 3:04 PM, Paul Moore wrote: > I like MRAB's idea of using a (non-standard) "e" flag to include > stderr. So "r" reads from stdout, "re" reads from stdout+stderr. > > Anything more complicated probably should just use "raw" Popen > objects. Don't overcomplicate the interface

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread Steven D'Aprano
On Tue, 28 Jul 2009 04:06:45 am Eric Pruitt wrote: > I am implementing the file wrapper using changes to subprocess.Popen > that also make it asynchronous and non-blocking so implementing "r+" > should be trivial to do. How about handling stderr? I have the > following ideas: leave out support for

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread MRAB
Steven D'Aprano wrote: On Tue, 28 Jul 2009 03:21:30 am MRAB wrote: What about stderr? You could add "e" if you want to read from it. "Read from stderr" is just a read. "Write to stderr" is just a write. The difference between reading stdout and stderr is not that you have different modes, b

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread Steven D'Aprano
On Tue, 28 Jul 2009 03:21:30 am MRAB wrote: > What about stderr? You could add "e" if you want to read from it. "Read from stderr" is just a read. "Write to stderr" is just a write. The difference between reading stdout and stderr is not that you have different modes, but that you are reading f

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread Paul Moore
2009/7/27 Eric Pruitt : > I am implementing the file wrapper using changes to subprocess.Popen that > also make it asynchronous and non-blocking so implementing "r+" should be > trivial to do. How about handling stderr? I have the following ideas: leave > out support for reading from stderr, make i

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread Eric Pruitt
I am implementing the file wrapper using changes to subprocess.Popen that also make it asynchronous and non-blocking so implementing "r+" should be trivial to do. How about handling stderr? I have the following ideas: leave out support for reading from stderr, make it so that there is an optional a

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread MRAB
Paul Moore wrote: 2009/7/27 Eric Pruitt : Hello, Since there was a bit of confusion last time, I'll start by saying I am working on the subprocess.Popen module for Google Summer of Code. One of the features I am implementing is a class so that a running process can stand in in place of a file.

Re: [Python-Dev] Implementing File Modes

2009-07-27 Thread Paul Moore
2009/7/27 Eric Pruitt : > Hello, > > Since there was a bit of confusion last time, I'll start by saying I am > working on the subprocess.Popen module for Google Summer of Code. One of the > features I am implementing is a class so that a running process can stand in > in place of a file. For exampl

[Python-Dev] Implementing File Modes

2009-07-27 Thread Eric Pruitt
Hello, Since there was a bit of confusion last time, I'll start by saying I am working on the subprocess.Popen module for Google Summer of Code. One of the features I am implementing is a class so that a running process can stand in in place of a file. For examples, instead of open( "filelist", mo