import os, sys, select, subprocess

args = ['mode2', '-d', '/dev/lirc0']
p1 = subprocess.Popen(args, stdout=subprocess.PIPE)
p2 = subprocess.Popen(args, stdout=subprocess.PIPE)

while True:
    rlist, wlist, xlist = select.select([p1.stdout, p2.stdout], [], [])
    for stdout in rlist:
        sys.stdout.write('indicator: ' + os.read(stdout.fileno(), 1024).decode('utf-8'))
@@ -292,40 +292,16 @@
     
-sys.stdout.write('indicator: ' +
+output =
  os.
@@ -343,9 +343,80 @@
 'utf-8')
+%0A        if output:%0A            sys.stdout.write('indicator: ' + output
 )

modify output format