From 386574d8ac9c25939b24fbf0f2027f5f0f429caf Mon Sep 17 00:00:00 2001 From: inpos Date: Wed, 1 Mar 2017 20:56:06 +0300 Subject: [PATCH] python3 agi send_command --- asterisk/agi.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/asterisk/agi.py b/asterisk/agi.py index 09bcde3..0707307 100755 --- a/asterisk/agi.py +++ b/asterisk/agi.py @@ -105,7 +105,8 @@ class AGI: def _get_agi_env(self): while 1: if PY3: - line = self.stdin.readline().strip().decode('utf8') + line = self.stdin.readline().strip() + if type(line) is bytes: line = line.decode('utf8') else: line = self.stdin.readline().strip() self.stderr.write('ENV LINE: ') @@ -164,7 +165,10 @@ class AGI: if command[-1] != '\n': command += '\n' self.stderr.write(' COMMAND: %s' % command) - self.stdout.write(command) + if PY3: + self.stdout.write(command.encode('utf8')) + else: + self.stdout.write(command) self.stdout.flush() def get_result(self, stdin=sys.stdin):