Ejemplo n.º 1
0
def on_message(client, userdata, msg):
    global tDefault, tDefault1, tDefault2, tTemperature, tSmoke, tAlertSmoke, tAlertTemperature, delayAlert
    print(str(msg.topic))
    # print("Message :" + str(msg.topic.decode("utf-8")))
    # print("Message :" + str(msg.payload.decode("utf-8")))
    # print ("client"+str(datetime.datetime.now()))
    if (str(msg.topic) == "lab/temperatureTes"):
        value = str(msg.payload.decode("utf-8"))
        print(tAlertTemperature)

        if ((datetime.datetime.now() - tAlertTemperature) >= delayAlert
                and int(value) > 30):
            function.post("temperature", value)
            smsgateway.kirim_pesan(
                '082220488112',
                'Peringatan !! Suhu berbahaya. ' + value + '° Celcius')
            fcm_client.app_notification('Peringatan !! Suhu berbahaya. ' +
                                        value + '° Celcius\nWwaktu: ' +
                                        str(datetime.datetime.now()) + '')
            tAlertTemperature = datetime.datetime.now()
    #dummy
    if (str(msg.topic) == "lab/pir"):
        value = msg.payload.decode("utf-8")
        print(value)
        if ((datetime.datetime.now() - tDefault) >= delayUpdate):
            function.post("pir", value)
            tDefault = datetime.datetime.now()

        # function.put("pir",value)

    if (str(msg.topic) == "lab/temperature"):
        value = str(msg.payload.decode("utf-8"))
        print(value)
        print(tTemperature)
        if ((datetime.datetime.now() - tAlertTemperature) >= delayAlert
                and int(value) > 32):
            function.post("temperature", value)
            smsgateway.kirim_pesan(
                '082220488112',
                'Peringatan !! Suhu berbahaya. ' + value + '° Celcius')
            fcm_client.app_notification('Peringatan !! Suhu berbahaya. ' +
                                        value + '° Celcius\nWwaktu: ' +
                                        str(datetime.datetime.now()) + '')
            tAlertTemperature = datetime.datetime.now()
        elif ((datetime.datetime.now() - tTemperature) >= delayUpdate):
            function.post("temperature", value)
            tTemperature = datetime.datetime.now()

    if (str(msg.topic) == "lab/smoke"):
        #         # smsgateway.kirim_pesan("082220488112","Tingkat Asap: " + str(msg.payload.decode("utf-8")))
        #         # function.post("smoke",str(msg.payload.decode("utf-8")))
        #         # function.put("smoke",str(msg.payload.decode("utf-8")))
        value = str(msg.payload.decode("utf-8"))
        print(value)
        if ((datetime.datetime.now() - tAlertSmoke) >=
                delayAlert) and int(value) > 403:
            function.post("smoke", value)
            smsgateway.kirim_pesan("082220488112", 'Tingkat asap berbahaya.')
            fcm_client.app_notification('Waktu: ' +
                                        str(datetime.datetime.now()) +
                                        'Tingkat asap berbahaya.')
            tAlertSmoke = datetime.datetime.now()
        elif ((datetime.datetime.now() - tSmoke) >= delayUpdate):
            function.post("smoke", value)
            tSmoke = datetime.datetime.now()

    if (str(msg.topic) == "lab/current"):
        value = str(msg.payload.decode("utf-8"))
        print(value)
        if ((datetime.datetime.now() - tDefault1) >= delayUpdate):
            function.post("current", value)
            tDefault1 = datetime.datetime.now()

    if (str(msg.topic) == "lab/ldr"):
        #         print(type(msg.payload.decode("utf-8")))
        value = int(msg.payload.decode("utf-8"))
        print(value)
        if ((datetime.datetime.now() - tDefault2) >= delayUpdate):
            function.post("ldr", value)
            tDefault2 = datetime.datetime.now()
Ejemplo n.º 2
0
    select = input("Please select your choice.")
    print()
    if select == "1":
        username = input("Please type your username: "******"Please type your password: "******"1. Enter a new exploit")
                print("2. Read your exploit")
                print("3. Modify your exploit")
                print("4. Read other hacker's exploit")
                print("5. Modify your account")
                print("6. Exit")
                exploit_select = input("Please input your selection.")
                print()
                if exploit_select == "1":
                    print("Please input your content.")
                    content = input()
                    function.post("username, content")
    elif select == "2":
        username = input("Please type your username: "******"Please type your password: "******"Password too short. Please enter at least 6 characters.")
                pass
    else:
        break
Ejemplo n.º 3
0
def Verify_that_the_is_on_url_with_root_and_password(driver, nas_url, user,
                                                     password):
    """Verify that the is on "{nas_url}" with "{user}" and "{password}"."""
    results = post(nas_url, 'filesystem/stat/', (user, password),
                   f'{smb_path}/testfile.txt')
    assert results.status_code == 200, results.text
Ejemplo n.º 4
0
def post():
    return post(request)