예제 #1
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())
예제 #2
0
def send(type="test"):
    url = "http://pls-test.post.kz/api/service/postamat?wsdl"
    headers = {'content-type': 'text/xml'}
    file_name = "./send.xml"
    IDs = naboox.read_json("cells_ID.json")
    NUMs = naboox.read_json("cells_numbers.json")
    with open(file_name, "r") as file:
        req = file.read()
        header = req.split("<!--date-->")[0]
        head = req.split("<!--date-->")[1].split("<!--number-->")[0]
        mid = req.split("<!--date-->")[1].split("<!--number-->")[1].split(
            "<!--user-->")[0]
        tail = req.split("<!--date-->")[1].split("<!--number-->")[1].split(
            "<!--user-->")[1]
        date = datetime.datetime.now().strftime("%Y-%m-%d")
        print(header + date + head + "123123" + mid + "naboox" + tail)
    return 1

    body = []
    print(IDs)
    for i in range(len(IDs)):
        for j in range(len(IDs[i])):
            if IDs[i][j] != 0:
                print(IDs[i][j])
                body.append(header + date + head + IDs[i][j] + mid + "naboox" +
                            tail)
    for bod in body:
        response = requests.post(url,
                                 data=request.encode('utf-8'),
                                 headers=headers)
        pretyy = xml.dom.minidom.parseString(response.content)
        pretty_xml_as_string = pretyy.toprettyxml()
        print(pretty_xml_as_string)
    return 1
예제 #3
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())
예제 #4
0
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())
예제 #5
0
def send(type="test"):
    url = "http://89.218.48.181:8080/smsgate/?wsdl"
    headers = {'content-type': 'text/xml'}
    IDs = naboox.read_json("cells_ID.json")
    PINs = naboox.read_json("cells_PIN.json")
    if type == "test":
        file_name = "./request-test.xml"
    else:
        file_name = "./request.xml"
    with open(file_name, "r") as file:
        req = file.read()
        head = req.split("<!--body-->")[0]
        mid = req.split("<!--body-->")[1]
        mid_ID = mid.split("[ID]")[0]
        mid_date = mid.split("[ID]")[1].split("[date]")[0]
        mid_pin = mid.split("[ID]")[1].split("[date]")[1].split("[pin]")[0]
        mid_tail = mid.split("[ID]")[1].split("[date]")[1].split("[pin]")[1]
        tail = req.split("<!--body-->")[2]

    date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

    body = []
    print(IDs)
    for i in range(len(IDs)):
        for j in range(len(IDs[i])):
            if IDs[i][j] != 0:
                print(IDs[i][j])
                body.append(mid_ID + str(IDs[i][j]) + mid_date + \
                          str(date) + mid_pin + str(PINs[i][j]) + mid_tail)
    request = head
    print(body)
    for bod in body:
        request = request + bod
    request = request + tail
    print(request)
    response = requests.post(url,
                             data=request.encode('utf-8'),
                             headers=headers)

    pretyy = xml.dom.minidom.parseString(response.content)
    pretty_xml_as_string = pretyy.toprettyxml()
    print(pretty_xml_as_string)
    return 1
예제 #6
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())