Skip to content
Snippets Groups Projects
Commit 697f65e9 authored by Eduard Friske's avatar Eduard Friske
Browse files

Unterstützung für Kommandozeilen-Parameter eingebaut

parent ba3ae7af
No related branches found
No related tags found
No related merge requests found
...@@ -63,7 +63,7 @@ elab_id=647 ...@@ -63,7 +63,7 @@ elab_id=647
cers = ["75556_0001","75557_0001","75558_0001","75559_0001"] # Beispiel: cers = ["75511_0001","75512_0001"] cers = ["75556_0001","75557_0001","75558_0001","75559_0001"] # Beispiel: cers = ["75511_0001","75512_0001"]
TL1_2= "TLA" #### FM1 oder TLA TL1_2= "TLA" #### FM1 oder TLA
year = "2024" year = str(config["KS-Daten"]["Jahr"])
kk= "KK" kk= "KK"
commentar = '' commentar = ''
......
...@@ -9,17 +9,37 @@ from pathlib import Path ...@@ -9,17 +9,37 @@ from pathlib import Path
import os import os
import couchdb import couchdb
import argparse
import json
couch = couchdb.Server('http://a73434.berlin.ptb.de:5984') couch = couchdb.Server('http://a73434.berlin.ptb.de:5984')
db = couch['vl_db'] # existing db = couch['vl_db'] # existing
path= Path(config["Pfad"]["Kalibrierschein"]) config_file = "config.json"
with open(config_file) as fp:
config = json.load(fp)
cmd_parser = argparse.ArgumentParser(description= "Schreibt erstellen kalibrierschein (TeX und PDF) in die CouchDB")
cmd_parser.add_argument("cal_no", type= int, metavar= "<Kalibrierschein-Nummer>", nargs= "*")
cmd_parser.add_argument("-y", "--year", type= int, metavar= "<Messjahr>")
args = cmd_parser.parse_args()
path= Path(config["Pfad"]["Kalibrierschein"])
year = str(config["KS-Daten"]["Jahr"]) year = str(config["KS-Daten"]["Jahr"])
cers = ["75559"] # Beispiel: cers = ["75511_0001","75512_0001"] if args.year is not None:
#cers = ["75562","75563"] # Beispiel: cers = ["75511_0001","75512_0001"] year = str(args.year)
cers = [""] * len(args.cal_no)
#print(args.cal_no)
for pos in range(len(args.cal_no)):
cers[pos] = str(args.cal_no[pos])
print(cers)
#cers = ["75559"] # Beispiel: cers = ["75511_0001","75512_0001"]
#cers = ["75562","75563"] # Beispiel: cers = ["75511_0001","75512_0001"]
exit()
################### die Kalibrierscheine werden an das cer-json-dokument angehangen ################## ################### die Kalibrierscheine werden an das cer-json-dokument angehangen ##################
i = 0 i = 0
while i < len(cers): while i < len(cers):
...@@ -65,6 +85,6 @@ while i < len(cers): ...@@ -65,6 +85,6 @@ while i < len(cers):
ks_tex.unlink(missing_ok= True) ks_tex.unlink(missing_ok= True)
ks_aux.unlink(missing_ok= True) ks_aux.unlink(missing_ok= True)
ks_log.unlink(missing_ok= True) ks_log.unlink(missing_ok= True)
ks_gz.unlink(missing_ok= True) ks_gz.unlink(missing_ok= True)
i += 1 i += 1
...@@ -17,6 +17,7 @@ import json ...@@ -17,6 +17,7 @@ import json
import couchdb import couchdb
from pathlib import Path from pathlib import Path
import os import os
import argparse
#import pathlib #import pathlib
couch = couchdb.Server('http://a73434.berlin.ptb.de:5984') couch = couchdb.Server('http://a73434.berlin.ptb.de:5984')
db = couch['vl_db'] # existing db = couch['vl_db'] # existing
...@@ -34,13 +35,27 @@ with open(config_file) as fp: ...@@ -34,13 +35,27 @@ with open(config_file) as fp:
# for entry in config[section].keys(): # for entry in config[section].keys():
# print(entry, "=", config[section][entry]) # print(entry, "=", config[section][entry])
cal_cert = "75559" cmd_parser = argparse.ArgumentParser(description= "Verarbeitet Messdaten aus TLA und speichert sie als CouchDB-Dokument")
cmd_parser.add_argument("cal_no", type= int, metavar= "<Kalibrierschein-Nummer>")
cmd_parser.add_argument("-y", "--year", type= int, metavar= "<Messjahr>")
cmd_parser.add_argument("-n", "--number", type= int, metavar= "<laufende Nummer>")
args = cmd_parser.parse_args()
#cal_cert = "75559"
year = str(config["KS-Daten"]["Jahr"]) year = str(config["KS-Daten"]["Jahr"])
no = str(config["KS-Daten"]["lfd. Nr."]).zfill(4) no = str(config["KS-Daten"]["lfd. Nr."]).zfill(4)
#if args.cal_no is not None:
cal_cert = str(args.cal_no)
if args.year is not None:
year = str(args.year)
if args.number is not None:
no = str(args.number).zfill(4)
#print("year:", year) #print("year:", year)
#print("no:", no) #print("no:", no)
json_file = "cal-" + year + "-tl2-kk-" + cal_cert + "_" + no json_file = "cal-" + year + "-tl2-kk-" + cal_cert + "_" + no
doc = db.get(json_file) doc = db.get(json_file)
......
...@@ -2,12 +2,29 @@ import time ...@@ -2,12 +2,29 @@ import time
import couchdb import couchdb
from datetime import date from datetime import date
from pathlib import Path from pathlib import Path
import argparse
import json
couch = couchdb.Server('http://a73434.berlin.ptb.de:5984') couch = couchdb.Server('http://a73434.berlin.ptb.de:5984')
db = couch['vl_db'] # existing db = couch['vl_db'] # existing
cal_cert = "75559" config_file = "config.json"
with open(config_file) as fp:
config = json.load(fp)
cmd_parser = argparse.ArgumentParser(description= "Erstellt TeX-Dokument als Zwischenschritt zum PDF-Kalibrierschein")
cmd_parser.add_argument("cal_no", type= int, metavar= "<Kalibrierschein-Nummer>")
cmd_parser.add_argument("-y", "--year", type= int, metavar= "<Messjahr>")
cmd_parser.add_argument("-n", "--number", type= int, metavar= "<laufende Nummer>")
args = cmd_parser.parse_args()
#cal_cert = "75559"
year = str(config["KS-Daten"]["Jahr"]) year = str(config["KS-Daten"]["Jahr"])
no = str(config["KS-Daten"]["lfd. Nr."]).zfill(4) no = str(config["KS-Daten"]["lfd. Nr."]).zfill(4)
cal_cert = str(args.cal_no)
if args.year is not None:
year = str(args.year)
if args.number is not None:
no = str(args.number).zfill(4)
year_cer = year[2:] year_cer = year[2:]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment