예제 #1
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())
예제 #2
0
def cellz(cellN):
    alert = "Введите номер мобильного телефона клиента: " + str(naboox.get_ip()) + ":7777/robot-control/"
    i = int(cellN[4])
    j = int(cellN[5])

    if request.method == 'POST':  # If user POST by clicking submit button any text
        while 1:
            try:
                box = ard.connect_to_box()
                break
            except:
                pass
        ard.open_doar(i, j, box)
        ID = request.form['id']
        file = "cells_ID.json"
        data = naboox.read_json(file)
        data[int(i)][int(j)] = ID
        naboox.write_json(data, file)
        alert = "Выберите ячейку: " + str(naboox.get_ip()) + ":7777/robot-control/"
        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 = "Свободно"
                exec("cell" + str(i) + str(j) + " = '" + value + "'")

        return render_template(
            "robot.html", **locals())
    return render_template(
        "cell.html", **locals())
예제 #3
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())
예제 #4
0
def make_PIN():
    PIN = random.sample(range(1000, 9999), 8)
    PIN = [PIN[0:4], PIN[4:8]]
    naboox.write_json(PIN, "cells_PIN.json")
예제 #5
0
def setup_all():
    data = [[0, 0, 0, 0], [0, 0, 0, 0]]
    naboox.write_json(data, "cells_ID.json")
    naboox.write_json(data, "cells_PIN.json")
    make_PIN()