conversion lpp s3 output file saving
This commit is contained in:
parent
5288f6ba1b
commit
37654cb4ec
|
@ -466,6 +466,60 @@ class Conversion:
|
|||
|
||||
|
||||
|
||||
"""Translation Completion mail here"""
|
||||
|
||||
to = self.user.email
|
||||
key_value = {
|
||||
"User": self.user.username,
|
||||
"title": self.original_script_object.script_title
|
||||
}
|
||||
sendmail(to_email=[to], email_code="PP18", key_value=key_value)
|
||||
|
||||
"""Translation Completion mail done"""
|
||||
|
||||
|
||||
|
||||
"""Vetting Process if Choosen"""
|
||||
# sys.stdout = original_stdout
|
||||
if self.translated_script_object.lpp:
|
||||
X = LPPTASKDatabase()
|
||||
X.user_id = self.translated_script_object.user_id
|
||||
X.usernote = "Kindly check if the translated file is correct as per the Uploaded Document!"
|
||||
X.translated_script = self.translated_script_object
|
||||
X.generated_from = "conversion"
|
||||
temp_amount = self.amount_without_subscrption
|
||||
X.amoutgiventolpp_action = round((temp_amount / 2), 2)
|
||||
X.amoutgiventolpp_dialogue = round((temp_amount / 2), 2)
|
||||
X.save()
|
||||
task_assigner(int(X.task_id), "conversion")
|
||||
|
||||
|
||||
# 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
|
||||
import os
|
||||
import boto3
|
||||
bucket = "conversion-kitchen"
|
||||
s3_client = boto3.client('s3',
|
||||
aws_access_key_id="AKIAQVLBBGCB45RMLKVW",
|
||||
aws_secret_access_key="ZWc6KOc5LuBLuCEBDDfQTor+Q7rp3fFH74gVt+AA",
|
||||
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}"
|
||||
self.translated_script_object.translated_script_pdf = s3_url
|
||||
print(response)
|
||||
except Exception as e:
|
||||
print("Error is", e)
|
||||
|
||||
|
||||
|
||||
|
||||
else:
|
||||
|
||||
"""Blockchain Upload Starts here"""
|
||||
# sys.stdout = original_stdout
|
||||
scriptconversion = {}
|
||||
|
@ -530,35 +584,6 @@ class Conversion:
|
|||
|
||||
|
||||
|
||||
"""Translation Completion mail here"""
|
||||
|
||||
to = self.user.email
|
||||
key_value = {
|
||||
"User": self.user.username,
|
||||
"title": self.original_script_object.script_title
|
||||
}
|
||||
sendmail(to_email=[to], email_code="PP18", key_value=key_value)
|
||||
|
||||
"""Translation Completion mail done"""
|
||||
|
||||
|
||||
|
||||
"""Vetting Process if Choosen"""
|
||||
# sys.stdout = original_stdout
|
||||
if self.translated_script_object.lpp:
|
||||
X = LPPTASKDatabase()
|
||||
X.user_id = self.translated_script_object.user_id
|
||||
X.usernote = "Kindly check if the translated file is correct as per the Uploaded Document!"
|
||||
X.translated_script = self.translated_script_object
|
||||
X.generated_from = "conversion"
|
||||
temp_amount = self.amount_without_subscrption
|
||||
X.amoutgiventolpp_action = round((temp_amount / 2), 2)
|
||||
X.amoutgiventolpp_dialogue = round((temp_amount / 2), 2)
|
||||
X.save()
|
||||
task_assigner(int(X.task_id), "conversion")
|
||||
|
||||
"""Vetting Process Done"""
|
||||
|
||||
"""Process Completed"""
|
||||
self.translated_script_object.status = "Completed"
|
||||
self.translated_script_object.save()
|
||||
|
|
Loading…
Reference in New Issue