diff --git a/src/dou_dag_generator.py b/src/dou_dag_generator.py old mode 100644 new mode 100755 index 28c5463..c9ccff9 --- a/src/dou_dag_generator.py +++ b/src/dou_dag_generator.py @@ -43,8 +43,20 @@ class DouDigestDagGenerator(): database. """ - SOURCE_DIR = os.path.join(os.environ['AIRFLOW_HOME'], 'dags/ro_dou/') - YAMLS_DIR = os.path.join(SOURCE_DIR, 'dag_confs/') + base_dir = os.path.join(os.environ['AIRFLOW_HOME'], 'dags') + dir_name = 'ro_dou' + + # Walk through the directory tree to find the directory + for root, dirs, files in os.walk(base_dir): + if dir_name in dirs: + # If the directory is found, print its path and exit the loop + SOURCE_DIR = os.path.join(root, dir_name) + break + else: + # If the directory is not found, print a message + raise Exception("{dir_name} directory not found in {base_dir} or its subdirectories.") + + YAMLS_DIR = os.path.join(SOURCE_DIR, 'dag_confs') parser = YAMLParser searchers: Dict[str, BaseSearcher] @@ -283,7 +295,7 @@ def send_report(self, search_report_str: str, subject, report_date, email_to_list, attach_csv, skip_null): """Builds the email content, the CSV if applies, and send it """ - full_subject = f"{subject} - DOs de {report_date}" + full_subject = f"{subject} - DOs de {report_date}" search_report = ast.literal_eval(search_report_str) items = ['contains' for k, v in search_report.items() if v] if items: