コード例 #1
0
    isogeo.connect(
        username=environ.get("ISOGEO_USER_NAME"),
        password=environ.get("ISOGEO_USER_PASSWORD"),
    )
    auth_timer = default_timer()

    logger.info("{} metadatas will be migrated".format(len(li_src_to_migrate)))

    # ------------------------------------ BACKUP --------------------------------------
    if environ.get("BACKUP") == "1" and len(li_to_backup):
        logger.info(
            "---------------------------- BACKUP {} metadatas---------------------------------"
            .format(len(li_to_backup)))
        # backup manager instanciation
        backup_path = Path(r"./scripts/rouen/md_ref/_output/_backup")
        backup_mng = BackupManager(api_client=isogeo,
                                   output_folder=backup_path)
        # lauching backup
        amplitude = 50

        if len(li_to_backup) > amplitude:
            bound_range = int(len(li_to_backup) / amplitude)
            li_bound = []
            for i in range(bound_range + 1):
                li_bound.append(amplitude * i)
            li_bound.append(len(li_to_backup))

            logger.info(
                "Starting backup for {} rounds".format(len(li_bound) - 1))
            for i in range(len(li_bound) - 1):
                if default_timer() - auth_timer >= 250:
                    logger.info("Manually refreshing token")
コード例 #2
0
    isogeo = Isogeo(
        client_id=environ.get("ISOGEO_API_USER_LEGACY_CLIENT_ID"),
        client_secret=environ.get("ISOGEO_API_USER_LEGACY_CLIENT_SECRET"),
        auth_mode="user_legacy",
        auto_refresh_url="{}/oauth/token".format(environ.get("ISOGEO_ID_URL")),
        platform=environ.get("ISOGEO_PLATFORM", "qa"),
    )
    isogeo.connect(
        username=environ.get("ISOGEO_USER_NAME"),
        password=environ.get("ISOGEO_USER_PASSWORD"),
    )

    logger.info("{} medatatas will be migrated and {} will be saved".format(
        len(li_src_to_migrate), len(li_to_backup)))
    # ------------------------------------- BACKUP -------------------------------------
    backup_mngr = BackupManager(api_client=isogeo,
                                output_folder="./scripts/jura/output")

    bound_range = int(len(li_to_backup) / 50)
    li_bound = []
    for i in range(bound_range + 1):
        li_bound.append(50 * i)
    li_bound.append(len(li_to_backup))

    logger.info("Starting backup for {} rounds".format(len(li_bound) - 1))
    for i in range(len(li_bound) - 1):
        bound_inf = li_bound[i]
        bound_sup = li_bound[i + 1]
        logger.info("Round {} - backup from source metadata {} to {}".format(
            i + 1, bound_inf + 1, bound_sup))

        search_parameters = {