conversion add files to s3 even when no lpp for testing

This commit is contained in:
Ubuntu 2024-05-13 07:55:11 +00:00
parent 9e11ea778d
commit 1481720be0
1 changed files with 37 additions and 15 deletions

View File

@ -481,6 +481,27 @@ class Conversion:
"""Translation Completion mail done""" """Translation Completion mail done"""
# adding file to s3 output folder
object_name = "OUTPUT/" + (self.translated_script_object.translated_script_path.split("/"))[-1]
filee = basePath + self.translated_script_object.translated_script_path
# Upload the file
bucket = "conversion-kitchen"
s3_client = boto3.client('s3',
aws_access_key_id="AKIAQVLBBGCB45RMLKVW",
aws_secret_access_key="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",
region_name="ap-south-1"
)
try:
response = s3_client.upload_file(filee, bucket, object_name)
s3_url = f"https://{bucket}.s3.ap-south-1.amazonaws.com/{object_name}"
print(response)
except Exception as e:
print("Error is", e)
"""Vetting Process if Choosen""" """Vetting Process if Choosen"""
# sys.stdout = original_stdout # sys.stdout = original_stdout
@ -499,22 +520,22 @@ class Conversion:
# adding file to s3 output folder # adding file to s3 output folder
object_name = "OUTPUT/" + (self.translated_script_object.translated_script_path.split("/"))[-1] # object_name = "OUTPUT/" + (self.translated_script_object.translated_script_path.split("/"))[-1]
filee = basePath + self.translated_script_object.translated_script_path # filee = basePath + self.translated_script_object.translated_script_path
# Upload the file # # Upload the file
bucket = "conversion-kitchen" # bucket = "conversion-kitchen"
s3_client = boto3.client('s3', # s3_client = boto3.client('s3',
aws_access_key_id="AKIAQVLBBGCB45RMLKVW", # aws_access_key_id="AKIAQVLBBGCB45RMLKVW",
aws_secret_access_key="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", # aws_secret_access_key="ZWc6KOc5LuBLuCEBDDfQTor+Q7rp3fFH74gVt+AA",
region_name="ap-south-1" # region_name="ap-south-1"
) # )
try: # try:
response = s3_client.upload_file(filee, bucket, object_name) # response = s3_client.upload_file(filee, bucket, object_name)
s3_url = f"https://{bucket}.s3.ap-south-1.amazonaws.com/{object_name}" # s3_url = f"https://{bucket}.s3.ap-south-1.amazonaws.com/{object_name}"
print(response) # print(response)
except Exception as e: # except Exception as e:
print("Error is", e) # print("Error is", e)
else: else:
@ -621,6 +642,7 @@ class Conversion:
self.translated_script_object.status = "Completed" self.translated_script_object.status = "Completed"
try: try:
self.translated_script_object.blockchain_txhash = tx_id self.translated_script_object.blockchain_txhash = tx_id
self.translated_script_object.translated_script_pdf = s3_url
except: except:
self.translated_script_object.translated_script_pdf = s3_url self.translated_script_object.translated_script_pdf = s3_url
self.translated_script_object.save() self.translated_script_object.save()