Created
January 4, 2017 16:43
-
-
Save Alloyed/4d6c43a01f2f60ebf831485d0c73b058 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
"""Reads from argument the log file name. And displays it in real time. | |
The default log name is log.txt (which is correct if the script is launched | |
from the afterbirth folder itself) | |
It will read each line one after the other on an infinit loop. | |
If the file gets updated (ie: a line is added) it will display it and | |
lower the reading cooldown. | |
If nothing happen on the reading loop, it increase the reading cooldown. | |
author: gibonus, /u/RGibonnus | |
""" | |
from sys import argv | |
from time import sleep | |
if len(argv) > 1: | |
logloc = ' '.join(argv[1:]) | |
else: | |
logloc = 'log.txt' | |
f = open(logloc, 'r') | |
stime = 0.001 | |
while True: | |
t = f.readline() | |
if t != '': | |
stime = 0.001 | |
print(t,end='') | |
else: | |
stime = stime + 0.005 if stime < 1 else 1 | |
sleep(stime) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment