From f45bc1f1c571ee0f2f39571e406c46244f557e8c Mon Sep 17 00:00:00 2001 From: inpos Date: Wed, 1 Mar 2017 21:43:02 +0300 Subject: [PATCH] python3 agi get_result --- asterisk/agi.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/asterisk/agi.py b/asterisk/agi.py index 0707307..3dba46b 100755 --- a/asterisk/agi.py +++ b/asterisk/agi.py @@ -104,11 +104,9 @@ class AGI: def _get_agi_env(self): while 1: + line = self.stdin.readline().strip() if PY3: - 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: ') self.stderr.write(line) self.stderr.write('\n') @@ -176,6 +174,8 @@ class AGI: code = 0 result = {'result': ('', '')} line = self.stdin.readline().strip() + if PY3: + if type(line) is bytes: line = line.decode('utf8') self.stderr.write(' RESULT_LINE: %s\n' % line) m = re_code.search(line) if m: @@ -203,6 +203,8 @@ class AGI: while line[:3] != '520': usage.append(line) line = self.stdin.readline().strip() + if PY3: + if type(line) is bytes: line = line.decode('utf8') usage.append(line) usage = '%s\n' % '\n'.join(usage) raise AGIUsageError(usage)