def make_call(call):
  manager = asterisk.manager.Manager()
  manager.lock = threading.Condition()
  try:  
    try:
	call.start = datetime.datetime.now()

        # connect to the manager
        manager.connect(settings.AST_HOST)
        manager.login(settings.AST_USER, settings.AST_PASS)

        # register some callbacks
        manager.register_event('Shutdown', handle_shutdown) # shutdown
        manager.register_event('*', lambda event, manager: handle_event(event,manager,call)) # catch all

        # get a status report
        response = manager.originate(call.channel, call.extension, call.context, settings.AST_PRIO, settings.AST_TIMEOUT_ORIGINATE * 1000, call.caller_id)
        call.response = response.get_header('Response')
        with manager.lock:
            manager.lock.wait(settings.AST_TIMEOUT_HANGUP)

    except asterisk.manager.ManagerSocketException, (errno, reason):
       msg = "Error connecting to the manager: %s" % reason
       call.disposition = msg
       raise
    except asterisk.manager.ManagerAuthException, reason:
       msg = "Error logging in to the manager: %s" % reason
       call.disposition = msg
       raise
    except asterisk.manager.ManagerException, reason:
       msg = "Error: %s" % reason
       call.disposition = msg
       raise

  finally:
    # remember to clean up
    call.save()
    manager.close()
dataset/ETHPy150Open maxiberta/django-asterisk/django_asterisk/engine.py/make_call/original