printing to stdout

richard lucassen mailinglists at lucassen.org
Thu Aug 16 16:37:13 EDT 2018


I can run a shell script from the commandline as root in which I start
a python script as user "ha". The output to stdout and stderr
generated by the python script is visible in an xterm:

#!/bin/dash
exec 2>&1
chpst -u ha:ha:i2c -U ha /usr/local/ha/init.sh
exec chpst -u ha:ha:i2c:gpio /usr/local/ha/wait4int.py

So far so good. But when I run the script supervised by runit, I can
see the output generated by the shell script "init.sh", but the output
of the python script is not transferred to the supervised logging. The
python script itself works, it reads out some I/O expanders on a
Raspberry Pi. But the output of the "print" commands seems to disappear:

[..]
while True:
  if GPIO.input(23) == 1: # if still 0, another event has occurred
    GPIO.wait_for_edge(23, GPIO.FALLING)
  print ('-------')
  while GPIO.input(23) == 0:
    for pcf in pcf_present:
      output = bus.read_byte(pcf)
      print ("%x: %x" % (pcf, output))
      if GPIO.input(23) == 1:
        loopcntr = 0
        break
      else:
        loopcntr += 1
        if loopcntr >=20:
          print ('[ALERT] possible INT loop, disable 10 seconds')
          sleep (10)
GPIO.cleanup()

Anyone a hint? Note: I'm a newbie to python.

-- 
richard lucassen
http://contact.xaq.nl/



More information about the Python-list mailing list