From 60b904bf106829b2cc03322a7ffc1dcff51278ce Mon Sep 17 00:00:00 2001 From: Randall Degges Date: Tue, 31 May 2011 17:12:23 -0700 Subject: [PATCH] Adding in bugfix for issue with manager.status(). The problem is that the status command returns output in a special format, that was not being parsed correctly. This fix is a bit ugly, but is the only way (afaik) to cleanly handle the status command so that its output can be used. --- asterisk/manager.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/asterisk/manager.py b/asterisk/manager.py index da183f0..70541f6 100644 --- a/asterisk/manager.py +++ b/asterisk/manager.py @@ -274,6 +274,7 @@ class Manager(object): """ multiline = False + status = False wait_for_marker = False eolcount = 0 # loop while we are sill running and connected @@ -303,6 +304,11 @@ class Manager(object): break # ignore empty lines at start continue + # If the user executed the status command, it's a special + # case, so we need to look for a marker. + if 'status will follow' in line: + status = True + wait_for_marker = True lines.append(line) # line not ending in \r\n or without ':' isn't a # valid header and starts multiline response @@ -310,13 +316,17 @@ class Manager(object): multiline = True # Response: Follows indicates we should wait for end # marker --END COMMAND-- - if not multiline and line.startswith('Response') and \ + if not (multiline or status) and line.startswith('Response') and \ line.split(':', 1)[1].strip() == 'Follows': wait_for_marker = True # same when seeing end of multiline response if multiline and line.startswith('--END COMMAND--'): wait_for_marker = False multiline = False + # same when seeing end of status response + if status and 'StatusComplete' in line: + wait_for_marker = False + status = False if not self._connected.isSet(): break else: