10 fd = os.open(path, os.O_RDONLY)
11 current_ino = os.fstat(fd).st_ino
12 with os.fdopen(fd, "r") as f:
13 logging.info("Re-attached to file.")
18 if os.stat(path).st_ino != current_ino or \
19 os.stat(path).st_size < f.tell():
25 yield line.rstrip("\n")
26 except FileNotFoundError:
30 def feed_handler(cmd, data):
32 handler = subprocess.Popen(shlex.split(cmd),
33 stdin=subprocess.PIPE,
34 stdout=subprocess.PIPE,
35 stderr=subprocess.PIPE,
37 out_data, err_data = handler.communicate("%s\n" % data)
38 if handler.returncode != 0:
39 logging.warning("Handler exited with non-zero return code %d! (%s)" %
40 (handler.returncode, err_data))
41 except Exception as e:
42 logging.error("Error feeding handler: %s" % str(e))
44 def create_msg(title, icon, logfile, text, lines):
45 msg = "<b>%s</b> <i>%s</i> %s" % (title, logfile, icon)
46 msg += "<br>%s" % text
48 for line in lines: msg += line + "\n"
52 def print_list(lst, ptr):
54 for i in range(0, len(lst)):
55 txt += str( lst[(ptr + i) % len(lst)] )
56 if i < len(lst) - 1: txt += ', '