Files
mars-elt/python/mrds_common/mrds/docs/upload.py
Grzegorz Michalski 2c225d68ac init
2026-03-02 09:47:35 +01:00

51 lines
1.2 KiB
Python

# file uploader
import os
import sys
import logging
from mrds.utils import objectstore
BUCKET = os.getenv("INBOX_BUCKET", "mrds_inbox_poc")
BUCKET_NAMESPACE = os.getenv("BUCKET_NAMESPACE", "frcnomajoc7v")
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s - %(message)s",
handlers=[
logging.StreamHandler(sys.stdout),
],
)
source_filepath = '/home/dbt/tmp/mrds_4twsw_ib/20250630_Pre-Production_DV_P2_DBT_I4.zip'
source_filename = '20250630_Pre-Production_DV_P2_DBT_I4.zip'
target_prefix = 'INBOX/CSDB/STC_CentralizedSecuritiesDissemination_ECB'
def upload_file():
client = objectstore.get_client()
logging.info(
f"uploading source file to '{BUCKET}/{target_prefix}/{source_filename}'"
)
objectstore.upload_file(
client,
source_filepath,
BUCKET_NAMESPACE,
BUCKET,
target_prefix,
source_filename,
)
logging.info(
f"Source file uploaded to '{BUCKET}/{target_prefix}/{source_filename}'"
)
if __name__ == "__main__":
try:
upload_file()
sys.exit(0)
except Exception as e:
logging.error(f"Unexpected error: {e}")
sys.exit(1)