From 152eab4b515be16f52bb2698202d380eb1d83e89 Mon Sep 17 00:00:00 2001 From: user <user@cocal-machine.local> Date: Tue, 23 Jan 2024 12:08:16 +0100 Subject: [PATCH] include switch for dcc validation --- app/cocal_methods.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/cocal_methods.py b/app/cocal_methods.py index 365210f..9e93f05 100644 --- a/app/cocal_methods.py +++ b/app/cocal_methods.py @@ -156,13 +156,13 @@ class CocalMethods: soundfile.close() def upload_is_ready(self): - # return self.dut_path.exists() - return True + return self.dut_path.exists() + # return True def wait_for_user_upload(self, timeout=10): start = time.time() while not self.upload_is_ready(): - time.wait(1) + time.sleep(1) if time.time() - start > timeout: break return self.upload_is_ready() @@ -313,7 +313,7 @@ class CocalMethods: return filter_tree - def generate_dcc(self): + def generate_dcc(self, perform_dcc_validation=False): if self.transfer_behavior: placeholder_dict = { "PLACEHOLDER_GIT_HASH": self.get_current_git_hash(), @@ -344,14 +344,15 @@ class CocalMethods: ET.indent(tree) tree.write(self.dcc_path, encoding="UTF-8", pretty_print=True, ) - # validate against schema - dcc_schema_path = os.path.abspath(r"app/dcc/dcc.xsd") - try: - schema = xmlschema.XMLSchema(dcc_schema_path, validation="lax") # strict (default) requires internet connection - result = schema.validate(self.dcc_path) - print(result) - except Exception as e: - print(f"Schema did not validate successfully. (Error: {e})") + # validate against schema (requires internet connection) + if perform_dcc_validation: + dcc_schema_path = os.path.abspath(r"app/dcc/dcc.xsd") + try: + schema = xmlschema.XMLSchema(dcc_schema_path) + result = schema.validate(self.dcc_path) + print(result) + except Exception as e: + print(f"Schema did not validate successfully. (Error: {e})") else: print("Can't generate DCC. No transfer behavior available.") -- GitLab