def get_manager(): snsclient = boto3.client( 'sns', region_name=aws_region_name, aws_access_key_id=eventlistenerconf.aws_access_key_id, aws_secret_access_key=eventlistenerconf.aws_secret_access_key) amanager = manager.Manager() amanager.connect(asterisk_ip) amanager.login(asterisk_user, eventlistenerconf.asterisk_passwd) event_handler = functools.partial(handle_interesting_event, snsclient=snsclient) misc_event_handler = functools.partial(handle_misc_event, snsclient=snsclient) amanager.register_event('PeerStatus', event_handler) amanager.register_event('Registry', event_handler) amanager.register_event('ConfbridgeJoin', event_handler) amanager.register_event('ConfbridgeLeave', event_handler) amanager.register_event('HangupRequest', event_handler) amanager.register_event('SoftHangupRequest', event_handler) amanager.register_event('Hangup', event_handler) amanager.register_event('UserEvent', event_handler) amanager.register_event('*', misc_event_handler) return amanager
def main(argv): auth = HTTPBasicAuth(argv[2], argv[3]) url = argv[1] # connect to asterisk ami = manager.Manager() ami.connect(HOST) ami.login(USER, PASS) # get phone numbers from vcard for vurl in getAllVcardLinks(url, auth): r = requests.request("GET", vurl, auth=auth) vcard = vobject.readOne(r.content) if "tel" in vcard.contents: for telno in vcard.contents['tel']: num = tidyPhoneNumber(telno.value) if "fn" in vcard.contents: name = vcard.fn.value print("Adding/updating Number: " + num + " Name: " + name) ami.send_action({ "Action": "DBPut", "Family": "cidname", "Key": num, "Val": name }) ami.logoff() ami.close()
def __init__(self, cfg): ami = manager.Manager() ami.connect(cfg.ami_host) ami.login(cfg.ami_user, cfg.ami_pwd) self.ami = ami self.cfg = cfg
def __init__(self, config_file, group, use_agi=False, use_mgr=False): self.config_file = config_file self.group = group # Validate and parse the config config = _Config(self.config_file, self.group) (status, self.conf) = config.parse() if not status: print "[ConfigError] %s" % self.conf sys.exit(1) self.sql = _SQL(self.conf['sqlite_database']) self.log = self._setupLogging(self.conf['log_file'], self.conf['log_level']) if use_agi: self.agi = agi.AGI() if use_mgr: self.mgr = manager.Manager()
def __init__(self, username, password, host): self.__ami = manager.Manager() self.__ami.connect(host) self.__ami.login(username, password)
if (ident == 0): response = m.originate(targetURL, 102, context='name-record', priority=1) print(m.status()) lastOneFinished = False if (ident == 1): response2 = m.originate(targetURL_stephan, 102, context='name-record', priority=1) print(m.status()) lastOneFinished = True return HOST = '192.168.2.117' PORT = 5038 inter_counter = 0 m = manager.Manager() m.connect(HOST,port=PORT) m.login('managerTest', 'ainesc') targetURL = 'SIP/fonial/00497532808054' targetURL_stephan = 'SIP/fonial2/004917696734058' for i in range(2): if inter_counter == 0: response = m.originate(targetURL, 103, context='init-global-counter', priority=1, async=True) inter_counter += 1 print ("Global var initiated") else: response = m.originate(targetURL_stephan, 102, context='name-record', priority=1, async=True) inter_counter += 1 print(m.status())