def log_import(integration_or_setting):
    log.info("CREATED: %r" % integration_or_setting)


_db = production_session()
try:
    Configuration.load()

    shadowcat_conf = Configuration.integration('Shadowcat')
    if shadowcat_conf and shadowcat_conf.get('url'):
        shadowcat = EI(name=EI.NYPL_SHADOWCAT,
                       protocol=EI.NYPL_SHADOWCAT,
                       goal=EI.METADATA_GOAL)
        _db.add(shadowcat)
        shadowcat.url = shadowcat_conf.get('url')
        log_import(shadowcat)

    content_cafe_conf = Configuration.integration('Content Cafe')
    if content_cafe_conf:
        content_cafe = EI(name=EI.CONTENT_CAFE,
                          protocol=EI.CONTENT_CAFE,
                          goal=EI.METADATA_GOAL)
        _db.add(content_cafe)

        content_cafe.username = content_cafe_conf.get('username')
        content_cafe.password = content_cafe_conf.get('password')

    metadata_wrangler_conf = Configuration.integration('Metadata Wrangler')
    if metadata_wrangler_conf:
        url = metadata_wrangler_conf.get('url')
Ejemplo n.º 2
0
    circ_manager_conf = Configuration.integration('Circulation Manager')
    if circ_manager_conf:
        url = circ_manager_conf.get('url')
        if url:
            setting = ConfigurationSetting.sitewide(_db, Configuration.BASE_URL_KEY)
            setting.value = unicode(url)
            log_import(setting)

    # Import Metadata Wrangler configuration.
    metadata_wrangler_conf = Configuration.integration('Metadata Wrangler')

    if metadata_wrangler_conf:
        integration = EI(protocol=EI.METADATA_WRANGLER, goal=EI.METADATA_GOAL)
        _db.add(integration)

        integration.url = metadata_wrangler_conf.get('url')
        integration.username = metadata_wrangler_conf.get('client_id')
        integration.password = metadata_wrangler_conf.get('client_secret')

        log_import(integration)

    # Import NoveList Select configuration.
    novelist = Configuration.integration('NoveList Select')
    if novelist:
        integration = EI(protocol=EI.NOVELIST, goal=EI.METADATA_GOAL)
        _db.add(integration)

        integration.username = novelist.get('profile')
        integration.password = novelist.get('password')

        integration.libraries.extend(LIBRARIES)
        )
        _db.add(bibblio)
        bibblio.username = bibblio_conf.get('client_id')
        bibblio.password = bibblio_conf.get('client_secret')
        log_import(bibblio)

    # Create the Metadata Wrangler configuration.
    metadata_wrangler_conf = Configuration.integration('Metadata Wrangler')
    if metadata_wrangler_conf:
        wrangler = EI(
            name=EI.METADATA_WRANGLER,
            protocol=EI.METADATA_WRANGLER,
            goal=EI.METADATA_GOAL
        )
        _db.add(wrangler)
        wrangler.url = metadata_wrangler_conf.get('url')
        wrangler.username = metadata_wrangler_conf.get('client_id')
        wrangler.password = metadata_wrangler_conf.get('client_secret')
        log_import(wrangler)

    # Get the base url.
    content_server_conf = Configuration.integration('Content Server')
    if content_server_conf:
        url = content_server_conf.get('url')
        setting = ConfigurationSetting.sitewide(_db, Configuration.BASE_URL_KEY)
        setting.value = url
        log_import(setting)

    # Copy facet configuration to the library.
    facet_policy = Configuration.policy("facets", default={})
    log.info("CREATED: %r" % integration_or_setting)


_db = production_session()
try:
    Configuration.load()

    shadowcat_conf = Configuration.integration('Shadowcat')
    if shadowcat_conf and shadowcat_conf.get('url'):
        shadowcat = EI(
            name=EI.NYPL_SHADOWCAT,
            protocol=EI.NYPL_SHADOWCAT,
            goal=EI.METADATA_GOAL
        )
        _db.add(shadowcat)
        shadowcat.url = shadowcat_conf.get('url')
        log_import(shadowcat)

    content_cafe_conf = Configuration.integration('Content Cafe')
    if content_cafe_conf:
        content_cafe = EI(
            name=EI.CONTENT_CAFE,
            protocol=EI.CONTENT_CAFE,
            goal=EI.METADATA_GOAL
        )
        _db.add(content_cafe)

        content_cafe.username = content_cafe_conf.get('username')
        content_cafe.password = content_cafe_conf.get('password')

    metadata_wrangler_conf = Configuration.integration('Metadata Wrangler')