Пример #1
0
def get(installation, controller_ip):
    res = controllerHandler.get_controller(installation, controller_ip)
    if res:
            statusHandler.set_status_for_controller(res)
            return OkResponse(res)
    else:
            return ConflictResponse("Could not get controller")
Пример #2
0
def get():
    tag = {"name":"WARNING_SECOND", "value": 1, "controller_ip": "192.168.0.1", "time": "2014-10-20T11:32:33.744353"}
    installation = "66002174487292"
    installation_obj = installationHandler.get(installation, True)
    controller_obj = controllerHandler.get_controller(installation, tag['controller_ip'], True)
    customer_obj = customerHandler.get_customer(installation_obj['customer'])
    res = mailHandler.send_alarm_mail(tag, installation_obj, controller_obj, customer_obj)
    return OkResponse('Sent the mail!')
Пример #3
0
def insert(tag, debug=False):
    res = None
    controller = controllerHandler.get_controller(tag.get('installation'), tag.get('controller_ip'))
    current_tag = tag_dao.get(tag.get('installation'), tag.get('controller_ip'), tag.get('name'))
    if controller and not current_tag:
        res = tag_dao.create_tag(tag)
    if res and not debug:
        print('Inserted new tag with name: ' + tag['name'])
        sync = {}
        sync['installation'] = tag['installation']
        sync['method'] = sync_methods.INSERT
        sync['table'] = 'tags'
        sync['data'] = tag
        sync['prev'] = None
        res = syncHandler.insert(sync)
    return res
Пример #4
0
def get_tags(serial_number, controller_ip):
    res = None
    if controllerHandler.get_controller(serial_number, controller_ip):
        res = tag_dao.get_all(serial_number, controller_ip)
    return res
Пример #5
0
def get_tag_by_name(serial_number, controller_ip, name):
    res = None
    controller = controllerHandler.get_controller(serial_number, controller_ip)
    if controller:
        res = tag_dao.get(serial_number, controller_ip, name)
    return res