* [sup-talk] [PATCH] Pipe message/attachement to shell command
@ 2007-11-09 15:33 Marcus Williams
2007-11-12 17:55 ` William Morgan
0 siblings, 1 reply; 8+ messages in thread
From: Marcus Williams @ 2007-11-09 15:33 UTC (permalink / raw)
Hi -
On the back of Eyal's patch heres a patch to pipe a message or
attachment to a shell command via '|' in thread view mode.
William, in the code it says that message.raw_message is slow but
thats the only way I could do it without creating a string via
each_raw_message_line. Is there a better way than this?
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pipe-patch
Type: application/octet-stream
Size: 1467 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071109/4a0fc011/attachment.obj
^ permalink raw reply [flat|nested] 8+ messages in thread
* [sup-talk] [PATCH] Pipe message/attachement to shell command
2007-11-09 15:33 [sup-talk] [PATCH] Pipe message/attachement to shell command Marcus Williams
@ 2007-11-12 17:55 ` William Morgan
2007-11-12 22:06 ` Marcus Williams
0 siblings, 1 reply; 8+ messages in thread
From: William Morgan @ 2007-11-12 17:55 UTC (permalink / raw)
Excerpts from Marcus Williams's message of Fri Nov 09 07:33:35 -0800 2007:
> William, in the code it says that message.raw_message is slow but
> thats the only way I could do it without creating a string via
> each_raw_message_line. Is there a better way than this?
Hey, this is another reason to use open3 instead of Session. You need to
have access to use the stdin filehandle in order to use
#each_raw_message_line. (There's no speed difference for IMAP, but for
Maildir and mbox, it's quite large. Maildir could be sped up, but mbox
fundamentally not.)
BTW, that first argument to BufferManager#ask should ideally be a symbol
of some sort rather than nil. History is shared amongst all invocations
with the same symbol.
--
William <wmorgan-sup at masanjin.net>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [sup-talk] [PATCH] Pipe message/attachement to shell command
2007-11-12 17:55 ` William Morgan
@ 2007-11-12 22:06 ` Marcus Williams
2007-11-13 11:58 ` Marcus Williams
0 siblings, 1 reply; 8+ messages in thread
From: Marcus Williams @ 2007-11-12 22:06 UTC (permalink / raw)
On 12.11.2007, William Morgan wrote:
> Hey, this is another reason to use open3 instead of Session. You need to
> have access to use the stdin filehandle in order to use
> #each_raw_message_line. (There's no speed difference for IMAP, but for
> Maildir and mbox, it's quite large. Maildir could be sped up, but mbox
> fundamentally not.)
Attached is a patch for the shell/pipe code so that it uses open3.
Just realised I've not moved shell method into sup in this patch, but
its a start!
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: open3-diffs
Type: application/octet-stream
Size: 3068 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071112/0add038a/attachment.obj
^ permalink raw reply [flat|nested] 8+ messages in thread
* [sup-talk] [PATCH] Pipe message/attachement to shell command
2007-11-12 22:06 ` Marcus Williams
@ 2007-11-13 11:58 ` Marcus Williams
2007-11-14 9:40 ` Marcus Williams
0 siblings, 1 reply; 8+ messages in thread
From: Marcus Williams @ 2007-11-13 11:58 UTC (permalink / raw)
On 12.11.2007, Marcus Williams wrote:
> Attached is a patch for the shell/pipe code so that it uses open3.
> Just realised I've not moved shell method into sup in this patch, but
> its a start!
Mmmm. Seem to be having some buffering problems with open3 on slightly
longer messages. The pipe stuff blocks because of it.
Will have to resubmit when I figure it out.
Marcus
^ permalink raw reply [flat|nested] 8+ messages in thread
* [sup-talk] [PATCH] Pipe message/attachement to shell command
2007-11-13 11:58 ` Marcus Williams
@ 2007-11-14 9:40 ` Marcus Williams
2007-11-26 20:57 ` Marcus Williams
0 siblings, 1 reply; 8+ messages in thread
From: Marcus Williams @ 2007-11-14 9:40 UTC (permalink / raw)
On 13.11.2007, Marcus Williams wrote:
> Mmmm. Seem to be having some buffering problems with open3 on slightly
> longer messages. The pipe stuff blocks because of it.
>
> Will have to resubmit when I figure it out.
Ok, heres the new one. I think in the pipe to command case, the
session gem is probably the best way to go (although I've not use it
here) because it handles the blocking problems for you.
This patch will:
* return an error correctly if the command returns an error initially
(like a usage error, or missing file etc)
* pipes the mail/attachment to the command
* read either stdout OR stderr, whichever is ready first and display that.
The last step is where the problem lies. If a command produces both I
cant figure out what to do with it, should it display two separate
buffers, one with errors and one with output? What happens if the
context of the error is important (ie where it is in the output
stream)?
I'm pretty sure this is an edge case, as the majority of usages of
this would be to pipe through a spam filter, or a file viewer (like
textviewer.sh from claws mail or antiword) and this patch works fine
in those cases.
Anyone any comments?
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: open3-diffs
Type: application/octet-stream
Size: 3524 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071114/5d29ac10/attachment.obj
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-12-10 6:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-09 15:33 [sup-talk] [PATCH] Pipe message/attachement to shell command Marcus Williams
2007-11-12 17:55 ` William Morgan
2007-11-12 22:06 ` Marcus Williams
2007-11-13 11:58 ` Marcus Williams
2007-11-14 9:40 ` Marcus Williams
2007-11-26 20:57 ` Marcus Williams
2007-11-26 21:01 ` Marcus Williams
2007-12-10 6:24 ` William Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox