MathFreak Apprentice
Joined: 07 Jul 2002 Posts: 217 Location: Bethlehem, PA
|
Posted: Sun Apr 13, 2003 1:31 am Post subject: FIFO's and loops with python |
|
|
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. |
|