Пример #1
0
def checkLog(_listAlert, _listAlertStack):
    sender = '01633248977'
    ip = readIP()
    for ift in ip:
        _lineLog = ift
    #print(_lineLog)
    _warning, _root, _ipsource, _iptarget, _attack, _time, _timeStart, _date = _lineLog.split(
        ':')
    strcontent = _timeStart + ' WA' + _attack + ' ' + _time + ' from ' + _ipsource + ' to ' + _iptarget + ' ' + _date
    if (strcontent not in _listAlert and strcontent not in _listAlertStack):
        _listAlert.append(strcontent)
        #print(strcontent)
    if (compareTime(_timeStart,
                    datetime.datetime.now().strftime('%H%M%S'))._time <= 60
            and strcontent in _listAlert
            and strcontent not in _listAlertStack):
        #print(_time)
        try:
            sendSMS(strcontent, sender)
            _listAlert.remove(strcontent)
            _listAlertStack.append(strcontent)
        except:
            print('Check module sendsms')
Пример #2
0
def main():
    config = getConfig()
    my_number = config['General']['MY_NUMBER']

    sendSMS(input(), my_number)
Пример #3
0
    ratio = nomask_count / (mask_count + nomask_count + 0.000001)

    if ratio >= 0.1 and nomask_count >= 3:
        text = "Danger !"
        cv2.putText(frame, text, (W - 100, int(border_size - 50)),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.65, [26, 13, 247], 2)
        if fps._numFrames >= next_frame_towait:  #to send danger sms again,only after skipping few seconds
            msg = "**Face Mask System Alert** %0A%0A"
            msg += "Camera ID: C001 %0A%0A"
            msg += "Status: Danger! %0A%0A"
            msg += "No_Mask Count: " + str(nomask_count) + " %0A"
            msg += "Mask Count: " + str(mask_count) + " %0A"
            datetime_ist = datetime.now(IST)
            msg += "Date-Time of alert: %0A" + datetime_ist.strftime(
                '%Y-%m-%d %H:%M:%S %Z')
            sendSMS(msg, [7041677471])
            print('Sms sent')
            next_frame_towait = fps._numFrames + (5 * 25)

    elif ratio != 0 and np.isnan(ratio) != True:
        text = "Warning !"
        cv2.putText(frame, text, (W - 100, int(border_size - 50)),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.65, [0, 255, 255], 2)

    else:
        text = "Safe "
        cv2.putText(frame, text, (W - 100, int(border_size - 50)),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.65, [0, 255, 0], 2)

    # ensure at least one detection exists
    if len(idxs) > 0:
Пример #4
0
def watcherseye(queue, stop):  #queue watcher
    while True:
        if stop.value:
            print('watcherseye OFF')
            exit()
        sleep(1)
        if queue.empty() == False:
            n = queue.get_nowait()
            print("n", n)
            prefix = 'WARNING'
            msg, msg1, msg2 = '', '', ''
            if int(n['numpvs']) == 0:  #for future implementation
                msg = 'ERROR on monitor.py'
                pass
            elif int(n['numpvs']) == 1:
                msg = prefix + '\n\r' + n['rule1']
                msg = msg.replace('==', '=', 1)
                msg = msg.replace('!=', '=', 1)
                msg = msg.replace('>=', '=', 1)
                msg = msg.replace('<=', '=', 1)
                msg = msg.replace('>', '=', 1)
                msg = msg.replace('<', '=', 1)
                msg = msg.replace('L', n['value1'], 1)
                msg = msg.replace('pv', n['pv1'], 1)
                msg = msg + '\n\r' + 'Limit: ' + n[
                    'limits1'] + '\n\rRule: ' + n['rule1']
            elif int(n['numpvs']) == 2:
                if (n['rule1'].find('(pv < LL) or (pv > LU)') !=
                        -1):  #outside range
                    msg1 = prefix + '\n\r1) ' + n['pv1'] + ' = ' + n[
                        'value1'] + '\n\r' + 'Limits: ' + n[
                            'limits1'] + '\n\rRule: ' + n['rule1']
                    print('pv1 outside range')
                elif (n['rule1'].find('(pv > LL) and (pv < LU)') !=
                      -1):  #within range
                    msg1 = prefix + '\n\r1) ' + n['pv1'] + ' = ' + n[
                        'value1'] + '\n\r' + 'Limits: ' + n[
                            'limits1'] + '\n\rRule: ' + n['rule1']
                    print('pv1 within range')
                elif (bool(re.search('^pv .+ L$',
                                     n['rule1']))) != -1:  #other rules
                    msg1 = prefix + '\n\r1) ' + n['rule1']
                    msg1 = msg1.replace('==', '=', 1)
                    msg1 = msg1.replace('!=', '=', 1)
                    msg1 = msg1.replace('>=', '=', 1)
                    msg1 = msg1.replace('<=', '=', 1)
                    msg1 = msg1.replace('>', '=', 1)
                    msg1 = msg1.replace('<', '=', 1)
                    msg1 = msg1.replace('L', n['value1'], 1)
                    msg1 = msg1.replace('pv', n['pv1'], 1)
                    msg1 = msg1 + '\n\r' + 'Limit: ' + n[
                        'limits1'] + '\n\rRule: ' + n['rule1']
                    print('pv1 pv=L choice')
                if (n['rule2'].find('(pv < LL) or (pv > LU)') !=
                        -1):  #outside range
                    msg2 = '\n\r2) ' + n['pv2'] + ' = ' + n[
                        'value2'] + '\n\r' + 'Limits: ' + n[
                            'limits2'] + '\n\rRule: ' + n['rule2']
                elif (n['rule2'].find('(pv > LL) and (pv < LU)') !=
                      -1):  #within range
                    msg2 = '\n\r2) ' + n['pv2'] + ' = ' + n[
                        'value2'] + '\n\r' + 'Limits: ' + n[
                            'limits2'] + '\n\rRule: ' + n['rule2']
                    print('pv2 within range')
                elif (bool(re.search('^pv .+ L$', n['rule2']))):  #other rules
                    msg2 = '\n\r2) ' + n['rule2']
                    msg2 = msg2.replace('==', '=', 1)
                    msg2 = msg2.replace('!=', '=', 1)
                    msg2 = msg2.replace('>=', '=', 1)
                    msg2 = msg2.replace('<=', '=', 1)
                    msg2 = msg2.replace('>', '=', 1)
                    msg2 = msg2.replace('<', '=', 1)
                    msg2 = msg2.replace('L', n['value2'])
                    msg2 = msg2.replace('pv', n['pv2'])
                    msg2 = msg2 + '\n\r' + 'Limit: ' + n[
                        'limits2'] + '\n\rRule: ' + n['rule2']
                    print('pv2 pv=L choice')
                msg = msg1 + msg2
                msg = (msg[:149]) if len(msg) > 149 else msg
            elif int(n['numpvs']) == 3:
                pass
            r = sendsms.sendSMS(sub("[^0-9]", "", n['phone']), msg)
            print('r', r)
            print("msg", msg)
            if r == True:
                writer.write(msg)
            else:
                writer.write('Modem error: ' + str(r))
        else:
            sleep(1)