Skip to content

Commit

Permalink
supervisor4/python3
Browse files Browse the repository at this point in the history
From @nunojpg in issue coderanger#17:

> Under latest versions I found 3 issues:
> - if processes output non-ASCII output then the event RESULT message
>   sends the wrong length.
> - event_handler response is byte and not string, so all the code
>   fails.
> - empty lines are printed to log

coderanger#17
  • Loading branch information
zultron committed Oct 2, 2020
1 parent 5eeff27 commit 76084c1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions supervisor_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def main():
write_stdout('RESULT %s\n%s'%(len(data.encode("utf-8")), data)) # transition from READY to ACKNOWLEDGED

def event_handler(event, response):
line, data = response.split('\n', 1)
headers = dict([ x.split(':') for x in line.split() ])
lines = data.split('\n')
prefix = '%s %s | '%(headers['processname'], headers['channel'])
print('\n'.join([ prefix + l for l in lines ]))
line, data = response.split(b'\n', 1)
headers = dict([ x.split(b':') for x in line.split() ])
lines = data.split(b'\n')
prefix = b'%s %s | '%(headers[b'processname'], headers[b'channel'])
print(b'\n'.join([ prefix + l for l in lines if l]).decode('utf-8'))

if __name__ == '__main__':
main()

0 comments on commit 76084c1

Please sign in to comment.