#Modules maison from Alma_Apis_Interface import Alma_Apis_Users from logs import logs SERVICE = "Modification_PrimId_en_masse" LOGS_LEVEL = 'DEBUG' LOGS_DIR = os.getenv('LOGS_PATH') FILE_NAME = 'test' IN_FILE = '/media/sf_Partage_LouxBox/{}.csv'.format(FILE_NAME) # IN_FILE = './test.csv' #Init logger logs.init_logs(LOGS_DIR, SERVICE, LOGS_LEVEL) log_module = logging.getLogger(SERVICE) # get file encoding type def get_encoding_type(file): with open(file, 'rb') as f: rawdata = f.read() return detect(rawdata)['encoding'] def change_user_prim_id(barcode, newprimId): institutions_list = ['NETWORK', 'UB', 'UBM', 'IEP', 'INP', 'BXSA'] # institutions_list = ['NETWORK','UB','BXSA'] for institution in institutions_list: api_key = os.getenv("PROD_{}_USER_API".format(institution))
job_reponse = api.post_job(job_id, json.dumps(job_parameters)) #Récupère l'identifiant du service job_service = (job_reponse['additional_info']['link']) a = re.search("jobs\/(.*?)\/instances\/(.*)", job_service) job_instance_id = a.group(2) return job_instance_id # Initilalisation des paramétres null = None service = "supprime_bib" niveau_logs = 'DEBUG' logs_rep = os.getenv('LOGS_PATH') #On initialise le logger logs.init_logs(logs_rep, service, niveau_logs) log_module = logging.getLogger(service) #On initialise l'objet API api = Alma_Apis.Alma(apikey=os.getenv('PROD_NETWORK_CONF_API'), region='EU', service=service) #On lance le job qui permet d'identifier depuis la NZ les notices sans inventaires identifie_bib_job_id = 'M58' identifie_bib_job_parameters = get_job_parameters( './Jobs_parameters/Identifie_notices_Job_Paramater.json') identifie_bib_job_instance_id = post_job(identifie_bib_job_id, identifie_bib_job_parameters) # identifie_bib_job_instance_id='4063693030004671' log_module.info('[post_job (Job ({})] Instance Id({})'.format(