예제 #1
0
def model_index():
    project = Project.find()
    topicsFile = project.run_dir("models", "topics.index.m5oc")
    path = Path(topicsFile)

    topics = json.load(open(path)) if path.is_file() else {}

    # for now let's freeze the keys, so the we can re-use the
    # key name as the design's name, but this should probably
    # return a list
    topics = freeze_keys(topics)
    return jsonify(topics)
예제 #2
0
def get_plugin_configuration(plugin_ref) -> Response:
    """
    endpoint for getting a plugin's configuration
    """
    project = Project.find()
    settings = PluginSettingsService(project)
    config = flatten(settings.as_config(db.session, plugin_ref, redacted=True),
                     reducer="dot")

    return jsonify({
        # freeze the keys because they are used for lookups
        "config": freeze_keys(config),
        "settings": settings.get_definition(plugin_ref).settings,
    })
예제 #3
0
def get_config_with_metadata(settings):
    config_dict = {}
    config_metadata = {}

    config_with_metadata = settings.config_with_metadata(extras=False,
                                                         redacted=True,
                                                         session=db.session)
    for key, metadata in config_with_metadata.items():
        config_dict[key] = metadata.pop("value")

        metadata.pop("setting", None)

        try:
            metadata["source_label"] = metadata["source"].label
            metadata["auto_store_label"] = metadata["auto_store"].label
        except KeyError:
            pass

        config_metadata[key] = metadata

    return {
        "config": freeze_keys(config_dict),
        "config_metadata": freeze_keys(config_metadata),
    }
예제 #4
0
 def get_query_results(self, loader, sql):
     engine = self.get_db_engine(loader)
     results = engine.execute(sqlalchemy.text(sql))
     results = [freeze_keys(OrderedDict(row)) for row in results]
     return results
예제 #5
0
def freeze_profile_config_keys(profile):
    profile["config"] = freeze_keys(profile.get("config", {}))
    profile["config_sources"] = freeze_keys(profile.get("config_sources", {}))