def reschedule_current_dial_set(personTable,
                                tinyResponse=False,
                                sessionID=None):
    """
    10/03/22.
    called by dsh_common_views.reschedule().
    and dsh_reschedule.py
    tinyResponse==True when called by dsh_reschedule.py.
    it just returns the number of people scheduled in that case.
    """

    response = ''

    people = personTable.objects.filter(current_dial=True)

    if not people:
        response += dsh_utils.black_break_msg(
            'No person in the current dial set.')
        if tinyResponse:
            return 0
        return response

    dsh_utils.black_break_msg('Processing the following people...')

    count = 0
    for person in people:
        calleeInfo = '<span style="white-space: nowrap;">' +\
                     dsh_django_utils.callee_info(person) + '</span>'
        response += dsh_utils.black_break_msg(calleeInfo)
        scheduled,strMsg = dsh_django_utils.check_auto_timed_calls_for_person(
            person, noLogging=True)
        if scheduled:
            strMsg = '&nbsp;&nbsp;&nbsp;&nbsp; scheduled: ' + strMsg
        else:
            strMsg = '&nbsp;&nbsp;&nbsp;&nbsp; not scheduled: ' + strMsg
        response += dsh_utils.black_break_msg(strMsg)
        count += 1

    countMsg = dsh_utils.black_break_msg(
        'number of people in the dial set processed: ' +\
        str(count) + '.')
    response += countMsg
    dsh_agi.report_event(countMsg, sessionID=sessionID)

    if tinyResponse:
        return count
    return response
def hangup_signal_handler(signum, frame):
    """called after the hangup signal is received."""

    global globals4signal
    
    dsh_utils.db_print2('dsh_failed.signal_handler: entered...', 116)
    time.sleep(1)
    
    calleeDshUid = globals4signal['callee_dsh_uid']

    if is_triggered_by_dial_now(calleeDshUid):
        sys.exit(0)
    
    callee = dsh_django_utils.get_foreign_key(Person, calleeDshUid)
    if not callee:
        message = 'dsh_failed: no such callee found: ' + calleeDshUid
        dsh_utils.give_bad_news(message, logging.error)
        dsh_agi.report_event(message, reportLevel = 'ERR',
                             sessionID=get_session())
        sys.exit(1)
    else:
        dsh_utils.db_print('dsh_failed: found callee: ' + repr(callee), 116)

    event = Event(
        owner=callee,
        phone_number=callee.phone_number,
        action='NOPU',
        etype='INF',
        description='.call not picked up. re-arming.',
        session=get_session())
    event.save()
    dsh_django_utils.check_auto_timed_calls_for_person(
        callee, sessionID=get_session())

    calleeInfo = dsh_django_utils.callee_info(callee)    
    
    dsh_utils.give_news('dsh_failed.signal_handler: rearming callee: '+\
                        calleeInfo, logging.info)