Example #1
0
    def loadRinorModels(self):
        from domoweb.exceptions import RinorNotConfigured, RinorNotAvailable
        from domoweb.restModel import RestModel
        from domoweb.models import Parameter, DeviceType, DataType, Device
        try:
            ip = Parameter.objects.get(key='rinor_ip')
            port = Parameter.objects.get(key='rinor_port')
        except Parameter.DoesNotExist:
            cherrypy.engine.log("RINOR not configured, pass the data loading")
        else:
            try:
                prefix = Parameter.objects.get(key='rinor_prefix')
            except Parameter.DoesNotExist:
                uri = "http://%s:%s" % (ip.value, port.value)
            else:
                uri = "http://%s:%s/%s" % (ip.value, port.value, prefix.value)

            model_loaded = False
            i = 0
            while not model_loaded:  # Wait until RINOR respond
                try:
                    i = i + 1
                    RestModel.setRestUri(uri)
                    Parameter.refresh()
                    DataType.refresh()
                    DeviceType.refresh()
                    Device.refresh()
                    model_loaded = True
                except RinorNotAvailable:
                    cherrypy.engine.log(
                        "RINOR not online wait 5s before retry #%s" % i)
                    time.sleep(5)
Example #2
0
    def loadRinorModels(self):
	from domoweb.exceptions import RinorNotConfigured, RinorNotAvailable
        from domoweb.restModel import RestModel
        from domoweb.models import Parameter, DeviceType, DataType, Device
        try:
            ip = Parameter.objects.get(key='rinor_ip')
            port = Parameter.objects.get(key='rinor_port')
        except Parameter.DoesNotExist:
            cherrypy.engine.log("RINOR not configured, pass the data loading")
        else:
            try:
                prefix = Parameter.objects.get(key='rinor_prefix')
            except Parameter.DoesNotExist:
                uri = "http://%s:%s" % (ip.value, port.value)
            else:
                uri = "http://%s:%s/%s" % (ip.value, port.value, prefix.value)
    
            model_loaded = False
            i = 0
            while not model_loaded: # Wait until RINOR respond
                try:
                    i = i + 1
                    RestModel.setRestUri(uri)
                    Parameter.refresh()
                    DataType.refresh()
                    DeviceType.refresh()
                    Device.refresh()
                    model_loaded = True
                except RinorNotAvailable:
                    cherrypy.engine.log("RINOR not online wait 5s before retry #%s" % i)
                    time.sleep(5)
Example #3
0
def config_loadrinordata(request):
    """
    @param request : the HTTP request
    @return an HttpResponse object
    """
    from domoweb.restModel import RestModel
    from domoweb.models import Parameter, DataType, DeviceType, Device

    ip = Parameter.objects.get(key='rinor_ip')
    port = Parameter.objects.get(key='rinor_port')
    try:
        prefix = Parameter.objects.get(key='rinor_prefix')
    except Parameter.DoesNotExist:
        uri = "http://%s:%s" % (ip.value, port.value)
    else:
        uri = "http://%s:%s/%s" % (ip.value, port.value, prefix.value)

    RestModel.setRestUri(uri)
    Parameter.refresh()
    DataType.refresh()
    DeviceType.refresh()
    Device.refresh()

    return redirect('index_view')  # Redirect after POST
Example #4
0
def config_loadrinordata(request):
    """
    @param request : the HTTP request
    @return an HttpResponse object
    """
    from domoweb.restModel import RestModel
    from domoweb.models import Parameter, DataType, DeviceType, Device

    ip = Parameter.objects.get(key='rinor_ip')
    port = Parameter.objects.get(key='rinor_port')
    try:
        prefix = Parameter.objects.get(key='rinor_prefix')
    except Parameter.DoesNotExist:
        uri = "http://%s:%s" % (ip.value, port.value)
    else:
        uri = "http://%s:%s/%s" % (ip.value, port.value, prefix.value)
    
    RestModel.setRestUri(uri)
    Parameter.refresh()
    DataType.refresh()
    DeviceType.refresh()
    Device.refresh()

    return redirect('index_view') # Redirect after POST