for md in bd_carto_search.results: # refresh token if needed if default_timer() - auth_timer >= 6900: logger.info("Manually refreshing token") isogeo.connect( username=environ.get("ISOGEO_USER_NAME"), password=environ.get("ISOGEO_USER_PASSWORD"), ) auth_timer = default_timer() else: pass # Check if the metadata appears in matching table if md.get("_id") in li_md_uuid: md_info = [info for info in li_infos if info[0] == md.get("_id")][0] # check if infos retrieved from matching table are consistent if md_info[1] == md.get("title"): isogeo_md = Metadata(**md) isogeo_md.title = md_info[2] # let's updtae metadata title isogeo.metadata.update(metadata=isogeo_md) md_parsed_count += 1 else: logger.warning("Infos retrieved from matching table about '{}' metadata are not consistent with API response".format(md.get("_id"))) else: pass isogeo.close() logger.info("{}/{} metadatas parsed".format(md_parsed_count, len(li_infos)))
# API client instanciation 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"), ) auth_time = default_timer() new_md = Metadata() new_md.type = type_code new_md.format = format_code new_md.title = title new_md.name = name new_md.path = path metadata = isogeo.metadata.create(workgroup_id=trg_wg_uuid, metadata=new_md) for cat_uuid in li_trg_cat_uuid: cat = isogeo.catalog.get(workgroup_id=trg_wg_uuid, catalog_id=cat_uuid) isogeo.catalog.associate_metadata(metadata=metadata, catalog=cat) search = isogeo.search() isogeo.close()
logger.error(e) if row[dct_i2o_struct.get("date_publication")].value: try: isogeo.md_associate_events( metadata=target_md, event_date=row[dct_i2o_struct.get("date_publication")].value, event_kind="publication", ) except Exception as e: logger.error(e) # print(row[dct_i2o_struct.get("context")].value) # edit local metadata object target_md.title = row[dct_i2o_struct.get("title")].value target_md.abstract = row[dct_i2o_struct.get("abstract")].value target_md.collectionContext = row[dct_i2o_struct.get("context")].value target_md.collectionMethod = row[dct_i2o_struct.get("method")].value target_md.updateFrequency = row[dct_i2o_struct.get("frequency")].value target_md.scale = row[dct_i2o_struct.get("scale")].value # print(row[39].value) # metadata UUID # print(row[0].value) # title # print(row[2].value) # abstract # print(row[5].value) # keywords # print(row[6].value) # INSPIRE # update online metadata isogeo.md_update(target_md) sleep(1) logger.info("{} update finished at {:5.2f}s".format(