Skip to content
Snippets Groups Projects
Commit 18110774 authored by Maximilian Gruber's avatar Maximilian Gruber
Browse files

change "DCC" to "report" in most places

parent 2b2cd3a8
No related branches found
No related tags found
1 merge request!1Visualize report data
...@@ -45,7 +45,7 @@ class CocalMethods: ...@@ -45,7 +45,7 @@ class CocalMethods:
self.audio_config = json.load(open(self.audio_config_path, "r")) self.audio_config = json.load(open(self.audio_config_path, "r"))
self.dut_path = self.session_dir.joinpath("upload.wav") self.dut_path = self.session_dir.joinpath("upload.wav")
self.dcc_path = self.session_dir.joinpath("dcc.xml") self.report_path = self.session_dir.joinpath("report.xml")
self.result_image_path = self.session_dir.joinpath("transfer_behaviour.png") self.result_image_path = self.session_dir.joinpath("transfer_behaviour.png")
##### TESTING ##### TESTING
...@@ -168,12 +168,11 @@ class CocalMethods: ...@@ -168,12 +168,11 @@ class CocalMethods:
break break
return self.upload_is_ready() return self.upload_is_ready()
def generate_dummy_dcc(self): def generate_dummy_report(self):
dcc_content = f"<xml>dummy dcc for {self.session.hash}</xml>" report_content = f"<xml>dummy report for {self.session.hash}</xml>"
filepath = self.session_dir.joinpath("dcc.xml") f = open(self.report_path, "w")
f = open(filepath, "w") f.write(report_content)
f.write(dcc_content)
f.close() f.close()
def get_current_git_hash(self): def get_current_git_hash(self):
...@@ -300,7 +299,7 @@ class CocalMethods: ...@@ -300,7 +299,7 @@ class CocalMethods:
} }
# load template # load template
filter_template_path = os.path.abspath(r"app/dcc/filter_template.xml") filter_template_path = os.path.abspath(r"app/report/filter_template.xml")
filter_template = open(filter_template_path, "r") filter_template = open(filter_template_path, "r")
filter_tree = ET.parse(filter_template) filter_tree = ET.parse(filter_template)
...@@ -311,7 +310,7 @@ class CocalMethods: ...@@ -311,7 +310,7 @@ class CocalMethods:
return filter_tree return filter_tree
def generate_dcc(self, perform_dcc_validation=False): def generate_report(self, perform_dcc_validation=False):
if self.transfer_behavior: if self.transfer_behavior:
placeholder_dict = { placeholder_dict = {
"PLACEHOLDER_GIT_HASH": self.get_current_git_hash(), "PLACEHOLDER_GIT_HASH": self.get_current_git_hash(),
...@@ -331,33 +330,33 @@ class CocalMethods: ...@@ -331,33 +330,33 @@ class CocalMethods:
} }
# load template # load template
dcc_template_path = os.path.abspath(r"app/dcc/dcc_template.xml") report_template_path = os.path.abspath(r"app/report/report_template.xml")
dcc_template = open(dcc_template_path, "r") report_template = open(report_template_path, "r")
tree = ET.parse(dcc_template) tree = ET.parse(report_template)
# replace placeholders with substitute from dict # replace placeholders with substitute from dict
tree = self.replace_placeholders_with_substitutes(tree, placeholder_dict) tree = self.replace_placeholders_with_substitutes(tree, placeholder_dict)
# write DCC to file # write report to file
ET.indent(tree) ET.indent(tree)
tree.write( tree.write(
self.dcc_path, self.report_path,
encoding="UTF-8", encoding="UTF-8",
pretty_print=True, pretty_print=True,
) )
# validate against schema (requires internet connection) # validate against schema (requires internet connection)
if perform_dcc_validation: if perform_dcc_validation:
dcc_schema_path = os.path.abspath(r"app/dcc/dcc.xsd") report_schema_path = os.path.abspath(r"app/report/dcc.xsd")
try: try:
schema = xmlschema.XMLSchema(dcc_schema_path) schema = xmlschema.XMLSchema(report_schema_path)
result = schema.validate(self.dcc_path) result = schema.validate(self.report_path)
print(result) print(result)
except Exception as e: except Exception as e:
print(f"Schema did not validate successfully. (Error: {e})") print(f"Schema did not validate successfully. (Error: {e})")
else: else:
print("Can't generate DCC. No transfer behavior available.") print("Can't generate report. No transfer behavior available.")
def replace_placeholders_with_substitutes(self, tree, placeholder_dict): def replace_placeholders_with_substitutes(self, tree, placeholder_dict):
for placeholder, substitute in placeholder_dict.items(): for placeholder, substitute in placeholder_dict.items():
......
...@@ -73,7 +73,7 @@ def cocal_task(db: Session = Depends(get_db), hash = hash): ...@@ -73,7 +73,7 @@ def cocal_task(db: Session = Depends(get_db), hash = hash):
cocal.perform_computations() # perform_dummy_computations cocal.perform_computations() # perform_dummy_computations
# generate (dummy) DCC # generate (dummy) DCC
cocal.generate_dcc() # generate_dummy_dcc cocal.generate_report() # generate_dummy_report
# generate visualization of transfer behaviour # generate visualization of transfer behaviour
cocal.generate_spectral_domain_visualization() cocal.generate_spectral_domain_visualization()
...@@ -167,7 +167,7 @@ def download_certificate(hash: str, db: Session = Depends(get_db)): ...@@ -167,7 +167,7 @@ def download_certificate(hash: str, db: Session = Depends(get_db)):
session = crud.get_cocal_session_by_hash(db, hash) session = crud.get_cocal_session_by_hash(db, hash)
if session.result_state == "ready": if session.result_state == "ready":
filepath = Path(".").joinpath("sessions", session.hash, "dcc.xml") filepath = Path(".").joinpath("sessions", session.hash, "report.xml")
return FileResponse(filepath, filename=filepath.name) return FileResponse(filepath, filename=filepath.name)
else: else:
return {"message": "Result not ready."} return {"message": "Result not ready."}
......
File moved
File moved
File moved
...@@ -30,7 +30,7 @@ cocal.dut_path = "sessions/ad554ee7119047559a2250e7e9678ee4/upload_2.wav" ...@@ -30,7 +30,7 @@ cocal.dut_path = "sessions/ad554ee7119047559a2250e7e9678ee4/upload_2.wav"
cocal.load_files() cocal.load_files()
cocal.perform_computations() cocal.perform_computations()
cocal.generate_dcc() cocal.generate_report()
cocal.generate_spectral_domain_visualization() cocal.generate_spectral_domain_visualization()
......
...@@ -2,10 +2,10 @@ import xmlschema ...@@ -2,10 +2,10 @@ import xmlschema
import os import os
dcc_file = os.path.abspath(r"testing_method\templates\dcc_template.xml") report_file = os.path.abspath(r"testing_method\templates\report_template.xml")
schema_file = os.path.abspath(r"testing_method\templates\dcc.xsd") schema_file = os.path.abspath(r"testing_method\templates\dcc.xsd")
schema = xmlschema.XMLSchema(schema_file) schema = xmlschema.XMLSchema(schema_file)
result = schema.validate(dcc_file) result = schema.validate(report_file)
print(result) print(result)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment