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)
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)
def addField(cls, option): types = json.loads(option.types) for t in types: types += DataType.getChilds(id=t) sensors = Sensor.getTypesFilter(types=types) if (option.group): cls.addGroupModelChoiceField(key=option.key, label=option.name, min=option.groupmin, max=option.groupmax, queryset=sensors, group_by_field='device_id', empty_label="--Select Sensor--", help_text=option.description) else: cls.addModelChoiceField(key=option.key, label=option.name, required=option.required, queryset=sensors, group_by_field='device_id', empty_label="--Select Sensor--", help_text=option.description)
def addField(cls, option): types = json.loads(option.types) datatypes = [] for t in types: args = () for d in t: l = [d] l += DataType.getChilds(id=d) args += (l,) for p in itertools.product(*args): datatypes.append(''.join(p)) commands = Command.getTypesFilter(types=datatypes) cls.addGroupedModelChoiceField(key=option.key, label=option.name, required=option.required, queryset=commands, group_by_field='device_id', empty_label="--Select Command--", help_text=option.description)
def addField(cls, option): types = json.loads(option.types) datatypes = [] for t in types: args = () for d in t: l = [d] l += DataType.getChilds(id=d) args += (l,) for p in itertools.product(*args): datatypes.append(''.join(p)) commands = Command.getTypesFilter(types=datatypes) cls.addModelChoiceField(key=option.key, label=option.name, required=option.required, queryset=commands, group_by_field='device_id', empty_label="--Select Command--", help_text=option.description)
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
def loadDatatypes(cls, develop): session = Session() # get all datatypes logger.info(u"MQ: Loading Datatypes") msg = MQMessage() msg.set_action('datatype.get') res = cli.request('manager', msg.get(), timeout=10) if res is not None: _data = res.get_data()['datatypes'] else: _data = {} session.query(DataType).delete() for type, params in _data.iteritems(): r = DataType(id=type, parameters=json.dumps(params)) session.add(r) session.commit() session.flush()
def WSDatatypesGetall(self, data): datatypes =dict ((o.id, json.loads(o.parameters)) for o in DataType.getAll()) return ['datatype-list', datatypes]
def WSDatatypesGetall(self, data): datatypes = dict( (o.id, json.loads(o.parameters)) for o in DataType.getAll()) return ['datatype-list', datatypes]