Update kitchen_counter/scriptAudit/views.py
added print statements and added gasprice in line number 768
This commit is contained in:
parent
3e450093e6
commit
0b1aacb560
|
@ -258,10 +258,22 @@ def run_audit_in_counter(msg):
|
|||
audit_data={}
|
||||
script_original["status"] = "STARTED"
|
||||
script_original["script_id"] = script_id
|
||||
try:
|
||||
print("Orginal File path is here-->",file_to_original.file.path)
|
||||
print("blockchain obj", blockchain_obj)
|
||||
print("FileSecure on -->",blockchain_obj.FileSecureOn)
|
||||
except:
|
||||
print("Faile in printing file path :print no worries needed i was just prting the file path")
|
||||
with open(file_to_original.file.path, 'rb') as file:
|
||||
hash = uploadDataToIPFSNode(file)
|
||||
print("printing hash here -->",str(hash))
|
||||
django_file = File2(file)
|
||||
try:
|
||||
print("django file,-->",str(django_file))
|
||||
except:
|
||||
print("django_file didnt print")
|
||||
filename = os.path.basename(file_to_original.file.path)
|
||||
print("Filename is here -->",str(filename))
|
||||
files, _ = MNFServersFile.objects.get_or_create(
|
||||
project_id= script_id,
|
||||
file_type="script-original",
|
||||
|
@ -271,6 +283,7 @@ def run_audit_in_counter(msg):
|
|||
script_original["type"] = "script-original"
|
||||
script_original["script_file_path"] = file_to_original.file.path
|
||||
audit_data["script-original"] = script_original
|
||||
print("audit data in script-original-->",audit_data)
|
||||
userkey= decryptionOfPrivate(blockchain_obj.privateKey)
|
||||
print("userkey = ", str(userkey))
|
||||
print("blockchain_obj.publicKey",blockchain_obj.publicKey)
|
||||
|
@ -479,7 +492,7 @@ def run_audit_in_counter(msg):
|
|||
data = {"message": "Success"}
|
||||
|
||||
else:
|
||||
|
||||
print("the file is not fdx")
|
||||
file_to_audit = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-csv"
|
||||
|
@ -494,6 +507,7 @@ def run_audit_in_counter(msg):
|
|||
hash2 = ""
|
||||
hash2_docx = ""
|
||||
try:
|
||||
print("script-docx")
|
||||
file_to_audit_docx = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-docx"
|
||||
|
@ -513,7 +527,10 @@ def run_audit_in_counter(msg):
|
|||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
audit_data["script-docx"] = script_docx
|
||||
print("script_docx is -->",script_docx)
|
||||
print("audit_data is -->",audit_data)
|
||||
except:
|
||||
print("except blocck script-docx")
|
||||
csv_script_path = file_to_audit.file.path
|
||||
df = pd.read_csv(csv_script_path)
|
||||
docx = utilities.csv_to_docx(df)
|
||||
|
@ -539,6 +556,7 @@ def run_audit_in_counter(msg):
|
|||
script_docx = {}
|
||||
script_path1 = file_to_audit_docx.file.path
|
||||
script_size = file_to_audit_docx.file.size
|
||||
print("script_path1 -->",script_path1)
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
django_file = File2(_file)
|
||||
|
@ -552,13 +570,15 @@ def run_audit_in_counter(msg):
|
|||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
audit_data["script-docx"] = script_docx
|
||||
|
||||
print("script_docx is -->",script_docx)
|
||||
print("audit_data is -->",audit_data)
|
||||
## code for pdf also
|
||||
try:
|
||||
temp_dir = tempfile.TemporaryDirectory()
|
||||
pdf_file_path = utilities.docx_to_pdf(
|
||||
script_path1, temp_dir.name)
|
||||
|
||||
print("pdf_path")
|
||||
print("pdf is loading -->",script_path1)
|
||||
with open(pdf_file_path, "rb") as temp_pdf:
|
||||
|
||||
pdf_file = DjangoFile(temp_pdf,pdf_file_path.rsplit('/', 1)[1],)
|
||||
|
@ -571,6 +591,7 @@ def run_audit_in_counter(msg):
|
|||
script_pdf = {}
|
||||
script_path1 = pdf_file_path
|
||||
# script_size = file_to_audit_docx.file.size
|
||||
print("script_path1 -->",script_path1)
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
django_file = File2(_file)
|
||||
|
@ -584,11 +605,15 @@ def run_audit_in_counter(msg):
|
|||
script_pdf["script_file"] = hash2
|
||||
script_pdf["type"] = "script-pdf"
|
||||
audit_data["script-pdf"] = script_pdf
|
||||
print("script_pdf is -->",script_pdf)
|
||||
print("audit_data is -->",audit_data)
|
||||
except:
|
||||
pass
|
||||
# convert csv to json and store JSON
|
||||
try:
|
||||
print("JSON PART is HERE")
|
||||
csv_script_path = file_to_audit.file.path
|
||||
print("csv_script_path-->",csv_script_path)
|
||||
df = pd.read_csv(csv_script_path)
|
||||
df = df.loc[:, ["content", "script_element"]]
|
||||
script_json: dict = json.loads(utilities.csv_to_json(df))
|
||||
|
@ -601,6 +626,7 @@ def run_audit_in_counter(msg):
|
|||
script_json = {}
|
||||
script_path1 = temp_filename
|
||||
# script_size = file_to_audit_docx.file.size
|
||||
print("script_path1-->",script_path1)
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
django_file = File2(_file)
|
||||
|
@ -616,6 +642,8 @@ def run_audit_in_counter(msg):
|
|||
script_json["screenplay_name"] = str(screenplay_name)
|
||||
audit_data["script-json"] = script_json
|
||||
print("data_uploaded")
|
||||
print("script_json is -->",script_json)
|
||||
print("audit_data is -->",audit_data)
|
||||
except Exception as exp:
|
||||
print("###ERROR:",exp)
|
||||
print("######Error from JSON CREATION############")
|
||||
|
@ -623,7 +651,7 @@ def run_audit_in_counter(msg):
|
|||
|
||||
script_csv = {}
|
||||
audit_report ={}
|
||||
|
||||
print("here iam ")
|
||||
script_path = file_to_audit.file.path
|
||||
script_size = file_to_audit.file.size
|
||||
|
||||
|
@ -640,7 +668,7 @@ def run_audit_in_counter(msg):
|
|||
files.public_file.save(filename, django_file)
|
||||
script_csv["script_file_path"] = script_path
|
||||
script_csv["type"] = "script-csv"
|
||||
|
||||
print("script-csv done")
|
||||
try:
|
||||
audit_report_path = file_to_audit_report.file.path
|
||||
with open(audit_report_path, 'rb') as file1:
|
||||
|
@ -660,13 +688,15 @@ def run_audit_in_counter(msg):
|
|||
except:
|
||||
pass
|
||||
if status.User_preference != "MNF":
|
||||
print("audit data",audit_data)
|
||||
print("script_id-->",script_id
|
||||
|
||||
Response,gasprice = UploadScriptAuditData(OWNER_KEY,blockchain_obj.publicKey,blockchain_obj.user_id,script_id,str(audit_data))
|
||||
print("tx_hash",Response)
|
||||
transactioni_id = str(Response)
|
||||
status.transaction_hash =str(transactioni_id)
|
||||
status.save()
|
||||
|
||||
print("trying to send mail")
|
||||
to_email = [user.email]
|
||||
email_code = 'SB1'
|
||||
key_value_aud = { "Script Name" : str(screenplay_name),
|
||||
|
@ -734,14 +764,14 @@ def run_audit_in_counter(msg):
|
|||
|
||||
|
||||
else:
|
||||
|
||||
print("trying to sed mail; dsf")
|
||||
to_email = [user.email]
|
||||
email_code = 'SB2'
|
||||
key_value_aud = { "Script Name" : str(screenplay_name),
|
||||
"Audited script url" : f"{settings.SITE_DOMAIN}/audit/audits1",}
|
||||
sendmail(to_email=to_email , email_code=email_code, key_value = key_value_aud )
|
||||
|
||||
Response = UploadScriptAuditData(OWNER_KEY,blockchain_obj.publicKey,blockchain_obj.user_id,script_id,str(audit_data))
|
||||
print("gas price added now")
|
||||
Response, gasprice = UploadScriptAuditData(OWNER_KEY,blockchain_obj.publicKey,blockchain_obj.user_id,script_id,str(audit_data))
|
||||
print("tx_hash",Response)
|
||||
hash = hash_decrypation(hash)
|
||||
#certificate = certificateGenrate(request.user.username,"script audit",hash)
|
||||
|
@ -753,7 +783,7 @@ def run_audit_in_counter(msg):
|
|||
"Audited script url" : f"{settings.SITE_DOMAIN}/audit/counter_run",}
|
||||
sendmail(to_email=to_email , email_code=email_code, key_value = key_value_aud )
|
||||
# certificate = certificateGenrate(request.user.username,"script audit",tx_id,projectname=script_file_name,matic=gasprice)
|
||||
|
||||
print("buddy please")
|
||||
to_email = [user.email]
|
||||
email_code = 'BL1'
|
||||
# key_value = {
|
||||
|
@ -771,7 +801,7 @@ def run_audit_in_counter(msg):
|
|||
}
|
||||
certificate = certificateGenrate(user.username,"script audit",tx_id,projectname=script_file_name,matic=gasprice)
|
||||
sendmail(to_email=to_email , email_code=email_code, key_value=key_value, filePath=certificate)
|
||||
|
||||
print()
|
||||
print("::::::::::::::",key_value)
|
||||
print("userkey = ", userkey)
|
||||
|
||||
|
|
Loading…
Reference in New Issue