From ba3ae7afab6898b693e432a0e8991730cdf4112c Mon Sep 17 00:00:00 2001 From: Eduard Friske <eduard.friske@ptb.de> Date: Thu, 28 Mar 2024 13:52:38 +0100 Subject: [PATCH] Umbau attachment_cer auf Konfiguration --- API-V2-elab.py | 4 ++-- attachment_cer.py | 41 +++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/API-V2-elab.py b/API-V2-elab.py index e1375b0..dd03066 100644 --- a/API-V2-elab.py +++ b/API-V2-elab.py @@ -59,8 +59,8 @@ today = datetime.date.today() ######## -elab_id=643 -cers = ["75552_0001","75553_0001"] # Beispiel: cers = ["75511_0001","75512_0001"] +elab_id=647 +cers = ["75556_0001","75557_0001","75558_0001","75559_0001"] # Beispiel: cers = ["75511_0001","75512_0001"] TL1_2= "TLA" #### FM1 oder TLA year = "2024" diff --git a/attachment_cer.py b/attachment_cer.py index 3e23f07..aa7867e 100644 --- a/attachment_cer.py +++ b/attachment_cer.py @@ -5,19 +5,19 @@ Created on Fri Jan 6 11:14:44 2023 @author: becker07 """ -import pathlib +from pathlib import Path import os -import couchdb - +import couchdb couch = couchdb.Server('http://a73434.berlin.ptb.de:5984') db = couch['vl_db'] # existing +path= Path(config["Pfad"]["Kalibrierschein"]) -year = "2024" +year = str(config["KS-Daten"]["Jahr"]) -cers = ["75552","75553"] # Beispiel: cers = ["75511_0001","75512_0001"] +cers = ["75559"] # Beispiel: cers = ["75511_0001","75512_0001"] #cers = ["75562","75563"] # Beispiel: cers = ["75511_0001","75512_0001"] ################### die Kalibrierscheine werden an das cer-json-dokument angehangen ################## @@ -29,11 +29,11 @@ while i < len(cers): cer_pdf= "ks-" +cers[i] + "-" + year + ".pdf" cer_tex= "ks-" +cers[i] + "-" + year + ".tex" print(cer_pdf, cer_tex) - ks_pdf = "C:\\Users\\becker07\\kalibrierschein\\" + cer_pdf - ks_tex = "C:\\Users\\becker07\\kalibrierschein\\" + cer_tex + ks_pdf = path.joinpath(cer_pdf) + ks_tex = path.joinpath(cer_tex) print(ks_pdf, ks_tex) - content_pdf=pathlib.Path(ks_pdf).read_bytes() - content_tex=pathlib.Path(ks_tex).read_bytes() + content_pdf=ks_pdf.read_bytes() + content_tex=ks_tex.read_bytes() db.put_attachment(doc, content_pdf, cer_pdf , content_type='application/pdf') db.put_attachment(doc, content_tex, cer_tex , content_type='text/plain') @@ -41,6 +41,7 @@ while i < len(cers): ################### die Kalibrierscheine werden im Ordner Kalibrierscheine gelöscht ################## +exit() i = 0 while i < len(cers): @@ -53,17 +54,17 @@ while i < len(cers): cer_log= "ks-" +cers[i] + "-" + year + ".log" cer_gz= "ks-" +cers[i] + "-" + year + ".synctex.gz" print(cer_pdf, cer_tex) - ks_pdf = "C:\\Users\\becker07\\kalibrierschein\\" + cer_pdf - ks_tex = "C:\\Users\\becker07\\kalibrierschein\\" + cer_tex - ks_aux = "C:\\Users\\becker07\\kalibrierschein\\" + cer_aux - ks_log = "C:\\Users\\becker07\\kalibrierschein\\" + cer_log - ks_gz = "C:\\Users\\becker07\\kalibrierschein\\" + cer_gz + ks_pdf = path.joinpath(cer_pdf) + ks_tex = path.joinpath(cer_tex) + ks_aux = path.joinpath(cer_aux) + ks_log = path.joinpath(cer_log) + ks_gz = path.joinpath(cer_gz) print(ks_pdf, ks_tex) - os.remove(ks_pdf) - os.remove(ks_tex) - os.remove(ks_aux) - os.remove(ks_log) - os.remove(ks_gz) + ks_pdf.unlink(missing_ok= True) + ks_tex.unlink(missing_ok= True) + ks_aux.unlink(missing_ok= True) + ks_log.unlink(missing_ok= True) + ks_gz.unlink(missing_ok= True) - i += 1 \ No newline at end of file + i += 1 -- GitLab