This commit is contained in:
Ubuntu 2024-11-12 10:22:32 +00:00
parent fea3542506
commit 55eff06ff3
2 changed files with 67 additions and 31 deletions

View File

@ -33,6 +33,7 @@ def background_execution(obj):
def run_conversion(msg): def run_conversion(msg):
print("inside run_conversion")
body_dict = json.loads(msg.body) body_dict = json.loads(msg.body)
msg.delete() msg.delete()
translated_script = ScriptTranslations.objects.get(translation_id=body_dict["translation_id"]) translated_script = ScriptTranslations.objects.get(translation_id=body_dict["translation_id"])
@ -44,7 +45,7 @@ def run_conversion(msg):
region_name="ap-south-1" region_name="ap-south-1"
) )
s3_client.download_file("conversion-kitchen", object_key, local_file_path) s3_client.download_file("conversion-kitchen", object_key, local_file_path)
print("i am here below s3_client")
audit_user = User.objects.get(id=1) audit_user = User.objects.get(id=1)
conversion_params = { conversion_params = {
"audit_user": audit_user, "audit_user": audit_user,
@ -108,7 +109,8 @@ class Request:
def lpp_audit(msg): def lpp_audit(msg):
import boto3 import boto3
from lpp.models import LPPTASKDatabase from lpp.models import LPPTASKDatabase,MNFLPPDDatabase
from decimal import Decimal
from utils import filesystem, utilities from utils import filesystem, utilities
from centralisedFileSystem.models import Script from centralisedFileSystem.models import Script
from scriptAudit.models import ScriptAuditModel from scriptAudit.models import ScriptAuditModel
@ -123,7 +125,16 @@ def lpp_audit(msg):
from Blockchain2.block_user_info import user_info from Blockchain2.block_user_info import user_info
body_dict = json.loads(msg.body) body_dict = json.loads(msg.body)
msg.delete() msg.delete()
with open(f"/home/ubuntu/Conversion_Kitchen_Code/kitchen_counter/MNF/json_keys/conversionRates.json") as c:
curr = json.load(c)
try:
usd_inr_rate = curr["rates"]["INR"]
# c = CurrencyRates()
# rate = c.get_rate("USD", str(currency.upper()))
except Exception as e:
print("checkout error", e)
usd_inr_rate = 80
print("ran till here 1") print("ran till here 1")
task_id = body_dict.get("task_id", None) task_id = body_dict.get("task_id", None)
@ -139,7 +150,9 @@ def lpp_audit(msg):
pass pass
lpp_user = LPPTASKDatabase.objects.get(task_id=task_id) lpp_user = LPPTASKDatabase.objects.get(task_id=task_id)
# x = LPPTASKDatabase.objects.get(task_id=pk)
# lpp_amount = MNFLPPDDatabase.objects.get(lpp_id=lpp_user.assignedlpp_dialogue.lpp_id)
if outputfile is None: if outputfile is None:
pass pass
@ -202,33 +215,14 @@ def lpp_audit(msg):
), ),
defaults={"status" : "SUCCESS"} defaults={"status" : "SUCCESS"}
) )
lpp_user.status = "completed"
lpp_user.save()
except Exception as exp: except Exception as exp:
ScriptAuditModel.objects.update_or_create(script = Script.objects.get(id = audit_id), ScriptAuditModel.objects.update_or_create(script = Script.objects.get(id = audit_id),
defaults={"status" : "FAILURE", defaults={"status" : "FAILURE",
"results" : exp}) "results" : exp})
print("audit will start") print("audit will start")
# if id is not None:
# from mnfapp.models import MNFScriptDatabase
# script_get = MNFScriptDatabase.objects.get(id=id)
# script_get.language_audit_id = audit_id
# script_get.save()
# try:
# audit.audit()
# status.status = "SUCCESS"
# status.save()
# to = lpp_user.assignedlpp_action.lpp_email
# key_value = {
# "User": lpp_user.assignedlpp_action.user_id.username,
# "Amount": lpp_user.amoutgiventolpp_action
# }
# sendmail(to_email=[to], email_code="PP14", key_value=key_value)
# except Exception as e:
# print("Error of Audit is:", e)
# status.status = "FAILURE"
# status.save()
# sys.stdout = original_stdout
except Exception as e: except Exception as e:
print("Error in auditing vetted output is", e) print("Error in auditing vetted output is", e)
print("ran till here 11") print("ran till here 11")
@ -239,8 +233,26 @@ def lpp_audit(msg):
id = audit_id id = audit_id
)) ))
scriptconversion = {} scriptconversion = {}
print("ADDING LPP BALANCE HERE \n\n\n")
try: try:
if status.status == "SUCCESS": if status.status == "SUCCESS":
print("#### STATUS iS SUCESSS @############\n\n")
# adding amount to the wallet here
lpp_amount = MNFLPPDDatabase.objects.get(lpp_id=lpp_user.assignedlpp_action.lpp_id)
print("##### try to add amount here#####\n\n\n")
try:
lpp_amount.lpp_task_balance = float(Decimal(
str(lpp_amount.lpp_task_balance))) + float(float(Decimal(str(lpp_user.amoutgiventolpp_dialogue))) * usd_inr_rate)
print("TRY BLOCK COMPLETE")
print(str(lpp_amount.lpp_task_balance))
except Exception as e:
print("\n\n#####LPP Balance Error", e)
lpp_amount.lpp_task_balance = 0.00 + \
float(
float(Decimal(lpp_user.amoutgiventolpp_dialogue)) * usd_inr_rate)
lpp_amount.save()
print("#######the AMOUNT iS ADDED ##########\n\n\n")
to = lpp_user.assignedlpp_action.lpp_email to = lpp_user.assignedlpp_action.lpp_email
key_value = { key_value = {
"User": lpp_user.assignedlpp_action.user_id.username, "User": lpp_user.assignedlpp_action.user_id.username,
@ -278,9 +290,10 @@ def lpp_audit(msg):
print("blockchain script conversion 5.1") print("blockchain script conversion 5.1")
# blockchain upload of csv-json data # blockchain upload of csv-json data
adit_id = obj.converted_audit_id adit_id = obj.converted_audit_id
print("######ADIT ID",adit_id)
print("###########@@@@@@@@@ AUDIT ID",audit_id)
file_to_audit = File.objects.get( file_to_audit = File.objects.get(
script=adit_id, script=audit_id,
type="script-csv" type="script-csv"
) )
csv_script_path = file_to_audit.file.path csv_script_path = file_to_audit.file.path
@ -317,6 +330,23 @@ def lpp_audit(msg):
print("Tx id -> ", tx_id, tx_gas_fee) print("Tx id -> ", tx_id, tx_gas_fee)
# user_infos = user_info(tx_hash=tx_id, service="Conversion", gas_fee=2345432345123456) # user_infos = user_info(tx_hash=tx_id, service="Conversion", gas_fee=2345432345123456)
# addition_result = user_infos.update_info(request) # addition_result = user_infos.update_info(request)
######## UPLOADING THE FILE FOR LPP USER (LLP SIDE VIEW BUTTON)
blockchain_obj_for_lpp = UserCredentialsForBlockchain.objects.get(user=lpp_user.assignedlpp_action.user_id)
UserId_for_lpp = blockchain_obj_for_lpp.user_id
Data_for_lpp = str(scriptconversion)
userPrivateKey_for_lpp = blockchain_obj_for_lpp.privateKey
userkey_for_lpp = decryptionOfPrivate(userPrivateKey_for_lpp)
tx_id_for_lpp, tx_gas_fee_for_lpp = UploadConversionData(OWNER_KEY, blockchain_obj_for_lpp.publicKey, UserId_for_lpp,
str(Project),
Data_for_lpp)
print("LPP USER BLOCKCHAIN and REAL USER BLOCKCHAIN UPLOADED")
print("Project-------->",Project)
name_script = (((uploaded_script.split("/"))[-1]).split("."))[0] name_script = (((uploaded_script.split("/"))[-1]).split("."))[0]
try: try:
user_infos = user_info(tx_hash=tx_id, service="Conversion", gas_fee=tx_gas_fee, user_infos = user_info(tx_hash=tx_id, service="Conversion", gas_fee=tx_gas_fee,
@ -428,7 +458,8 @@ class Command(BaseCommand):
print(type(msg.body)) print(type(msg.body))
body_dict = json.loads(msg.body) body_dict = json.loads(msg.body)
if body_dict['service_type'] == "conversion": if body_dict['service_type'] == "conversion":
print("Entering Conversion")
print(str(body_dict))
run_conversion(msg) run_conversion(msg)
elif body_dict['service_type'] == "audit": elif body_dict['service_type'] == "audit":
@ -441,6 +472,7 @@ class Command(BaseCommand):
except Exception as error: except Exception as error:
print("error execution from queue: %s", error) print("error execution from queue: %s", error)
print(repr(error))
else: else:
break break

View File

@ -2053,7 +2053,7 @@ def task_assigner(taskid, source):
# # x.usernote = "Kindly check if the Created 'Subtitles' are correct as per the Uploaded Video!" # # x.usernote = "Kindly check if the Created 'Subtitles' are correct as per the Uploaded Video!"
# # else: # # else:
# # x.status = "" # # x.status = ""
print("task assigner funcation called")
if source == "conversion": if source == "conversion":
# translate_srt, conversion, one_pager # translate_srt, conversion, one_pager
# if the actionline is translated or not # if the actionline is translated or not
@ -2114,6 +2114,8 @@ def task_assigner(taskid, source):
return True return True
count = 0 count = 0
for i in y: for i in y:
print("x.translated_script.script_link_id.nondial_src_script",x.translated_script.script_link_id.nondial_src_script)
print("x.translated_script.dial_dest_script",x.translated_script.dial_dest_script)
if x.translated_script.script_link_id.nondial_src_script in i.scripts and x.translated_script.dial_dest_script in i.scripts: if x.translated_script.script_link_id.nondial_src_script in i.scripts and x.translated_script.dial_dest_script in i.scripts:
if count < 3: if count < 3:
@ -2150,6 +2152,8 @@ def task_assigner(taskid, source):
# ).start() # ).start()
else: else:
x.eligiblelpp_action.add(i) x.eligiblelpp_action.add(i)
print("assigned lpp action",x.assignedlpp_action)
print(x.eligiblelpp_action)
x.status = "actionline_lppassigned" x.status = "actionline_lppassigned"
x.usernote = "Kindly check if the translated 'ACTION LINES' and 'DIALOGUE LINES' are correct as per the Uploaded Document!" x.usernote = "Kindly check if the translated 'ACTION LINES' and 'DIALOGUE LINES' are correct as per the Uploaded Document!"
pass pass
@ -2249,7 +2253,7 @@ def task_assigner(taskid, source):
# ).start() # ).start()
else: else:
x.eligiblelpp_action.add(i) x.eligiblelpp_action.add(i)
print(x.assignedlpp_action) print("assigned lpp action else",x.assignedlpp_action)
print(x.eligiblelpp_action) print(x.eligiblelpp_action)
x.status = "actionline_lppassigned" x.status = "actionline_lppassigned"
x.usernote = "Kindly check if the translated 'ACTION LINES' are correct as per the Uploaded Document!" x.usernote = "Kindly check if the translated 'ACTION LINES' are correct as per the Uploaded Document!"