Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Exploratory query

Reply
Thread Tools

Exploratory query

 
 
Don Todd
Guest
Posts: n/a
 
      08-05-2003
I'm a total python newbie and have not really even begun to learn.
Before I start, however, I would like to know if python is the proper
tool for what I want to do.

I want to query various MH mailboxes to see if they contain new mail.
There is a program, flist, that will do this, but it is a pain to run it
every time. I'd like something a la xbiff or gbiffy.

Would python allow me to run flist and use its output, or would I need
to re-write flist? The idea is to keep something on the screen and poll
the mailboxes every n seconds and update the display.

TIA,

dt
 
Reply With Quote
 
 
 
 
Skip Montanaro
Guest
Posts: n/a
 
      08-05-2003

Don> Would python allow me to run flist and use its output, or would I
Don> need to re-write flist? The idea is to keep something on the screen
Don> and poll the mailboxes every n seconds and update the display.

You can do this quite easily. Presuming you just want to display flist's
output for now, but maybe mangle it later, you can probably get away with
something simple like this:

import time
import commands

while True:
status, output = commands.getstatusoutput("flist")
if status != 0:
print "flist barfed... exiting"
# right here you could massage output
print output
time.sleep(300) # five minutes

Skip

 
Reply With Quote
 
 
 
 
Don Todd
Guest
Posts: n/a
 
      08-05-2003
In article <(E-Mail Removed)>, Skip Montanaro wrote:
>
> Don> Would python allow me to run flist and use its output, or would I
> Don> need to re-write flist? The idea is to keep something on the screen
> Don> and poll the mailboxes every n seconds and update the display.
>
> You can do this quite easily. Presuming you just want to display flist's
> output for now, but maybe mangle it later, you can probably get away with
> something simple like this:
>
> import time
> import commands
>
> while True:
> status, output = commands.getstatusoutput("flist")
> if status != 0:
> print "flist barfed... exiting"
> # right here you could massage output
> print output
> time.sleep(300) # five minutes
>
> Skip


Thanks, Skip! That pretty much does what I want; I modified it to do
"flist mailbox1", "flist mailbox2" etc.

Is there a way to run this in a terminal and have it uptate the new over
the old? I'm thinking it would be sweet to run it in tranparent
terminal. Perhaps I'll look into using a gui, too.

dt
 
Reply With Quote
 
Skip Montanaro
Guest
Posts: n/a
 
      08-05-2003
>>>>> "Don" == Don Todd <(E-Mail Removed)> writes:

Don> In article <(E-Mail Removed)>, Skip Montanaro wrote:
>>

Don> Would python allow me to run flist and use its output, or would I
Don> need to re-write flist? The idea is to keep something on the screen
Don> and poll the mailboxes every n seconds and update the display.
>>
>> You can do this quite easily. Presuming you just want to display flist's
>> output for now, but maybe mangle it later, you can probably get away with
>> something simple like this:
>>
>> import time
>> import commands
>>
>> while True:
>> status, output = commands.getstatusoutput("flist")
>> if status != 0:
>> print "flist barfed... exiting"
>> # right here you could massage output
>> print output
>> time.sleep(300) # five minutes
>>
>> Skip


Don> Thanks, Skip! That pretty much does what I want; I modified it to
Don> do "flist mailbox1", "flist mailbox2" etc.

Also, note that I forgot the break statement in the exit branch. Should
have been:

if status != 0:
print "flist barfed... exiting"
break

Don> Is there a way to run this in a terminal and have it uptate the new
Don> over the old? I'm thinking it would be sweet to run it in
Don> tranparent terminal. Perhaps I'll look into using a gui, too.

Sure. There are a couple ways to do it. The crude way might just be to put


commands.getstatusoutput("clear")

at the top of the list. The cleaner way would probably be to use the
curses module. I've no experience to make any suggestions, but the curses
module docs at

http://www.python.org/doc/current/li...le-curses.html

have a link to Andrew Kuchling's "Curses with Python" tutorial.

Skip


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET won't retrieve query results that depend on union query Eric Nelson ASP .Net 5 02-04-2009 10:51 PM
Trying to query the Address table data of AdventureWorks database from Query Analyzer - need help! Learner ASP .Net 1 01-30-2006 08:58 PM
Build dynamic sql query for JSTL <sql:query> Anonymous Java 0 10-13-2005 10:01 PM
xpath query query David Gordon XML 2 05-18-2005 03:33 PM
Exploratory testing with Ruby Brian Marick Ruby 8 05-17-2004 04:12 AM



Advertisments