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"