Persuade Asterisk to reload config files (from Python)


I have a python script (run as www-data), that makes changes to extensions.conf.

I need to persuade Asterisk to reload the extensions.conf file.

(And I can think of a few extemely hack-ish ways to achieve this; but I’d like to do this - if possible - in a non-hacky way.)



OK: I achieved it in the following way:

import sys
import telnetlib
HOST = "localhost"
tn = telnetlib.Telnet(HOST, 5038)
tn.write(“Action: login\r\nUsername: xxx\r\nSecret: xxx\r\n\r\nAction: command\r\nCommand: reload\r\n\r\n”)

(I obviously enabled a manager user in manager.conf)