init
This commit is contained in:
50
python/mrds_common/mrds/docs/upload.py
Normal file
50
python/mrds_common/mrds/docs/upload.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# 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)
|
||||
Reference in New Issue
Block a user