Audit Changes, email changes and some blockchain changes
This commit is contained in:
parent
e6fa5b8293
commit
8efd0e495b
|
@ -1,8 +1,10 @@
|
|||
|
||||
from web3 import Web3
|
||||
from web3.middleware import geth_poa_middleware
|
||||
|
||||
|
||||
web3 = Web3(Web3.HTTPProvider("https://rpc-amoy.polygon.technology/"))
|
||||
# CAddress = '0x953113427cdCA32e360727d1298f9B83f06c23a6'
|
||||
web3.middleware_onion.inject(geth_poa_middleware, layer=0)
|
||||
|
||||
def get_user_Balance(public_key):
|
||||
# Get the balance of the Ethereum address
|
||||
|
@ -14,13 +16,15 @@ def get_user_Balance(public_key):
|
|||
|
||||
|
||||
def get_transction_recipt(tx):
|
||||
print(tx,"txx")
|
||||
response = web3.eth.get_transaction_receipt(tx)
|
||||
print(response)
|
||||
return response
|
||||
|
||||
|
||||
|
||||
timestamp = web3.eth.get_block(response.blockNumber).timestamp
|
||||
return response,timestamp
|
||||
|
||||
# get_transction_recipt("0xfacda3343495205bf1de5cfe096290c82c6fafcf319844935139b883e00c47c8")
|
||||
|
||||
def mypublickey(key):
|
||||
acc1 = web3.eth.account.from_key(key).address
|
||||
return acc1
|
||||
|
||||
|
||||
|
||||
|
|
Binary file not shown.
|
@ -11,12 +11,7 @@ from django.core.management import call_command
|
|||
from mnfapp.models import ScriptTranslations
|
||||
from MNF.settings import BasePath
|
||||
from conversion.translation.external_conversion import Conversion
|
||||
from centralisedFileSystem.models import Script, File
|
||||
from scriptAudit.models import ScriptAuditModel
|
||||
from scriptAudit.models import States
|
||||
from utils import filesystem, utilities
|
||||
from scriptAudit.utils import update_audit_status
|
||||
from scriptAudit.mnf_script_audit import NeutralAudit
|
||||
from scriptAudit.views import run_audit_in_counter
|
||||
from django.core.files.base import ContentFile
|
||||
from django.contrib.auth import get_user_model
|
||||
from users.models import UserCredentialsForBlockchain
|
||||
|
@ -74,12 +69,6 @@ def run_conversion(msg):
|
|||
|
||||
|
||||
def run_audit(msg):
|
||||
from Blockchain2.decryption import decryptionOfPrivate, decryptionOfUrl, download_file_System,decryptionOflocalUrl,hash_decrypation
|
||||
from Blockchain2.DataStorage import uploadDataToIPFSNode
|
||||
from Blockchain2.scriptAudit import getUserprojectIds,UploadScriptAuditData,getScriptAudit
|
||||
from Blockchain2.blockchainsetting import OWNER_KEY
|
||||
|
||||
print("Hello World inside ")
|
||||
body_dict = json.loads(msg.body)
|
||||
msg.delete()
|
||||
user = body_dict.get("user")
|
||||
|
@ -100,453 +89,17 @@ def run_audit(msg):
|
|||
)
|
||||
print(object_key, local_file_path)
|
||||
s3_client.download_file("conversion-kitchen", object_key, local_file_path)
|
||||
print("113")
|
||||
|
||||
with open(local_file_path, 'rb') as file:
|
||||
file_content = file.read()
|
||||
|
||||
file = ContentFile(
|
||||
file_content,
|
||||
script_file_name,
|
||||
)
|
||||
|
||||
user = User.objects.get(username=user)
|
||||
|
||||
result = filesystem.new_screenplay_without_audit_in_background(
|
||||
user,
|
||||
author,
|
||||
screenplay_name,
|
||||
file,
|
||||
"script-original",
|
||||
language,
|
||||
)
|
||||
|
||||
|
||||
script_id = result.get("script", {}).get("id")
|
||||
|
||||
file_to_original = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-original"
|
||||
|
||||
)
|
||||
try:
|
||||
update_audit_status(script_id, States.STARTED)
|
||||
except:
|
||||
update_audit_status(script_id, States.FAILURE)
|
||||
|
||||
|
||||
try:
|
||||
|
||||
audit = NeutralAudit(script_id)
|
||||
audit.audit_in_background()
|
||||
ScriptAuditModel.objects.update_or_create(
|
||||
script = Script.objects.get(
|
||||
id = script_id
|
||||
),
|
||||
defaults={"status" : "SUCCESS"}
|
||||
)
|
||||
|
||||
|
||||
|
||||
except:
|
||||
ScriptAuditModel.objects.update_or_create(
|
||||
script = Script.objects.get(
|
||||
id = script_id
|
||||
),
|
||||
defaults={"status" : "FAILURE"}
|
||||
)
|
||||
|
||||
status = ScriptAuditModel.objects.get(
|
||||
script = Script.objects.get(
|
||||
id = script_id
|
||||
))
|
||||
print("STATUS AUDIT",status)
|
||||
status.only_audit = True
|
||||
# Blockchain
|
||||
# if UserCredentialsForBlockchain.objects.filter(user=request.user).exists():
|
||||
blockchain_obj = UserCredentialsForBlockchain.objects.get(user=user)
|
||||
script_original= {}
|
||||
audit_data={}
|
||||
script_original["status"] = "STARTED"
|
||||
script_original["script_id"] = script_id
|
||||
with open(file_to_original.file.path, 'rb') as file:
|
||||
hash = uploadDataToIPFSNode(file)
|
||||
script_original["script_file"] = hash
|
||||
script_original["type"] = "script-original"
|
||||
script_original["script_file_path"] = file_to_original.file.path
|
||||
audit_data["script-original"] = script_original
|
||||
userkey= decryptionOfPrivate(blockchain_obj.privateKey)
|
||||
print("userkey = ", str(userkey))
|
||||
print("blockchain_obj.publicKey",blockchain_obj.publicKey)
|
||||
print("blockchain_obj.privateKey",blockchain_obj.privateKey)
|
||||
if status.status == "SUCCESS":
|
||||
|
||||
if script_ext == "fdx":
|
||||
|
||||
file_to_audit = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-csv"
|
||||
)
|
||||
hash2 = ""
|
||||
hash2_docx = ""
|
||||
try:
|
||||
file_to_audit_docx = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-docx"
|
||||
)
|
||||
script_docx = {}
|
||||
script_path1 = file_to_audit_docx.file.path
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
audit_data["script-docx"] = script_docx
|
||||
except:
|
||||
csv_script_path = file_to_audit.file.path
|
||||
df = pd.read_csv(csv_script_path)
|
||||
docx = utilities.csv_to_docx(df)
|
||||
|
||||
temp_file_stream = BytesIO()
|
||||
docx.save(temp_file_stream)
|
||||
temp_file_stream.seek(0)
|
||||
|
||||
docx_file = ContentFile(
|
||||
temp_file_stream.getvalue(),
|
||||
"from_audited_csv_to_document.docx",
|
||||
)
|
||||
|
||||
query_file = File.objects.create(
|
||||
script= file_to_audit.script,
|
||||
file=docx_file,
|
||||
type="script-docx",
|
||||
)
|
||||
file_to_audit_docx = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-docx"
|
||||
)
|
||||
script_docx = {}
|
||||
script_path1 = file_to_audit_docx.file.path
|
||||
script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
audit_data["script-docx"] = script_docx
|
||||
|
||||
## code for pdf also
|
||||
try:
|
||||
temp_dir = tempfile.TemporaryDirectory()
|
||||
pdf_file_path = utilities.docx_to_pdf(
|
||||
script_path1, temp_dir.name)
|
||||
|
||||
with open(pdf_file_path, "rb") as temp_pdf:
|
||||
|
||||
pdf_file = DjangoFile(temp_pdf,pdf_file_path.rsplit('/', 1)[1],)
|
||||
|
||||
query_file = File.objects.create(
|
||||
script = file_to_audit.script,
|
||||
file = pdf_file,
|
||||
type="script-pdf",
|
||||
)
|
||||
script_pdf = {}
|
||||
script_path1 = pdf_file_path
|
||||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
script_pdf["script_file_path"] = script_path1
|
||||
script_pdf["script_file"] = hash2
|
||||
script_pdf["type"] = "script-pdf"
|
||||
audit_data["script-pdf"] = script_pdf
|
||||
except:
|
||||
pass
|
||||
# convert csv to json and store JSON
|
||||
try:
|
||||
csv_script_path = file_to_audit.file.path
|
||||
print("csv_path fetched",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))
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
print("Temporary directory created:", temp_dir)
|
||||
temp_filename = os.path.join(temp_dir, 'script_json_file.json')
|
||||
print("temp file name ----------------?>",temp_filename)
|
||||
with open(temp_filename, 'w') as json_file:
|
||||
json.dump(script_json, json_file, indent=4)
|
||||
script_json = {}
|
||||
script_path1 = temp_filename
|
||||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
script_json["script_file_path"] = script_path1
|
||||
script_json["script_file"] = hash2
|
||||
script_json["type"] = "script-json"
|
||||
audit_data["script-json"] = script_json
|
||||
print("data_uploaded")
|
||||
except Exception as exp:
|
||||
print("###ERROR:",exp)
|
||||
print("######Error from JSON CREATION############")
|
||||
try:
|
||||
script_csv = {}
|
||||
script_path = file_to_audit.file.path
|
||||
print("script_file_path_is_here",script_path)
|
||||
with open(script_path, 'rb') as _file:
|
||||
hash1 = uploadDataToIPFSNode(_file)
|
||||
script_csv["script_file"] = hash1
|
||||
script_csv["script_file_path"] = script_path
|
||||
script_csv["type"] = "script-csv"
|
||||
audit_data["script-csv"]= script_csv
|
||||
except Exception as exp:
|
||||
print(exp)
|
||||
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()
|
||||
to_email = [user.email]
|
||||
print("####### #### to_email",to_email)
|
||||
key_value_aud = { "script_name" : str(screenplay_name) }
|
||||
email_code = 'SB1'
|
||||
sendmail(to_email=to_email , email_code=email_code, key_value = key_value_aud )
|
||||
print("$$$$### after sendmail")
|
||||
# user_infos = user_info(tx_hash=Response,service="Script Audit",gas_fee=gasprice)
|
||||
# addition_result = user_infos.update_info(request)
|
||||
hash2_docx = hash_decrypation(hash2_docx)
|
||||
tx_id = Response
|
||||
certificate = certificateGenrate(user.username,"script audit",tx_id,projectname=script_file_name,matic=gasprice)
|
||||
to_email = [user.email]
|
||||
email_code = 'BL1'
|
||||
key_value = {
|
||||
"service":"Audited Script",
|
||||
"hash": hash2_docx,
|
||||
"public key":blockchain_obj.publicKey,
|
||||
"Transaction Hash": tx_id,
|
||||
audit_parameters = {
|
||||
"service_type" : "audit",
|
||||
"user":user,
|
||||
"s3-file-path": local_file_path,
|
||||
"screenplay_name": screenplay_name,
|
||||
"author": author,
|
||||
"language": language,
|
||||
"script_ext": script_ext,
|
||||
"script_file_name": script_file_name
|
||||
}
|
||||
print("userkey = ", userkey)
|
||||
sendmail(to_email=to_email , email_code=email_code, key_value=key_value, filePath=certificate)
|
||||
print("mail send sucessfully:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
|
||||
data = {"message": "Success"}
|
||||
|
||||
else:
|
||||
|
||||
file_to_audit = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-csv"
|
||||
)
|
||||
file_to_audit_report = File.objects.get(
|
||||
script=script_id,
|
||||
type="audit-report"
|
||||
)
|
||||
hash2 = ""
|
||||
hash2_docx = ""
|
||||
try:
|
||||
file_to_audit_docx = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-docx"
|
||||
)
|
||||
script_docx = {}
|
||||
script_path1 = file_to_audit_docx.file.path
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
audit_data["script-docx"] = script_docx
|
||||
except:
|
||||
csv_script_path = file_to_audit.file.path
|
||||
df = pd.read_csv(csv_script_path)
|
||||
docx = utilities.csv_to_docx(df)
|
||||
|
||||
temp_file_stream = BytesIO()
|
||||
docx.save(temp_file_stream)
|
||||
temp_file_stream.seek(0)
|
||||
|
||||
docx_file = ContentFile(
|
||||
temp_file_stream.getvalue(),
|
||||
"from_audited_csv_to_document.docx",
|
||||
)
|
||||
|
||||
query_file = File.objects.create(
|
||||
script= file_to_audit.script,
|
||||
file=docx_file,
|
||||
type="script-docx",
|
||||
)
|
||||
file_to_audit_docx = File.objects.get(
|
||||
script=script_id,
|
||||
type="script-docx"
|
||||
)
|
||||
script_docx = {}
|
||||
script_path1 = file_to_audit_docx.file.path
|
||||
script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2_docx = uploadDataToIPFSNode(_file)
|
||||
script_docx["script_file_path"] = script_path1
|
||||
script_docx["script_file"] = hash2_docx
|
||||
script_docx["type"] = "script-docx"
|
||||
audit_data["script-docx"] = script_docx
|
||||
|
||||
## code for pdf also
|
||||
try:
|
||||
temp_dir = tempfile.TemporaryDirectory()
|
||||
pdf_file_path = utilities.docx_to_pdf(
|
||||
script_path1, temp_dir.name)
|
||||
|
||||
with open(pdf_file_path, "rb") as temp_pdf:
|
||||
|
||||
pdf_file = DjangoFile(temp_pdf,pdf_file_path.rsplit('/', 1)[1],)
|
||||
|
||||
query_file = File.objects.create(
|
||||
script = file_to_audit.script,
|
||||
file = pdf_file,
|
||||
type="script-pdf",
|
||||
)
|
||||
script_pdf = {}
|
||||
script_path1 = pdf_file_path
|
||||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
script_pdf["script_file_path"] = script_path1
|
||||
script_pdf["script_file"] = hash2
|
||||
script_pdf["type"] = "script-pdf"
|
||||
audit_data["script-pdf"] = script_pdf
|
||||
except:
|
||||
pass
|
||||
# convert csv to json and store JSON
|
||||
try:
|
||||
csv_script_path = file_to_audit.file.path
|
||||
df = pd.read_csv(csv_script_path)
|
||||
df = df.loc[:, ["content", "script_element"]]
|
||||
script_json: dict = json.loads(utilities.csv_to_json(df))
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
print("Temporary directory created:", temp_dir)
|
||||
temp_filename = os.path.join(temp_dir, 'script_json_file.json')
|
||||
print("temp file name ----------------?>",temp_filename)
|
||||
with open(temp_filename, 'w') as json_file:
|
||||
json.dump(script_json, json_file, indent=4)
|
||||
script_json = {}
|
||||
script_path1 = temp_filename
|
||||
# script_size = file_to_audit_docx.file.size
|
||||
with open(script_path1, 'rb') as _file:
|
||||
hash2 = uploadDataToIPFSNode(_file)
|
||||
script_json["script_file_path"] = script_path1
|
||||
script_json["script_file"] = hash2
|
||||
script_json["type"] = "script-json"
|
||||
audit_data["script-json"] = script_json
|
||||
print("data_uploaded")
|
||||
except Exception as exp:
|
||||
print("###ERROR:",exp)
|
||||
print("######Error from JSON CREATION############")
|
||||
pass
|
||||
|
||||
script_csv = {}
|
||||
audit_report ={}
|
||||
audit_report_path = file_to_audit_report.file.path
|
||||
script_path = file_to_audit.file.path
|
||||
script_size = file_to_audit.file.size
|
||||
|
||||
print("script_file_path_is_here",script_path)
|
||||
with open(script_path, 'rb') as _file:
|
||||
hash1 = uploadDataToIPFSNode(_file)
|
||||
script_csv["script_file"] = hash1
|
||||
script_csv["script_file_path"] = script_path
|
||||
script_csv["type"] = "script-csv"
|
||||
with open(audit_report_path, 'rb') as file1:
|
||||
hash2 = uploadDataToIPFSNode(file1)
|
||||
audit_report["script_file"] = hash2
|
||||
audit_report["script_file_path"] = audit_report_path
|
||||
audit_report["type"] = "audit-report"
|
||||
audit_data["script-csv"]= script_csv
|
||||
audit_data["audit-report"]= audit_report
|
||||
|
||||
|
||||
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()
|
||||
|
||||
to_email = [user.email]
|
||||
email_code = 'SB1'
|
||||
key_value_aud = { "script_name" : str(screenplay_name)}
|
||||
sendmail(to_email=to_email , email_code=email_code, key_value = key_value_aud)
|
||||
|
||||
# user_infos = user_info(tx_hash=Response,service="Script Audit",gas_fee=gasprice)
|
||||
# addition_result = user_infos.update_info(request)
|
||||
hash2_docx = hash_decrypation(hash2_docx)
|
||||
tx_id = Response
|
||||
certificate = certificateGenrate(user.username,"script audit",tx_id,projectname=script_file_name,matic=gasprice)
|
||||
to_email = [user.email]
|
||||
email_code = 'BL1'
|
||||
key_value = {
|
||||
"service":"Audited Script",
|
||||
"hash": hash2_docx,
|
||||
"public key":blockchain_obj.publicKey,
|
||||
"Transaction Hash": tx_id,
|
||||
}
|
||||
print("userkey = ", userkey)
|
||||
sendmail(to_email=to_email , email_code=email_code, key_value=key_value, filePath=certificate)
|
||||
print("mail send sucessfully:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
|
||||
data = {"message": "Success"}
|
||||
# deleting the folder and files
|
||||
|
||||
# Delete a file
|
||||
media_path = os.path.join(settings.MEDIA_ROOT, "audit_counter_files", script_file_name)
|
||||
if os.path.exists(media_path):
|
||||
os.remove(media_path)
|
||||
print(f"File '{media_path}' deleted successfully.")
|
||||
else:
|
||||
print(f"File '{media_path}' does not exist.")
|
||||
|
||||
# Delete a folder and its contents
|
||||
folder1_path = os.path.join(settings.MEDIA_ROOT, "scripts_folder", script_id)
|
||||
if os.path.exists(folder1_path):
|
||||
shutil.rmtree(folder1_path)
|
||||
print(f"Folder '{folder1_path}' and its contents deleted successfully.")
|
||||
else:
|
||||
print(f"Folder '{folder1_path}' does not exist.")
|
||||
|
||||
folder2_path = os.path.join(settings.MEDIA_ROOT, "audit_folder", script_id)
|
||||
if os.path.exists(folder2_path):
|
||||
shutil.rmtree(folder2_path)
|
||||
print(f"Folder '{folder2_path}' and its contents deleted successfully.")
|
||||
else:
|
||||
print(f"Folder '{folder2_path}' does not exist.")
|
||||
return JsonResponse(data, status=200)
|
||||
# return Response("Success", status=200)
|
||||
|
||||
|
||||
else:
|
||||
|
||||
to_email = [user.email]
|
||||
email_code = 'SB2'
|
||||
key_value_aud = { "script_name" : str(screenplay_name)}
|
||||
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("tx_hash",Response)
|
||||
hash = hash_decrypation(hash)
|
||||
#certificate = certificateGenrate(request.user.username,"script audit",hash)
|
||||
tx_id = Response
|
||||
|
||||
# certificate = certificateGenrate(request.user.username,"script audit",tx_id,projectname=script_file_name,matic=gasprice)
|
||||
|
||||
to_email = [user.email]
|
||||
email_code = 'BL1'
|
||||
key_value = {
|
||||
"service":"Orginal Script Audit",
|
||||
"hash": hash,
|
||||
"public key":blockchain_obj.publicKey,
|
||||
"private key":userkey,
|
||||
"Transaction Hash": tx_id,
|
||||
}
|
||||
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("::::::::::::::",key_value)
|
||||
print("userkey = ", userkey)
|
||||
|
||||
|
||||
run_audit_in_counter(audit_parameters)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class ScriptAuditModelAdmin(admin.ModelAdmin):
|
|||
list_display = (
|
||||
"script",
|
||||
"status",
|
||||
"pre_audit_run",
|
||||
"results",
|
||||
"last_call",
|
||||
"celery_id",
|
||||
"error_msg",
|
||||
)
|
||||
|
|
|
@ -2,39 +2,27 @@ import os
|
|||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
# import time
|
||||
import datetime
|
||||
# from utils import filesystem,utilities
|
||||
import pandas as pd
|
||||
from django.core.files.base import ContentFile
|
||||
import time
|
||||
# from users.models import UserCredentialsForBlockchain
|
||||
# from utils.scripts_functions import countPages
|
||||
# import page_script.models as ps_models
|
||||
# from mnfapp.views import update_juggernaut
|
||||
from centralisedFileSystem.models import File, Script, ScreenPlay
|
||||
# from utils import filesystem
|
||||
# from conversion.translation.detection import script_det, language_detector
|
||||
# from conversion.translation.translation_variables import get_language_script_code, language_code
|
||||
# from page_script.views import _file_path
|
||||
# from page_script import views as page_script
|
||||
from scriptAudit import sa_functions as sf
|
||||
from scriptAudit import sa_functions_english as sf_eng
|
||||
from scriptAudit.models import ScriptAuditModel, States
|
||||
# from mnfapp.views import update_juggernaut
|
||||
from io import BytesIO
|
||||
import datetime
|
||||
import pytz
|
||||
import subprocess
|
||||
|
||||
#from django_q.tasks import async_task
|
||||
# from django_q.tasks import async_task
|
||||
# from django_q.brokers import Broker
|
||||
|
||||
class NeutralAudit:
|
||||
def __init__(
|
||||
self,
|
||||
script_id: str = None,
|
||||
log: bool = False,
|
||||
log: bool = True,
|
||||
) -> None:
|
||||
"""
|
||||
To Audit a Script already uploded.
|
||||
|
@ -2712,7 +2700,7 @@ class NeutralAudit:
|
|||
return character_scripts_dict
|
||||
|
||||
def audit_in_background(self):
|
||||
# # commenting os.fork to make code run in foreground
|
||||
|
||||
# if os.fork() != 0:
|
||||
# return
|
||||
|
||||
|
@ -2736,76 +2724,10 @@ class NeutralAudit:
|
|||
except Exception as exp:
|
||||
self.audit_model_obj.status = States.FAILURE
|
||||
self.audit_model_obj.results = exp
|
||||
self.audit_model_obj.error_msg = "FAILED"
|
||||
self.audit_model_obj.save()
|
||||
print(end_time)
|
||||
|
||||
# def _audit(self):
|
||||
# try:
|
||||
# extension = self.input_script.rsplit(".", 1)[-1]
|
||||
# if extension == 'fdx':
|
||||
# self.audit_fdx()
|
||||
# else:
|
||||
# self.audit()
|
||||
# self.audit_model_obj.status = States.SUCCESS
|
||||
# self.audit_model_obj.save()
|
||||
# print("Audit Success!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
# with open(self.base_file_path + "time_taken.txt", "a") as file007:
|
||||
# file007.write("\n\n****AUDITING IS SUCCESSFUL****\n")
|
||||
# except Exception as exp:
|
||||
# self.audit_model_obj.status = States.FAILURE
|
||||
# self.audit_model_obj.results = exp
|
||||
# self.audit_model_obj.save()
|
||||
|
||||
# def audit_in_background(self):
|
||||
# print("Running in background")
|
||||
# async_task(self._audit)
|
||||
|
||||
|
||||
# def audit_in_background(self):
|
||||
# print("Running in background")
|
||||
# async_task(self._audit)
|
||||
# print("Task enqueued successfully")
|
||||
|
||||
# def _audit(self):
|
||||
# try:
|
||||
# extension = self.input_script.rsplit(".", 1)[-1]
|
||||
# if extension == 'fdx':
|
||||
# self.audit_fdx()
|
||||
# else:
|
||||
# self.audit()
|
||||
# self.audit_model_obj.status = States.SUCCESS
|
||||
# self.audit_model_obj.save()
|
||||
# print("Audit Success!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
# with open(self.base_file_path + "time_taken.txt", "a") as file007:
|
||||
# file007.write("\n\n****AUDITING IS SUCCESSFUL****\n")
|
||||
# except Exception as exp:
|
||||
# self.audit_model_obj.status = States.FAILURE
|
||||
# self.audit_model_obj.results = exp
|
||||
# self.audit_model_obj.save()
|
||||
# print("Audit Failed:", exp)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
naudit = NeutralAudit("123", True)
|
||||
## audit run
|
||||
# naudit.__call__()
|
||||
|
||||
## character subset check
|
||||
# character_list = []
|
||||
# character_list = naudit.get_character_list()
|
||||
|
||||
# try:
|
||||
# print("characters of script are",character_list)
|
||||
# except:
|
||||
# pass
|
||||
|
||||
# naudit.quick_audit()
|
||||
|
||||
naudit.get_character_subset()
|
||||
|
|
|
@ -62,3 +62,4 @@ class ScriptAuditModel(models.Model):
|
|||
bchain_privatekey = models.CharField(max_length=200, blank=False, null=True)
|
||||
isfdx = models.BooleanField(default=False)
|
||||
only_audit = models.BooleanField(null=True, blank=True)
|
||||
error_msg = models.TimeField(null=True,blank=True)
|
|
@ -3,24 +3,16 @@ from scriptAudit import views
|
|||
from django.views.generic import TemplateView
|
||||
|
||||
urlpatterns = [
|
||||
path("home", views.AuditHomeView.as_view(), name="upload_audit"),
|
||||
# path("home", views.AuditHomeView.as_view(), name="upload_audit"),#fetch from backup
|
||||
path("counter_run", views.Get_Counter.as_view(), name="counter_run"),
|
||||
path("fetch_in_counter", views.Fetch_in_Counter.as_view(), name="fetch_in_counter"),
|
||||
path("facade", views.AuditFacadeView.as_view(), name="upload_audit_facade"),
|
||||
path("facade/status_update", views.AuditStatusUpdate.as_view(), name="audit_facade_status_update"),
|
||||
path("facade/file_update", views.AuditedFileUpdate.as_view(), name="audit_facade_file_update"),
|
||||
path("facade/report_update", views.AuditedReportUpdate.as_view(), name="audit_facade_report_update"),
|
||||
# path("audited", views.AuditedScriptsView.as_view(), name="my_audited_scripts"),
|
||||
path("audits", views.AuditedScriptsView_kunal.as_view(), name="new_audited_page"), #new audited page
|
||||
path("audits1", views.AuditedScriptsView_kunal1.as_view(), name="new_audited_page1"), #new audited page
|
||||
# path("audit/<str:script_id>", views.AuditView.as_view()),
|
||||
# path("charlst/<str:script_id>", views.CharacterListView.as_view()),
|
||||
# path("fetch_in_counter", views.Fetch_in_Counter.as_view(), name="fetch_in_counter"),
|
||||
path("audit-blockchain_", views.AuditedScriptsView_Without_blockchain.as_view(), name="new_audited_page"), #new audited page
|
||||
path("audits1", views.AuditedScriptsView_With_Blockchain.as_view(), name="new_audited_page1"), #new audited page
|
||||
path("download",views.DownloadScript.as_view()),
|
||||
path("checkdomain",views.CheckDomain.as_view()),
|
||||
path("delete_scripts/<str:screen_play>", views.DeleteScriptAPIView.as_view(),name="delete_script"),
|
||||
path("processing", TemplateView.as_view(template_name="audit/audit_processing.html"), name="audit_processing_page"),
|
||||
path("audit_tutorial",TemplateView.as_view(template_name = "audit/audit_tutorial.html"),name="audit_tutorial"),
|
||||
path("scriptAuditDemo", TemplateView.as_view(template_name = "audit/audit_demo.html"), name="scriptAuditDemo"),
|
||||
path("downloadScriptFromBlockchain",views.DownloadScriptFromBlockchain.as_view()),
|
||||
|
||||
]
|
||||
# path('view/',login_required(ViewSpaceIndex.as_view(..)),
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue