Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
FIFO's and loops with python
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
MathFreak
Apprentice
Apprentice


Joined: 07 Jul 2002
Posts: 217
Location: Bethlehem, PA

PostPosted: Sun Apr 13, 2003 1:31 am    Post subject: FIFO's and loops with python Reply with quote

I thought the program described here https://forums.gentoo.org/viewtopic.php?t=25595#145426 sounded pretty nifty and decided to write something like that on my own (yes, I know about signify, but I wanted to do it myself). After googling, I found out that I should use a FIFO to accomplish this. Anyway, here's a snippet of the code I came up with:
Code:
while 1:
   fortune = os.popen('fortune -s')
   uptime = os.popen('uptime')
   fifo = open(signame,'w')
   fifo.write(name+ '\n')
   fifo.write(strip(uptime.read())+'\n')
   fifo.write(fortune.read())
   fifo.close()
   sleep(.1)


where signame is '~/.signature' and name is my real name.
My question is about the sleep statement. If I don't put it in there, 'cat .signature' will sometimes spit out multiple signatures at once. The sleep(.1) stops this. It just seems to me that there's probably a better way to do this, but I can't seem to find it.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum