Commit 5b7fbfa4 authored by Margrenzo Gunawan's avatar Margrenzo Gunawan 💬

Update 1_t24_interface.py

rename reversal
parent 970aef71
import json, os import json, os
import csv import csv
from datetime import date from datetime import date
import shutil
import calendar import calendar
from airflow import DAG from airflow import DAG
...@@ -101,6 +102,16 @@ def sql_clean_syntax(ti): ...@@ -101,6 +102,16 @@ def sql_clean_syntax(ti):
def stop_task(**kwargs): def stop_task(**kwargs):
return True return True
def rename_reversal():
formatted_date_today = datetime.now().strftime('%Y%m%d')
formatted_date_yesterday = yesterday_nodash
files_to_process = [f'T24-FT.REVERSAL-{formatted_date_today}.csv', f'T24-TT.REVERSAL-{formatted_date_today}.csv']
for file_info in files_to_process:
destination_path = f"""{Variable.get("LOCAL_PATH")}t24/{yesterday_nodash}/{file_info.replace(formatted_date_today, formatted_date_yesterday)}"""
source_path = f"""{Variable.get("LOCAL_PATH")}t24/{yesterday_nodash}/{file_info}"""
print("file sudah ada") if os.path.exists(destination_path) else shutil.copy2(source_path, destination_path)
with DAG("APJ_1_t24_interface", with DAG("APJ_1_t24_interface",
start_date=datetime(2021, 1, 1), start_date=datetime(2021, 1, 1),
schedule_interval=None, schedule_interval=None,
...@@ -125,6 +136,10 @@ with DAG("APJ_1_t24_interface", ...@@ -125,6 +136,10 @@ with DAG("APJ_1_t24_interface",
) )
rename_reversal = PythonOperator(
task_id='rename_reversal',
python_callable=rename_reversal
)
# sftp_neraca = BashOperator( # sftp_neraca = BashOperator(
# task_id="sftp_xx", # task_id="sftp_xx",
# bash_command=f"""sshpass -p {Variable.get("SFTP_T24_PASSWORD")} sftp -o StrictHostKeyChecking=no -r {Variable.get("SFTP_T24_USER")}@{Variable.get("SFTP_T24_HOST")}:/REPORT.BP/NERACA/*{yesterday_nodash}* {Variable.get("LOCAL_PATH")}t24_neraca/{yesterday_nodash}/""", # bash_command=f"""sshpass -p {Variable.get("SFTP_T24_PASSWORD")} sftp -o StrictHostKeyChecking=no -r {Variable.get("SFTP_T24_USER")}@{Variable.get("SFTP_T24_HOST")}:/REPORT.BP/NERACA/*{yesterday_nodash}* {Variable.get("LOCAL_PATH")}t24_neraca/{yesterday_nodash}/""",
...@@ -298,4 +313,4 @@ with DAG("APJ_1_t24_interface", ...@@ -298,4 +313,4 @@ with DAG("APJ_1_t24_interface",
) )
begin >> sftp_xx >> sftp_ppap >> ds_list_extractor >> csv_clean_syntax >> clean_csv >> pg_ddl_syntax >> pg_create_table >> ds_push_syntax >> sql_clean_syntax >> ds_csv_to_table >> ds_clean_data >> stop_task >> ds_create_table_history_nominatif >> ds_to_history >> set_access_schemma >> set_access_all_table >> set_access_schemma_his >> set_access_all_table_his >> pentaho >> zip_today >> delete_before >> history_finish begin >> sftp_xx >> sftp_ppap >> rename_reversal >> ds_list_extractor >> csv_clean_syntax >> clean_csv >> pg_ddl_syntax >> pg_create_table >> ds_push_syntax >> sql_clean_syntax >> ds_csv_to_table >> ds_clean_data >> stop_task >> ds_create_table_history_nominatif >> ds_to_history >> set_access_schemma >> set_access_all_table >> set_access_schemma_his >> set_access_all_table_his >> pentaho >> zip_today >> delete_before >> history_finish
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment