asterisk agi psyt2 오류 수정
pst2 버그 수정
Asterisk용 agi 라이브러리 설치
구린내 나는 pst2
$ pip install pyst2
agi 테스트용 extensions.confextensions.conf
exten =>1200,1,Answer()
exten =>1200,n,agi(agitest0.py,"こんにちは、東京")
exten =>1200,n,Verbose(返り値は、${retval})
exten =>1200,n.Hangup()
/var/lib/asterisk/agi-bin 아래 설정.agitest0.py
#!/usr/local/bin/python3.6
from asterisk.agi import *
import sys
agi = AGI()
para=sys.argv[1]
agi.verbose(para)
agi.set_variable('retval', para)
착오가 되다.github에도 오류 보고가 있습니다
실행 결과
return ''.join(['"', string.encode('utf8', 'ignore'), '"'])
TypeError: sequence item 1: expected str instance, bytes found
== Using SIP RTP CoS mark 5
> 0x73c077a8 -- Strict RTP learning after remote address set to: 192.168.1.10:53506
-- Executing [1200@default:1] Answer("SIP/201-00000001", "") in new stack
> 0x73c077a8 -- Strict RTP switching to RTP target address 192.168.1.10:53506 as source
-- Executing [1200@default:2] AGI("SIP/201-00000001", "agitest0.py,"こんにちは、東京"") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/agitest0.py
ARGS: ['/var/lib/asterisk/agi-bin/agitest0.py', 'こんにちは、東京']
ENV LINE: agi_request: agitest0.py
ENV LINE: agi_channel: SIP/201-00000001
ENV LINE: agi_language: ja
ENV LINE: agi_type: SIP
ENV LINE: agi_uniqueid: 1559018403.2
ENV LINE: agi_version: 16.3.0
ENV LINE: agi_callerid: 201
ENV LINE: agi_calleridname: 201
ENV LINE: agi_callingpres: 0
ENV LINE: agi_callingani2: 0
ENV LINE: agi_callington: 0
ENV LINE: agi_callingtns: 0
ENV LINE: agi_dnid: 1200
ENV LINE: agi_rdnis: unknown
ENV LINE: agi_context: default
ENV LINE: agi_extension: 1200
ENV LINE: agi_priority: 2
ENV LINE: agi_enhanced: 0.0
ENV LINE: agi_accountcode:
ENV LINE: agi_threadid: 1897927712
ENV LINE: agi_arg_1: こんにちは、東京
ENV LINE:
class AGI: self.env = {'agi_accountcode': '',
'agi_arg_1': 'こんにちは、東京',
'agi_callerid': '201',
'agi_calleridname': '201',
'agi_callingani2': '0',
'agi_callingpres': '0',
'agi_callingtns': '0',
'agi_callington': '0',
'agi_channel': 'SIP/201-00000001',
'agi_context': 'default',
'agi_dnid': '1200',
'agi_enhanced': '0.0',
'agi_extension': '1200',
'agi_language': 'ja',
'agi_priority': '2',
'agi_rdnis': 'unknown',
'agi_request': 'agitest0.py',
'agi_threadid': '1897927712',
'agi_type': 'SIP',
'agi_uniqueid': '1559018403.2',
'agi_version': '16.3.0'}
Traceback (most recent call last):
File "/var/lib/asterisk/agi-bin/agitest0.py", line 6, in <module>
agi.verbose(para)
File "/usr/local/lib/python3.6/site-packages/asterisk/agi.py", line 616, in verbose
self.execute('VERBOSE', self._quote(message), level)
File "/usr/local/lib/python3.6/site-packages/asterisk/agi.py", line 128, in _quote
return ''.join(['"', string.encode('utf8', 'ignore'), '"'])
TypeError: sequence item 1: expected str instance, bytes found
-- <SIP/201-00000001>AGI Script agitest0.py completed, returning 0
-- Executing [1200@default:3] Verbose("SIP/201-00000001", "返り値は、") in new stack
返り値は、
-- Auto fallthrough, channel 'SIP/201-00000001' status is 'UNKNOWN'
변경 후 일본어utf-8 문제 순조롭게 해결설치 방법
수정된 파일
설치 방법
pi@raspberrypi:~/pyst2 $ git clone https://github.com/yutakahirata/pyst2.git
Cloning into 'pyst2'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 596 (delta 0), reused 7 (delta 0), pack-reused 585
Receiving objects: 100% (596/596), 740.37 KiB | 551.00 KiB/s, done.
Resolving deltas: 100% (315/315), done.
pi@raspberrypi:~/pyst2 $ cd pyst2
pi@raspberrypi:~/pyst2/pyst2 $ ls
CHANGELOG MANIFEST.in Makefile README.rst assets asterisk docs doctrees examples setup.py
pi@raspberrypi:~/pyst2/pyst2 $ sudo su
root@raspberrypi:/home/pi/pyst2/pyst2# python setup.py install
수정 결과== Using SIP RTP CoS mark 5
> 0x74104f10 -- Strict RTP learning after remote address set to: 192.168.1.10:59718
-- Executing [1200@default:1] Answer("SIP/201-00000000", "") in new stack
> 0x74104f10 -- Strict RTP switching to RTP target address 192.168.1.10:59718 as source
-- Executing [1200@default:2] AGI("SIP/201-00000000", "agitest0.py,"こんにちは、東京"") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/agitest0.py
ARGS: ['/var/lib/asterisk/agi-bin/agitest0.py', 'こんにちは、東京']
ENV LINE: agi_request: agitest0.py
ENV LINE: agi_channel: SIP/201-00000000
ENV LINE: agi_language: ja
ENV LINE: agi_type: SIP
ENV LINE: agi_uniqueid: 1559020411.0
ENV LINE: agi_version: 16.3.0
ENV LINE: agi_callerid: 201
ENV LINE: agi_calleridname: 201
ENV LINE: agi_callingpres: 0
ENV LINE: agi_callingani2: 0
ENV LINE: agi_callington: 0
ENV LINE: agi_callingtns: 0
ENV LINE: agi_dnid: 1200
ENV LINE: agi_rdnis: unknown
ENV LINE: agi_context: default
ENV LINE: agi_extension: 1200
ENV LINE: agi_priority: 2
ENV LINE: agi_enhanced: 0.0
ENV LINE: agi_accountcode:
ENV LINE: agi_threadid: 1876464672
ENV LINE: agi_arg_1: こんにちは、東京
ENV LINE:
class AGI: self.env = {'agi_accountcode': '',
'agi_arg_1': 'こんにちは、東京',
'agi_callerid': '201',
'agi_calleridname': '201',
'agi_callingani2': '0',
'agi_callingpres': '0',
'agi_callingtns': '0',
'agi_callington': '0',
'agi_channel': 'SIP/201-00000000',
'agi_context': 'default',
'agi_dnid': '1200',
'agi_enhanced': '0.0',
'agi_extension': '1200',
'agi_language': 'ja',
'agi_priority': '2',
'agi_rdnis': 'unknown',
'agi_request': 'agitest0.py',
'agi_threadid': '1876464672',
'agi_type': 'SIP',
'agi_uniqueid': '1559020411.0',
'agi_version': '16.3.0'}
COMMAND: VERBOSE "こんにちは、東京" 1
agitest0.py,"こんにちは、東京": こんにちは、東京
RESULT_LINE: 200 result=1
RESULT_DICT: {'result': ('1', '')}
COMMAND: SET VARIABLE "retval" "こんにちは、東京"
RESULT_LINE: 200 result=1
RESULT_DICT: {'result': ('1', '')}
-- <SIP/201-00000000>AGI Script agitest0.py completed, returning 0
-- Executing [1200@default:3] Verbose("SIP/201-00000000", "返り値は、こんにちは、東京") in new stack
返り値は、こんにちは、東京
Reference
이 문제에 관하여(asterisk agi psyt2 오류 수정), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hiratarich/items/6c0db9b2f1759e5077b0텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)