From b4b1ba31dc7eccddfd5a702ef901d656a79e4115 Mon Sep 17 00:00:00 2001 From: sqozz Date: Thu, 25 Feb 2021 10:35:02 +0100 Subject: [PATCH] Fix status parsing The get_status method now parses the output from linphone more dynamically. This allows to fetch status information while in different states of a call (ringing, call established, etc). --- pylinphone.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pylinphone.py b/pylinphone.py index b9d9ac2..57da1a7 100644 --- a/pylinphone.py +++ b/pylinphone.py @@ -109,12 +109,10 @@ class LinphoneCommunicationSocket(): answer = self.send_command("call-status {call_id}".format(call_id=call_id)) if answer["status"]: data = answer["data"] - status = { - "state": data[0].split(":", 1)[1].strip(), - "from": data[1].split(":", 1)[1].strip(), - "direction": data[2].split(":", 1)[1].strip(), - "duration": int(data[3].split(":", 1)[1].strip()) - } + status = {} + for line in data: + key, value = line.split(":", 1) + status[key.strip().lower()] = value.strip() return status else: raise RuntimeError(answer["error"])