def launch_tails(follow_paths, lastlines_dirpath=None):
 if (lastlines_dirpath and (not os.path.exists(lastlines_dirpath))):
  os.makedirs(lastlines_dirpath)
 tail_cmd = ('/usr/bin/tail', '--retry', '--follow=name')
 procs = {}
 pipes = {}
 for path in follow_paths:
  cmd = list(tail_cmd)
  if lastlines_dirpath:
   reverse_lineno = lookup_lastlines(lastlines_dirpath, path)
   if (reverse_lineno is None):
    reverse_lineno = 1
   cmd.append(('--lines=%d' % reverse_lineno))
  cmd.append(path)
  tail_proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  procs[path] = tail_proc
  pipes[nonblocking(tail_proc.stdout)] = path
 return (procs, pipes)

def launch_tails ( follow_paths , lastlines_dirpath = None ) : if ( lastlines_dirpath and ( not os . path . exists ( lastlines_dirpath ) ) ) : os . makedirs ( lastlines_dirpath ) tail_cmd = ( '/usr/bin/tail' , '--retry' , '--follow=name' ) procs = { } pipes = { } for path in follow_paths : cmd = list ( tail_cmd ) if lastlines_dirpath : reverse_lineno = lookup_lastlines ( lastlines_dirpath , path ) if ( reverse_lineno is None ) : reverse_lineno = 1 cmd . append ( ( '--lines=%d' % reverse_lineno ) ) cmd . append ( path ) tail_proc = subprocess . Popen ( cmd , stdout = subprocess . PIPE ) procs [ path ] = tail_proc pipes [ nonblocking ( tail_proc . stdout ) ] = path return ( procs , pipes )
launch a tail process for each follow_path .