def main():
    global globals4signal

    globals4signal["session_id"] = dvoice.db.models.assign_dsh_uid()

    dsh_django2.init_log("dsh_failed: entered, session %s --------------------" % (get_session(),))

    #
    # get the AGI environment variables.
    # chicken out if it's not due to .call failure.
    #
    env = dsh_agi.read_env()
    if env == {}:
        message = "dsh_failed: failed to read agi envs."
        dsh_utils.give_bad_news(message, logging.error)
        dsh_agi.report_event(message, reportLevel="ERR", sessionID=get_session())
        sys.exit(1)

    if not env.has_key("agi_channel"):
        message = "dsh_failed: no agi_channel."
        dsh_utils.give_bad_news(message, logging.error)
        dsh_agi.report_event(message, reportLevel="ERR", sessionID=get_session())
        sys.exit(1)

    if env["agi_channel"] != "OutgoingSpoolFailed":
        message = "dsh_failed: unexpected agi_channel: " + env["agi_channel"]
        dsh_utils.give_bad_news(message, logging.error)
        dsh_agi.report_event(message, reportLevel="ERR", sessionID=get_session())
        sys.exit(1)

    dsh_config.init(env)

    #
    # get the dsh_uid of the callee from the command argument.
    #
    dsh_utils.db_print("dsh_failed: arguments are: " + repr(sys.argv), 116)
    if len(sys.argv) < 2:
        message = "dsh_failed: not enough arguments."
        dsh_utils.give_bad_news(message, logging.error)
        dsh_agi.report_event(message, reportLevel="ERR", sessionID=get_session())
        sys.exit(1)

    calleeDshUid = sys.argv[1].strip()
    if not calleeDshUid:
        message = "dsh_failed: no dshUid found."
        dsh_utils.give_bad_news(message, logging.error)
        dsh_agi.report_event(message, reportLevel="ERR", sessionID=get_session())
        sys.exit(1)

    dsh_utils.db_print("dsh_failed: calleeDshUid: " + calleeDshUid, 116)
    globals4signal["callee_dsh_uid"] = calleeDshUid

    #
    # let's sever ties with Asterisk.
    # this ensures the old .call file is deleted.
    #
    signal.signal(signal.SIGHUP, hangup_signal_handler)
    dsh_agi.send_command("HANGUP\n", caller="dsh_failed:")

    sys.exit(0)
def main():

    dsh_django2.init_log('dsh_stats_log.py: entered --------------------')
    sortBy = dsh_config.lookup('STATS_SORT_BY')

    success,response,totals = dsh_stats.stats_calculate(
        sortBy=sortBy, logAction='STT1', textLog=True)
    
    sys.exit(0)
def main():

    dsh_django2.init_log('dv2/dsh_reschedule.py: entered --------------------')
    dsh_common_selection.reschedule_script_call(Person)
    sys.exit(0)