Re: How to streamingly read text file and display whenever updated text

2013-10-07 Thread Andreas Perstinger
On 07.10.2013 03:54, galeom...@gmail.com wrote: https://docs.google.com/file/d/0B2D69u2pweEvelh1T25ra19oZEU/edit?usp=sharing For the readers who don't bother clicking on the link above: It's a short video where the OP demonstrates how her/his usage of tail doesn't work. no matter call tai

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread galeomaga
https://docs.google.com/file/d/0B2D69u2pweEvelh1T25ra19oZEU/edit?usp=sharing no matter call tail directly in python or using the script of tail all failed it seems it can not read next line -- https://mail.python.org/mailman/listinfo/python-list

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Chris Angelico
On Sun, Oct 6, 2013 at 10:31 PM, Mark Lawrence wrote: > > How do I know that you're not trying to send me to a rouge site? > I assure you, the background color is most distinctly white. They probably contract with Google for their white pixel supply: http://www.google.com.au/technology/pigeonr

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Mark Lawrence
On 06/10/2013 12:15, Chris Angelico wrote: On Sun, Oct 6, 2013 at 10:13 PM, Mark Lawrence wrote: Good point, but at least this time I typed "rogue" correctly, unlike on the tutor mailing list :) Obligatory TVTropes link. http://tvtropes.org/pmwiki/pmwiki.php/Main/RougeAnglesOfSatin ChrisA

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Chris Angelico
On Sun, Oct 6, 2013 at 10:13 PM, Mark Lawrence wrote: > Good point, but at least this time I typed "rogue" correctly, unlike on the > tutor mailing list :) Obligatory TVTropes link. http://tvtropes.org/pmwiki/pmwiki.php/Main/RougeAnglesOfSatin ChrisA -- https://mail.python.org/mailman/listinfo

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Mark Lawrence
On 06/10/2013 12:03, Chris Angelico wrote: On Sun, Oct 6, 2013 at 9:36 PM, Mark Lawrence wrote: Also note that a bare except is extremely bad practice, e.g. you can't stop rogue programs with a CTRL-C Or to be more accurate, a Ctrl-C will cause a jump to your except clause. Since, in this ins

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Chris Angelico
On Sun, Oct 6, 2013 at 9:36 PM, Mark Lawrence wrote: > Also note that a bare except is extremely bad practice, e.g. you can't stop > rogue programs with a CTRL-C Or to be more accurate, a Ctrl-C will cause a jump to your except clause. Since, in this instance, that's going to emit and die, Ctrl-C

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Mark Lawrence
On 06/10/2013 05:06, Steven D'Aprano wrote: On Sat, 05 Oct 2013 20:17:32 -0700, galeomaga wrote: if __name__ == '__main__': try: thread.start_new_thread( readfile, ("Thread-1", ) ) except: print "Error: unable to start thread" Why not? If you

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread galeomaga
I can start thread and no exception error print, and I do not know how to use tail in python script I need to cope with MySQL in python later as all file path stored in it, it is to monitor all text files -- https://mail.python.org/mailman/listinfo/python-list

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Steven D'Aprano
On Sat, 05 Oct 2013 20:17:32 -0700, galeomaga wrote: > if __name__ == '__main__': > try: > thread.start_new_thread( readfile, ("Thread-1", ) ) > except: > print "Error: unable to start thread" Why not? If you can't start a thread, you have a problem with

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 2:17 PM, wrote: > After tried many times, updated text file is not shown, it only print text at > the first time. The implementation of tail has a lot of little oddities to deal with edge cases. Why not simply use it? A while ago, I wanted to make a system that would tai

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread galeomaga
Joost Molenaar於 2013年10月5日星期六UTC+8下午7時02分05秒寫道: > A bit of googling found me this: > > http://www.linux-support.com/cms/implementation-of-tail-in-python/ > > > > import time > > import sys > > > > def tail_f(file): > > interval = 1.0 > > while True: > > where = file.tell() > >

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Mark Lawrence
On 05/10/2013 12:02, Joost Molenaar wrote: A bit of googling found me this: http://www.linux-support.com/cms/implementation-of-tail-in-python/ import time import sys def tail_f(file): interval = 1.0 while True: where = file.tell() line = file.readline() if not line:

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Joost Molenaar
A bit of googling found me this: http://www.linux-support.com/cms/implementation-of-tail-in-python/ import time import sys def tail_f(file): interval = 1.0 while True: where = file.tell() line = file.readline() if not line: time.sleep(interval) file.seek(where) els

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Nobody
On Sat, 05 Oct 2013 00:38:51 -0700, galeomaga wrote: > #!/usr/bin/python > import time > f = open('/home/martin/Downloads/a.txt') > while 1: > for line in f: > print line; > time.sleep(1); So you're trying to implement "tail -f"? First, check that "tail -f" actually wor

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Mark Lawrence
On 05/10/2013 09:06, James Harris wrote: wrote in message news:04ee91f9-1cbf-4364-bca3-da25aa4db...@googlegroups.com... #!/usr/bin/python import time f = open('/home/martin/Downloads/a.txt') Looks like you are on Unix so you can do this from the shell tail -F /home/martin/Downloads/a.tx

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Mark Lawrence
On 05/10/2013 08:54, galeom...@gmail.com wrote: if __name__ == '__main__': logfile = open("/home/martin/Downloads/a.txt","r"); while True: line = logfile.readline(); if not line: print line; time.sleep(1); this also failed Usually please s

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread James Harris
wrote in message news:04ee91f9-1cbf-4364-bca3-da25aa4db...@googlegroups.com... > > > #!/usr/bin/python > import time > f = open('/home/martin/Downloads/a.txt') Looks like you are on Unix so you can do this from the shell tail -F /home/martin/Downloads/a.txt James -- https://mail.python.or

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread galeomaga
gale...@gmail.com於 2013年10月5日星期六UTC+8下午3時38分51秒寫道: > #!/usr/bin/python > > import time > > f = open('/home/martin/Downloads/a.txt') > > while 1: > > for line in f: > > print line; > > time.sleep(1); if __name__ == '__main__': logfile = open("/home/martin/Downlo