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')
        ConfigurationSetting.sitewide(_db,
                                      Configuration.BASE_URL_KEY).value = url

finally:
    _db.commit()
    _db.close()
Exemplo n.º 2
0
        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)
        log_import(integration)
            _db, Library, name=u'default', short_name=u'default',
            uuid=unicode(uuid.uuid4())
        )
        library.is_default = True

    # Create the Bibblio integration.
    bibblio_conf = Configuration.integration('Bibblio')
    if bibblio_conf:
        bibblio = EI(
            name=EI.BIBBLIO,
            protocol=EI.BIBBLIO,
            goal=EI.METADATA_GOAL
        )
        _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)
        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')
        ConfigurationSetting.sitewide(_db, Configuration.BASE_URL_KEY).value = url


finally:
    _db.commit()
    _db.close()