Ejemplo n.º 1
0
def create_service_classes():
    path_services = Path.cwd() / 'eNMS' / 'automation' / 'services'
    dont_create_examples = not int(environ.get('CREATE_EXAMPLES', True))
    for file in path_services.glob('**/*.py'):
        if 'init' in str(file):
            continue
        if dont_create_examples and 'examples' in str(file):
            continue
        spec = spec_from_file_location(str(file), str(file))
        spec.loader.exec_module(module_from_spec(spec))
    for cls_name, cls in service_classes.items():
        for col in cls.__table__.columns:
            service_properties[cls_name].append(col.key)
            service_import_properties.append(col.key)
            if type(col.type) == Boolean:
                boolean_properties.append(col.key)
            if (type(col.type) == PickleType
                    and hasattr(cls, f'{col.key}_values')):
                property_types[col.key] = list
            else:
                property_types[col.key] = {
                    Boolean: bool,
                    Integer: int,
                    Float: float,
                    PickleType: dict,
                }.get(type(col.type), str)
Ejemplo n.º 2
0
def create_service_classes() -> None:
    path_services = [Path.cwd() / "eNMS" / "automation" / "services"]
    custom_services_path = environ.get("CUSTOM_SERVICES_PATH")
    if custom_services_path:
        path_services.append(Path(custom_services_path))
    dont_create_examples = not int(environ.get("CREATE_EXAMPLES", True))
    for path in path_services:
        for file in path.glob("**/*.py"):
            if "init" in str(file):
                continue
            if dont_create_examples and "examples" in str(file):
                continue
            spec = spec_from_file_location(str(file), str(file))
            assert isinstance(spec.loader, Loader)
            spec.loader.exec_module(module_from_spec(spec))  # type: ignore
    for cls_name, cls in service_classes.items():
        cls_to_properties[cls_name] = list(cls_to_properties["Service"])
        for col in cls.__table__.columns:
            cls_to_properties[cls_name].append(col.key)
            service_import_properties.append(col.key)
            if type(col.type) == Boolean:
                boolean_properties.append(col.key)
            if type(col.type) == PickleType and hasattr(
                    cls, f"{col.key}_values"):
                property_types[col.key] = "list"
            else:
                property_types[col.key] = {
                    Boolean: "bool",
                    Integer: "int",
                    Float: "float",
                    PickleType: "dict",
                }.get(type(col.type), "str")
Ejemplo n.º 3
0
def create_service_classes():
    path_services = [Path.cwd() / 'eNMS' / 'automation' / 'services']
    if environ.get('CUSTOM_SERVICES_PATH'):
        path_services.append(Path(environ.get('CUSTOM_SERVICES_PATH')))
    dont_create_examples = not int(environ.get('CREATE_EXAMPLES', True))
    for path in path_services:
        for file in path.glob('**/*.py'):
            if 'init' in str(file):
                continue
            if dont_create_examples and 'examples' in str(file):
                continue
            spec = spec_from_file_location(str(file), str(file))
            spec.loader.exec_module(module_from_spec(spec))
    for cls_name, cls in service_classes.items():
        cls_to_properties[cls_name] = list(cls_to_properties['Service'])
        for col in cls.__table__.columns:
            cls_to_properties[cls_name].append(col.key)
            service_import_properties.append(col.key)
            if type(col.type) == Boolean:
                boolean_properties.append(col.key)
            if (type(col.type) == PickleType
                    and hasattr(cls, f'{col.key}_values')):
                property_types[col.key] = 'list'
            else:
                property_types[col.key] = {
                    Boolean: 'bool',
                    Integer: 'int',
                    Float: 'float',
                    PickleType: 'dict',
                }.get(type(col.type), 'str')
Ejemplo n.º 4
0
def create_service_classes():
    path_services = Path.cwd() / 'eNMS' / 'automation' / 'services'
    for file in path_services.glob('**/*.py'):
        if 'init' not in str(file):
            spec = spec_from_file_location(str(file), str(file))
            spec.loader.exec_module(module_from_spec(spec))
    for cls_name, cls in service_classes.items():
        for col in cls.__table__.columns:
            if type(col.type) == Boolean:
                boolean_properties.append(col.key)
            if (type(col.type) == PickleType
                    and hasattr(cls, f'{col.key}_values')):
                property_types[col.key] = list
            else:
                property_types[col.key] = {
                    Boolean: bool,
                    Integer: int,
                    Float: float,
                    PickleType: dict,
                }.get(type(col.type), str)
Ejemplo n.º 5
0
def process_pool_properties():
    for col in Pool.__table__.columns:
        if type(col.type) == Boolean:
            boolean_properties.append(col.key)