From 7d7f454e70c7c2f0c7c180d3e643508ce8ec371e Mon Sep 17 00:00:00 2001 From: Eduard Friske <eduard.friske@ptb.de> Date: Thu, 28 Mar 2024 13:30:01 +0100 Subject: [PATCH] Konfiguration in config.json --- .gitignore | 1 + file-to-couchdb_TLA.py | 22 +++++++++++++++------- writeLaTeX-ks-TLA.py | 22 +++++++++++++--------- 3 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d344ba6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json diff --git a/file-to-couchdb_TLA.py b/file-to-couchdb_TLA.py index c4909cf..f58df25 100644 --- a/file-to-couchdb_TLA.py +++ b/file-to-couchdb_TLA.py @@ -26,11 +26,19 @@ db = couch['vl_db'] # existing # - Jahr der Kalibrierung # - laufende Nummer der Kalibrierung - +config_file = "config.json" +with open(config_file) as fp: + config = json.load(fp) +#for section in config.keys(): +# print("section:", section) +# for entry in config[section].keys(): +# print(entry, "=", config[section][entry]) cal_cert = "75559" -year = "2024" -no = "0001" +year = str(config["KS-Daten"]["Jahr"]) +no = str(config["KS-Daten"]["lfd. Nr."]).zfill(4) +#print("year:", year) +#print("no:", no) json_file = "cal-" + year + "-tl2-kk-" + cal_cert + "_" + no @@ -38,7 +46,7 @@ doc = db.get(json_file) # Die Daten aus dem File mit der entsprechenden Kalibrierscheinnummer werden eingelesen: # datum, time, p_up und alle Temperaturen, -path=Path('/home/friske01/O/Vakuum/Messplaetze/TL2/Messwerte') +path=Path(config["Pfad"]["Messwerte"]) #print(path.exists()) #datei = path.joinpath(year + ".json") @@ -52,11 +60,11 @@ print(json_file) #with smbclient.open_file(datei, mode= 'r') as datei_handle: datei_pkt = pd.read_csv(datei, sep="\t", decimal = ',' ) -print(datei_pkt) +#print(datei_pkt) #with smbclient.open_file(datei_S, mode= 'r') as datei_handle: datei_S_pkt = pd.read_csv(datei_S, sep="\t", decimal = ',' ) -print(datei_S_pkt) -exit() +#print(datei_S_pkt) +#exit() datum=datei_pkt["Datum"] time=datei_pkt["Zeit"] p_up=datei_pkt["Druck"] diff --git a/writeLaTeX-ks-TLA.py b/writeLaTeX-ks-TLA.py index b0b61cc..c9aa041 100644 --- a/writeLaTeX-ks-TLA.py +++ b/writeLaTeX-ks-TLA.py @@ -1,12 +1,14 @@ import time import couchdb from datetime import date +from pathlib import Path couch = couchdb.Server('http://a73434.berlin.ptb.de:5984') db = couch['vl_db'] # existing -cal_cert = "75553" -year = "2024" -no = "0001" +cal_cert = "75559" +year = str(config["KS-Daten"]["Jahr"]) +no = str(config["KS-Daten"]["lfd. Nr."]).zfill(4) +year_cer = year[2:] # Druckanzeige pup_cus_ptb = 0 (PTB/Wika) ; pup_cus_ptb = 1 (customer) @@ -39,16 +41,18 @@ doc = {'_id': json_file_cer} if id_cer == 0: db.save(doc) - print ( "Warten! 30 Sekunden" ) - time.sleep ( 30 ) + print ( "Warten! 2 Sekunden" ) + time.sleep ( 2 ) print ( json_file_cer," ist in der Couch angelegt" ) else: print ( json_file_cer," ist bereits in der Couch angelegt" ) +path = Path(config["Pfad"]["Kalibrierschein"]) id_ = "cal-" + year + "-tl2-kk-" + cal_cert + "_" + no -ks = "C:\\Users\\becker07\\kalibrierschein\\ks-" + cal_cert + "-" + year + ".tex" +ks_file = "ks-" + cal_cert + "-" + year + ".tex" +ks = path.joinpath(ks_file) cer = "cer-" + year + "-" + cal_cert json_file_cal = id_ @@ -129,7 +133,7 @@ typ = '\\type{' + Type + '}\n' serialNo = '\\serialNo{' + Serial + '}\n' applicant = '\\applicant{{' + Name + '}\n {' + Street + '} \n {' + Zipcode + Town +'}\n {' + Land+'}}\n' refNo = '\\refNo{ ' + ReferenceNo + '}\n' -calibMark = '\\calibMark{ ' +' ' + Certificate + ' PTB 23}\n' +calibMark = '\\calibMark{ ' +' ' + Certificate + ' PTB ' + year_cer + '}\n' calibDate = '\\calibDate{' + MeasurementDate + '}\n' examiner = '\\examiner{' + Examiner + '}\n' certificateDate = '\\certificateDate{' + CertificateDate + '}\n' @@ -223,7 +227,7 @@ sectionDiscription_1_en= TextEN ###### Beschreibung aus dem cal-Dokument if (sectionDiscription_noyes!= 'yes'): sectionDiscription_2= " Dies ist die erste von der PTB durchgeführte Kalibrierung." - sectionDiscription_2_en= "This is the previous calibration at PTB." + sectionDiscription_2_en= " This is the first calibration at PTB." print(" 1. durchgeführte Kalibrierung") else: @@ -481,4 +485,4 @@ db.save(doc_cer) - \ No newline at end of file + -- GitLab