Closed sancho2934489 closed 8 years ago
Thanks for brining this to my attention! Just fixed this, and I'm cutting a new release now. Please update from PyPI =)
I am not even sure the stderr.write should be kept. I have been thinking about patching this to use python logger, @rdegges any input?
I think that's part of the AGI protocol, no? It's honestly been a few years since I've worked with this, so my memory is really fuzzy =/ If you can remove the STDERR writing and just rely on STDOUT, that'd be ideal. I'm not a fan of arbitrary log statements without using a proper logger with different log levels / etc.
AGI protocol is just stdin stdout. Stderr, should not be sent to asterisk but rather to the active shell.
I would have to test just to make sure, and yes if I did do logging it would be with standard logging library and set to different levels. Info, warn, critical, debug.
It just occurred to me that maybe the agitb module requires the stderr. I am not sure how that code work... On Feb 21, 2016 8:33 PM, "Randall Degges" notifications@github.com wrote:
I think that's part of the AGI protocol, no? It's honestly been a few years since I've worked with this, so my memory is really fuzzy =/ If you can remove the STDERR writing and just rely on STDOUT, that'd be ideal. I'm not a fan of arbitrary log statements without using a proper logger with different log levels / etc.
— Reply to this email directly or view it on GitHub https://github.com/rdegges/pyst2/issues/21#issuecomment-187003663.
I worked agi.py, was as follows: def init(self, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr): self._got_sighup = False signal.signal(signal.SIGHUP, self._handle_sighup) # handle SIGHUP self.stderr.write('ARGS: ') self.stderr.write(str(sys.argv)) self.stderr.write('\n') self.stdin = stdin self.stdout = stdout self.stderr = stderr self.env = {} self._get_agi_env()
Error: Traceback (most recent call last): File "./test.py", line 16, in
agi = AGI()
File "/usr/local/lib/python2.7/dist-packages/pyst2-0.4.8-py2.7.egg/asterisk/agi.py", line 91, in init
self.stderr.write('ARGS: ')
I did so: def init(self,stdin=sys.stdin,stdout=sys.stdout,stderr=sys.stderr): self.stdin=stdin self.stdout=stdout self.stderr=stderr self._got_sighup = False signal.signal(signal.SIGHUP, self._handle_sighup) # handle SIGHUP self.stderr.write('ARGS: ') self.stderr.write(str(sys.argv)) self.stderr.write('\n') self.env = {} self._get_agi_env() It began to work.