added some logging
This commit is contained in:
+30
-18
@@ -36,6 +36,7 @@ def create_jack_lists(moodle_csv, jack_prefix):
|
||||
|
||||
|
||||
def split_tables(moodle_csv):
|
||||
print("splitting moodle registrations by appointment")
|
||||
moodle_list = read_moodle_csv(moodle_csv)
|
||||
days = moodle_list["Datum"].unique()
|
||||
frames_by_day = []
|
||||
@@ -83,7 +84,7 @@ def create_info_for_moodle(tables: list[pandas.DataFrame], moodle_upload):
|
||||
|
||||
|
||||
def create_students_tables(tables: list[pandas.DataFrame], login_file, tan_prefix):
|
||||
print("creating student tables")
|
||||
print("creating entry lists csv files")
|
||||
jack_tans = pandas.DataFrame()
|
||||
files = [f for f in listdir(".") if isfile(f)]
|
||||
for f in files:
|
||||
@@ -142,6 +143,7 @@ def create_students_tables(tables: list[pandas.DataFrame], login_file, tan_prefi
|
||||
|
||||
|
||||
def create_extra_logins(tables: list[pandas.DataFrame], login_file):
|
||||
print("collecting unused login information")
|
||||
length = sum([len(table) for table in tables])
|
||||
pc_logins: pandas.DataFrame
|
||||
try:
|
||||
@@ -161,6 +163,7 @@ def create_extra_logins(tables: list[pandas.DataFrame], login_file):
|
||||
|
||||
|
||||
def create_super_csv_for_pdf(tables: list[pandas.DataFrame]):
|
||||
print("creating csv for testat pdf")
|
||||
firstnames = []
|
||||
lastnames = []
|
||||
matnumbers = []
|
||||
@@ -201,12 +204,14 @@ def create_super_csv_for_pdf(tables: list[pandas.DataFrame]):
|
||||
|
||||
|
||||
def create_serienbrief():
|
||||
print("creating testat pdf")
|
||||
result = subprocess.run(["pdflatex", "Serienbrief.tex"], capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
sys.stderr.write("pdflatex exited with error code " + str(result.returncode))
|
||||
|
||||
|
||||
def create_teilnehmerlisten(filenames):
|
||||
print("creating entry lists pdfs")
|
||||
output = "File;Title"
|
||||
for file, title in filenames:
|
||||
output = output + "\n" + file + ";" + title
|
||||
@@ -218,12 +223,14 @@ def create_teilnehmerlisten(filenames):
|
||||
|
||||
|
||||
def create_extra_kennungen():
|
||||
print("creating extra login information pdf")
|
||||
result = subprocess.run(["pdflatex", "ExtraKennungen.tex"], capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
sys.stderr.write("pdflatex exited with error code " + str(result.returncode))
|
||||
|
||||
|
||||
def cleanup_files():
|
||||
print("deleting temporary files")
|
||||
files = [f for f in listdir(".") if isfile(f)]
|
||||
for f in files:
|
||||
if f.endswith(".aux"):
|
||||
@@ -234,6 +241,25 @@ def cleanup_files():
|
||||
remove(f)
|
||||
|
||||
|
||||
def start(moodle_input: str, moodle_output: str = "", logins: str = "",
|
||||
jack: bool = False, jack_prefix: str = "JACK_", tan_prefix: str = "examTans"):
|
||||
if jack:
|
||||
create_jack_lists(moodle_input, jack_prefix)
|
||||
tables = split_tables(moodle_input)
|
||||
if moodle_output != "":
|
||||
create_info_for_moodle(tables, moodle_output)
|
||||
if logins == "":
|
||||
cleanup_files()
|
||||
return
|
||||
extended_tables, filenames = create_students_tables(tables, logins, tan_prefix)
|
||||
create_extra_logins(extended_tables, logins)
|
||||
create_super_csv_for_pdf(extended_tables)
|
||||
create_serienbrief()
|
||||
create_teilnehmerlisten(filenames)
|
||||
create_extra_kennungen()
|
||||
cleanup_files()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-i", "--moodle_input", type=str, required=True,
|
||||
@@ -243,26 +269,12 @@ def main():
|
||||
help='prefix for output files for JACK, default: JACK_', action='store', default="JACK_")
|
||||
parser.add_argument("-t", "--tan_prefix", type=str,
|
||||
help='prefix for tan files from JACK, default: examTans', action='store', default="examTans")
|
||||
parser.add_argument("-o", "--moodle_output", type=str,
|
||||
parser.add_argument("-o", "--moodle_output", type=str, default="",
|
||||
help='output file for upload to moodle', action='store')
|
||||
parser.add_argument("-l", "--logins", type=str,
|
||||
parser.add_argument("-l", "--logins", type=str, default="",
|
||||
help='file with login information', action='store')
|
||||
args = parser.parse_args()
|
||||
if args.jack:
|
||||
create_jack_lists(args.moodle_input, args.jack_prefix)
|
||||
tables = split_tables(args.moodle_input)
|
||||
if args.moodle_output is not None:
|
||||
create_info_for_moodle(tables, args.moodle_output)
|
||||
if args.logins is None:
|
||||
cleanup_files()
|
||||
return
|
||||
extended_tables, filenames = create_students_tables(tables, args.logins, args.tan_prefix)
|
||||
create_extra_logins(extended_tables, args.logins)
|
||||
create_super_csv_for_pdf(extended_tables)
|
||||
create_serienbrief()
|
||||
create_teilnehmerlisten(filenames)
|
||||
create_extra_kennungen()
|
||||
cleanup_files()
|
||||
start(args.moodle_input, args.moodle_output, args.logins, args.jack, args.jack_prefix, args.tan_prefix)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user