Patch for commands.py to provide callback
Greetings all, I have attached a patch for commands.py to provide a callback ability. Example use: ------------------------------------- import commands cmd = 'top -b -n2' def fancy(out): print 'GOT(%s)' % out.strip() commands.cb = fancy (s,o) = commands.getstatusoutput(cmd) print 'OUTPUT (%s)' % o ------------------------------------- I am not sure if this is the proper forum or means to submit something like this, so please forgive me and advise accordingly if I am in error. The basic idea is obvious, to allow long-running commands to call back whenever there is output. This is against python 2.4. Please let me know if you have any questions or suggestions. thanks!! -brad
Brad Doctor wrote:
I am not sure if this is the proper forum or means to submit something like this, so please forgive me and advise accordingly if I am in error.
to make sure that they don't just disappear under a zillion other mails, patches should be submitted to the patch tracker: http://sourceforge.net/patch/?group_id=5470 </F>
Cool, thank you Fredrik -- going there now. -brad On 7/5/06, Fredrik Lundh <fredrik@pythonware.com> wrote:
Brad Doctor wrote:
I am not sure if this is the proper forum or means to submit something like this, so please forgive me and advise accordingly if I am in error.
to make sure that they don't just disappear under a zillion other mails, patches should be submitted to the patch tracker:
http://sourceforge.net/patch/?group_id=5470
</F>
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/brad.doctor%40gmail.com
Since commands.getstatusoutput() is such a trivial wrapper around os.popen(), why bother patching commands.py? On 7/5/06, Brad Doctor <brad.doctor@gmail.com> wrote:
Greetings all,
I have attached a patch for commands.py to provide a callback ability. Example use:
------------------------------------- import commands
cmd = 'top -b -n2'
def fancy(out): print 'GOT(%s)' % out.strip()
commands.cb = fancy
(s,o) = commands.getstatusoutput(cmd) print 'OUTPUT (%s)' % o -------------------------------------
I am not sure if this is the proper forum or means to submit something like this, so please forgive me and advise accordingly if I am in error. The basic idea is obvious, to allow long-running commands to call back whenever there is output. This is against python 2.4. Please let me know if you have any questions or suggestions.
thanks!! -brad
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
Because it is a great way to consistently use popen(). Rather than write something specific each time, our site/company prefers to use commands to keep it all consistent. -brad On 7/5/06, Guido van Rossum <guido@python.org> wrote:
Since commands.getstatusoutput() is such a trivial wrapper around os.popen(), why bother patching commands.py?
Greetings all,
I have attached a patch for commands.py to provide a callback ability. Example use:
------------------------------------- import commands
cmd = 'top -b -n2'
def fancy(out): print 'GOT(%s)' % out.strip()
commands.cb = fancy
(s,o) = commands.getstatusoutput(cmd) print 'OUTPUT (%s)' % o -------------------------------------
I am not sure if this is the proper forum or means to submit something
On 7/5/06, Brad Doctor <brad.doctor@gmail.com> wrote: like
this, so please forgive me and advise accordingly if I am in error. The basic idea is obvious, to allow long-running commands to call back whenever there is output. This is against python 2.4. Please let me know if you have any questions or suggestions.
thanks!! -brad
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
Hm. It sounds like your company would be better off developing a library of handy tools that it uses over and over, instead of on the one hand using only standard library, and then if the standard library doesn't provide the feature you need, proposing a patch. I wouldn't be so critical if I thought others would benefit from your patch. But it seems a rather arbitrary place to insert a debugging hook (if that's what you need it for), and I don't think I've seen others with the same need. Or perhaps you could start by explaining the problem you are trying to solve before proposing a specific patch? --Guido On 7/5/06, Brad Doctor <brad.doctor@gmail.com> wrote:
Because it is a great way to consistently use popen(). Rather than write something specific each time, our site/company prefers to use commands to keep it all consistent.
-brad
Since commands.getstatusoutput() is such a trivial wrapper around os.popen(), why bother patching commands.py?
On 7/5/06, Brad Doctor <brad.doctor@gmail.com> wrote:
Greetings all,
I have attached a patch for commands.py to provide a callback ability. Example use:
------------------------------------- import commands
cmd = 'top -b -n2'
def fancy(out): print 'GOT(%s)' % out.strip()
commands.cb = fancy
(s,o) = commands.getstatusoutput(cmd) print 'OUTPUT (%s)' % o -------------------------------------
I am not sure if this is the proper forum or means to submit something
On 7/5/06, Guido van Rossum <guido@python.org> wrote: like
this, so please forgive me and advise accordingly if I am in error. The basic idea is obvious, to allow long-running commands to call back whenever there is output. This is against python 2.4. Please let me know if you have any questions or suggestions.
thanks!! -brad
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:
http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (3)
-
Brad Doctor
-
Fredrik Lundh
-
Guido van Rossum