Example #1
0
    def upload_log_file(self,myFile,serial_number):

        if installationHandler.get(serial_number):
            size = 0
            for x in range(1,6):
                print("loops" + str(x))
                if os.path.isfile(myFile.filename + "." + str(x)) is True:
                    x +=1
                elif os.path.isfile(myFile.filename + "." + str(x)) is False and x > 1:
                    file = open(myFile.filename + "." + str(x), "w+")
                    data = open(myFile.filename + "." + str(x-1))
                    file.write(data.read())
                    file.close()
                    return myFile
                else:
                    file = open(myFile.filename + "." + str(x), "w+")
                    while True:
                        data = myFile.file.read(8192)
                        file.write(str(data))
                        if not data:
                            break
                        size += len(data)
                        file.close()
                        break
                    return myFile
        else:
            raise cherrypy.HTTPError('404', 'Unregistered device.')
Example #2
0
def insert(controller):
    res = None
    if installationHandler.get(controller.get('installation')):
        if not controllers_dao.get_controller(controller.get('ip'),
                                              controller.get('installation')):
            res = controllers_dao.create_controller(controller)
    return res
Example #3
0
def get(installation):
    res = installationHandler.get(installation)
    if res:
        statusHandler.set_status_for_installation(res)
        return OkResponse(res)
    else:
        return ConflictResponse("Could not get the installation")
Example #4
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!')
Example #5
0
def get_controllers(serial_number):
    res = None
    if installationHandler.get(serial_number):
        res = controllers_dao.get_all(serial_number)
    return res
Example #6
0
def get_controller(serial_number, controller_ip, internal=False):
    res = None
    if installationHandler.get(serial_number, internal):
        res = controllers_dao.get_controller(controller_ip, serial_number)
    return res
Example #7
0
def get_controllers(serial_number):
    res = None
    if installationHandler.get(serial_number):
        res = controllers_dao.get_all(serial_number)
    return res
Example #8
0
def get_controller(serial_number, controller_ip, internal=False):
    res = None
    if installationHandler.get(serial_number, internal):
        res = controllers_dao.get_controller(controller_ip, serial_number)
    return res
Example #9
0
def insert(controller):
    res = None
    if installationHandler.get(controller.get('installation')):
        if not controllers_dao.get_controller(controller.get('ip'), controller.get('installation')):
            res = controllers_dao.create_controller(controller)
    return res