python3 agi send_command

master
inpos 2017-03-01 20:56:06 +03:00
parent d81fa0ea5f
commit 386574d8ac
1 changed files with 6 additions and 2 deletions

View File

@ -105,7 +105,8 @@ class AGI:
def _get_agi_env(self): def _get_agi_env(self):
while 1: while 1:
if PY3: if PY3:
line = self.stdin.readline().strip().decode('utf8') line = self.stdin.readline().strip()
if type(line) is bytes: line = line.decode('utf8')
else: else:
line = self.stdin.readline().strip() line = self.stdin.readline().strip()
self.stderr.write('ENV LINE: ') self.stderr.write('ENV LINE: ')
@ -164,6 +165,9 @@ class AGI:
if command[-1] != '\n': if command[-1] != '\n':
command += '\n' command += '\n'
self.stderr.write(' COMMAND: %s' % command) self.stderr.write(' COMMAND: %s' % command)
if PY3:
self.stdout.write(command.encode('utf8'))
else:
self.stdout.write(command) self.stdout.write(command)
self.stdout.flush() self.stdout.flush()