def robot():
    alert = "Выберите ячейку и мой IP: " + str(naboox.get_ip()) + ":7777/robot-control/"
    file = "cells_ID.json"
    cell = naboox.read_json(file)

    for i in range(len(cell)):
        for j in range(len(cell[i])):
            if cell[i][j] != 0:
                value = "Занято"
            else:
                value = "Свободно"
            command = "cell" + str(i) + str(j) + " = '" + value + "'"
            exec(command)

    if request.method == "POST":
        passcode = request.form['passcode']
        ids, truepass, timer = read_config()
        if passcode == truepass:
            msg = "Кто-то зашел в кабинет"
            naboox.send_tlg_msg(msg, ids)
            return render_template(
                "robot.html", **locals())
        else:
            alert = "Вы ввели неправильный пароль"
            msg = "Кто-то пытался зайти в кабинет, используя неправильный пароль"
            naboox.send_tlg_msg(msg, ids)
            return render_template(
                "login.html", **locals())
    return render_template(
        "robot.html", **locals())
Exemple #2
0
def send():
    alert = "Введите пароль от посылки из СМС, и закройте крышку после себя, пожалуйста"
    # if check_time():
    #     msg = "Поехал домой"
    #     naboox.send_tlg_msg(msg, ids)
    # #     time.sleep(30)
    #     # try:
    #     #     motor.motion(mot, "A")
    #     # except:
    #     #     msg = "Что случилось по пути домой, не могу доехать"
    #     #     naboox.send_tlg_msg(msg, ids)
    #     # msg = "Я возле двери, впустите меня домой"
    #     # naboox.send_tlg_msg(msg, ids)
    #     return render_template(
    #         "hello.html", **locals())
    if request.method == 'POST':  # If user POST by clicking submit button any text
        PIN = request.form['passcode']
        file = "cells_PIN.json"
        passc = naboox.read_json(file)
        file = "cells_ID.json"
        cell = naboox.read_json(file)
        for i in range(len(passc)):
            for j in range(len(passc[i])):
                print("Checking " + str(i) + str(j))
                if int(PIN) == int(passc[i][j]):
                    # while 1:
                    #     try:
                    #         mot, box = ard.connect_to()
                    #         break
                    #     except:
                    #
                    #         pass
                    # ard.open_doar(i, j, box)
                    msg = "Отдал посылку клиента: " + str(cell[i][j])
                    naboox.send_tlg_msg(msg, ids)
                    cell[i][j] = 0
                    naboox.write_json(cell, "cells_ID.json")
                    value = "Открыто на 10 секунд"
                    exec("cell" + str(i) + str(j) + " = '" + value + "'")
                    return render_template(
                        "robot2.html", **locals())
        msg = "Вводят неправильный пароль"
        naboox.send_tlg_msg(msg, ids)
        alert = "Неправильный пароль"

    file = "cells_ID.json"
    cell = naboox.read_json(file)

    value = 0
    for i in range(len(cell)):
        for j in range(len(cell[i])):
            if cell[i][j] != 0:
                value = 1
    if value == 0:
        alert = "Еду домой"
        return render_template(
            "robot3.html", **locals())
    else:
        return render_template(
            "pin.html", **locals())
Exemple #3
0
def homeway():
    print("Go Home!")
    msg = "Я поехал домой"
    naboox.send_tlg_msg(msg, ids)
    # x = input("Доехал домой?")
    alert = "Мой IP: " + str(naboox.get_ip()) + ":7777/robot-control/"
    msg = "Я приехал домой и мой IP: " + str(naboox.get_ip())
    naboox.send_tlg_msg(msg, ids)
    return render_template("hello.html", **locals())
Exemple #4
0
def sended(i):
    if int(i) == 0:
        # naboox.write_json(time.time(), "start.json")
        msg = "Я поехал доставлять посылки"
        naboox.send_tlg_msg(msg, ids)
        time.sleep(10)
        # x = input("Доехал?")
        smsgate.send("real")
        msg = "Я приехал на АстанаХаб"
        naboox.send_tlg_msg(msg, ids)
    alert = "Чтобы получить посылку нажмите:"
    return render_template("sended.html", **locals())
Exemple #5
0
def send():
    alert = "Введите пароль от посылки из СМС, и закройте крышку после себя, пожалуйста"
    if request.method == 'POST':  # If user POST by clicking submit button any text
        PIN = request.form['passcode']
        file = "cells_PIN.json"
        passc = naboox.read_json(file)
        file = "cells_ID.json"
        cell = naboox.read_json(file)
        for i in range(len(passc)):
            for j in range(len(passc[i])):
                print("Checking " + str(i) + str(j))
                if int(PIN) == int(passc[i][j]):
                    while 1:
                        try:
                            box = ard.connect_to_box()
                            break
                        except:
                            pass
                    ard.open_doar(i, j, box)
                    msg = "Отдал посылку клиента: " + str(cell[i][j])
                    naboox.send_tlg_msg(msg, ids)
                    cell[i][j] = 0
                    naboox.write_json(cell, "cells_ID.json")
                    value = "Открыто на 10 секунд"
                    exec("cell" + str(i) + str(j) + " = '" + value + "'")
                    return render_template("robot2.html", **locals())
        msg = "Вводят неправильный пароль"
        naboox.send_tlg_msg(msg, ids)
        alert = "Неправильный пароль"

    file = "cells_ID.json"
    cell = naboox.read_json(file)

    value = 0
    for i in range(len(cell)):
        for j in range(len(cell[i])):
            if cell[i][j] != 0:
                value = 1
    if value == 0:
        alert = "Еду домой"
        return render_template("robot3.html", **locals())
    else:
        return render_template("pin.html", **locals())
    alert = "Мой IP: " + str(naboox.get_ip()) + ":7777/robot-control/"
    msg = "Я приехал домой и мой IP: " + str(naboox.get_ip())
    naboox.send_tlg_msg(msg, ids)
    return render_template(
        "hello.html", **locals())

# Login page, no authorisation with password
@app.route("/sended/<i>/", methods=["GET", "POST"])
def sended(i):
    if int(i) == 0:
        # naboox.write_json(time.time(), "start.json")
        msg = "Я поехал доставлять посылки"
        naboox.send_tlg_msg(msg, ids)
        time.sleep(10)
        x = input("Доехал?")
        smsgate.send("real")
        msg = "Я приехал на АстанаХаб"
        naboox.send_tlg_msg(msg, ids)
    alert = "Чтобы получить посылку нажмите:"
    return render_template(
        "sended.html", **locals())


# Main flask app
if __name__ == "__main__":
    # time.sleep(300)
    id, passcode4, timer4 = read_config()
    msg = "Я включился, мой IP: " + str(naboox.get_ip())
    naboox.send_tlg_msg(msg, id)
    app.run("0.0.0.0", port=7777, debug=True)