def test_device_models_smdx(self): path = device.model_type_path_default files = os.listdir(path) model_id = None for f in files: try: model_id = smdx.model_filename_to_id(f) if model_id is not None: device.model_type_get(model_id) except Exception, e: raise Exception('Error scanning model %s: %s' % (str(model_id), e))
def test_device_models_smdx(self): path = device.model_type_path_default files = os.listdir(path) model_id = None for f in files: try: model_id = smdx.model_filename_to_id(f) if model_id is not None: device.model_type_get(model_id) except Exception as e: raise Exception('Error scanning model %s: %s' % (str(model_id), e))
def model_class_get(model_id): def add_property(self, name, value): fget = lambda self: self._get_property(name) fset = lambda self, value: self._set_property(name, value) setattr(self, name, property(fget, fset)) def class_init(self, model, name): SunSpecClientModelBase.__init__(self, model, name) def block_class_init(self, block, name): SunSpecClientBlockBase.__init__(self, block, name) class_name = 'Model' + str(model_id) class_ = globals().get(class_name) if class_ is None: class_ = type(class_name, (SunSpecClientModelBase,), {'__init__' : class_init}) globals()[class_name] = class_ setattr(class_, 'points', []) model_type = None try: model_type = device.model_type_get(model_id) except Exception, e: setattr(class_, 'load_error', str(e))
def model_class_get(model_id): def add_property(self, name, value): fget = lambda self: self._get_property(name) fset = lambda self, value: self._set_property(name, value) setattr(self, name, property(fget, fset)) def class_init(self, model, name): SunSpecClientModelBase.__init__(self, model, name) def block_class_init(self, block, name): SunSpecClientBlockBase.__init__(self, block, name) class_name = 'Model' + str(model_id) class_ = globals().get(class_name) if class_ is None: class_ = type(class_name, (SunSpecClientModelBase, ), {'__init__': class_init}) globals()[class_name] = class_ setattr(class_, 'points', []) model_type = None try: model_type = device.model_type_get(model_id) except Exception as e: setattr(class_, 'load_error', str(e)) if model_type is not None: for point_type in model_type.fixed_block.points_list: if point_type.type != suns.SUNS_TYPE_SUNSSF and point_type.type != suns.SUNS_TYPE_PAD: add_property(class_, point_type.id, None) class_.points.append(point_type.id) ### check for writable point? block_type = model_type.repeating_block if block_type is not None: block_class_name = class_name + 'Repeating' block_class = type(block_class_name, (SunSpecClientBlockBase, ), {'__init__': block_class_init}) globals()[block_class_name] = block_class setattr(block_class, 'points', []) for point_type in block_type.points_list: if point_type.type != suns.SUNS_TYPE_SUNSSF and point_type.type != suns.SUNS_TYPE_PAD: add_property(block_class, point_type.id, None) block_class.points.append(point_type.id) return class_
def model_class_get(model_id): def add_property(self, name, value): fget = lambda self: self._get_property(name) fset = lambda self, value: self._set_property(name, value) setattr(self, name, property(fget, fset)) def class_init(self, model, name): SunSpecClientModelBase.__init__(self, model, name) def block_class_init(self, block, name): SunSpecClientBlockBase.__init__(self, block, name) class_name = 'Model' + str(model_id) class_ = globals().get(class_name) if class_ is None: class_ = type(class_name, (SunSpecClientModelBase,), {'__init__' : class_init}) globals()[class_name] = class_ setattr(class_, 'points', []) model_type = None try: model_type = device.model_type_get(model_id) except Exception as e: setattr(class_, 'load_error', str(e)) if model_type is not None: for point_type in model_type.fixed_block.points_list: if point_type.type != suns.SUNS_TYPE_SUNSSF and point_type.type != suns.SUNS_TYPE_PAD: add_property(class_, point_type.id, None) class_.points.append(point_type.id) ### check for writable point? block_type = model_type.repeating_block if block_type is not None: block_class_name = class_name + 'Repeating' block_class = type(block_class_name, (SunSpecClientBlockBase,), {'__init__' : block_class_init}) globals()[block_class_name] = block_class setattr(block_class, 'points', []) for point_type in block_type.points_list: if point_type.type != suns.SUNS_TYPE_SUNSSF and point_type.type != suns.SUNS_TYPE_PAD: add_property(block_class, point_type.id, None) block_class.points.append(point_type.id) return class_
def test_device_model_type_get(pathlist=None): try: device.model_type_get(221) except Exception, e: print '*** Failure test_model_type_get: %s' % str(e) return False