pravesh changes ffrom File
This commit is contained in:
parent
5c2e940a9d
commit
0eebab5185
|
@ -258,19 +258,25 @@ def run_audit_in_counter(msg):
|
||||||
audit_data={}
|
audit_data={}
|
||||||
script_original["status"] = "STARTED"
|
script_original["status"] = "STARTED"
|
||||||
script_original["script_id"] = script_id
|
script_original["script_id"] = script_id
|
||||||
with open(file_to_original.file.path, 'rb') as file:
|
if file_to_original and file_to_original.file and hasattr(file_to_original.file, 'path') and file_to_original.file.path:
|
||||||
hash = uploadDataToIPFSNode(file)
|
with open(file_to_original.file.path, 'rb') as file:
|
||||||
django_file = File2(file)
|
hash = uploadDataToIPFSNode(file)
|
||||||
filename = os.path.basename(file_to_original.file.path)
|
filename = os.path.basename(file_to_original.file.path)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
file = ContentFile(
|
||||||
project_id= script_id,
|
file.read(),
|
||||||
file_type="script-original",
|
filename,
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
script_original["script_file"] = hash
|
project_id= script_id,
|
||||||
script_original["type"] = "script-original"
|
file_type="script-original",
|
||||||
script_original["script_file_path"] = file_to_original.file.path
|
)
|
||||||
audit_data["script-original"] = script_original
|
script_original["script_file"] = hash
|
||||||
|
files.public_file.save(filename, file, save=True)
|
||||||
|
script_original["type"] = "script-original"
|
||||||
|
script_original["script_file_path"] = file_to_original.file.path
|
||||||
|
audit_data["script-original"] = script_original
|
||||||
|
else:
|
||||||
|
print("Original file is missing or has no valid path.")
|
||||||
userkey= decryptionOfPrivate(blockchain_obj.privateKey)
|
userkey= decryptionOfPrivate(blockchain_obj.privateKey)
|
||||||
print("userkey = ", str(userkey))
|
print("userkey = ", str(userkey))
|
||||||
print("blockchain_obj.publicKey",blockchain_obj.publicKey)
|
print("blockchain_obj.publicKey",blockchain_obj.publicKey)
|
||||||
|
@ -294,13 +300,16 @@ def run_audit_in_counter(msg):
|
||||||
script_path1 = file_to_audit_docx.file.path
|
script_path1 = file_to_audit_docx.file.path
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2_docx = uploadDataToIPFSNode(_file)
|
hash2_docx = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-docx",
|
file_type="script-docx",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_docx["script_file_path"] = script_path1
|
script_docx["script_file_path"] = script_path1
|
||||||
script_docx["script_file"] = hash2_docx
|
script_docx["script_file"] = hash2_docx
|
||||||
script_docx["type"] = "script-docx"
|
script_docx["type"] = "script-docx"
|
||||||
|
@ -333,13 +342,16 @@ def run_audit_in_counter(msg):
|
||||||
script_size = file_to_audit_docx.file.size
|
script_size = file_to_audit_docx.file.size
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2_docx = uploadDataToIPFSNode(_file)
|
hash2_docx = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-docx",
|
file_type="script-docx",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_docx["script_file_path"] = script_path1
|
script_docx["script_file_path"] = script_path1
|
||||||
script_docx["script_file"] = hash2_docx
|
script_docx["script_file"] = hash2_docx
|
||||||
script_docx["type"] = "script-docx"
|
script_docx["type"] = "script-docx"
|
||||||
|
@ -365,13 +377,16 @@ def run_audit_in_counter(msg):
|
||||||
# script_size = file_to_audit_docx.file.size
|
# script_size = file_to_audit_docx.file.size
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2 = uploadDataToIPFSNode(_file)
|
hash2 = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-pdf",
|
file_type="script-pdf",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_pdf["script_file_path"] = script_path1
|
script_pdf["script_file_path"] = script_path1
|
||||||
script_pdf["script_file"] = hash2
|
script_pdf["script_file"] = hash2
|
||||||
script_pdf["type"] = "script-pdf"
|
script_pdf["type"] = "script-pdf"
|
||||||
|
@ -396,13 +411,16 @@ def run_audit_in_counter(msg):
|
||||||
# script_size = file_to_audit_docx.file.size
|
# script_size = file_to_audit_docx.file.size
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2 = uploadDataToIPFSNode(_file)
|
hash2 = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-json",
|
file_type="script-json",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_json["script_file_path"] = script_path1
|
script_json["script_file_path"] = script_path1
|
||||||
script_json["script_file"] = hash2
|
script_json["script_file"] = hash2
|
||||||
script_json["type"] = "script-json"
|
script_json["type"] = "script-json"
|
||||||
|
@ -418,13 +436,16 @@ def run_audit_in_counter(msg):
|
||||||
print("script_file_path_is_here",script_path)
|
print("script_file_path_is_here",script_path)
|
||||||
with open(script_path, 'rb') as _file:
|
with open(script_path, 'rb') as _file:
|
||||||
hash1 = uploadDataToIPFSNode(_file)
|
hash1 = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path)
|
filename = os.path.basename(script_path)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-csv",
|
file_type="script-csv",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_csv["script_file"] = hash1
|
script_csv["script_file"] = hash1
|
||||||
script_csv["script_file_path"] = script_path
|
script_csv["script_file_path"] = script_path
|
||||||
script_csv["type"] = "script-csv"
|
script_csv["type"] = "script-csv"
|
||||||
|
@ -502,13 +523,16 @@ def run_audit_in_counter(msg):
|
||||||
script_path1 = file_to_audit_docx.file.path
|
script_path1 = file_to_audit_docx.file.path
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2_docx = uploadDataToIPFSNode(_file)
|
hash2_docx = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-docx",
|
file_type="script-docx",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_docx["script_file_path"] = script_path1
|
script_docx["script_file_path"] = script_path1
|
||||||
script_docx["script_file"] = hash2_docx
|
script_docx["script_file"] = hash2_docx
|
||||||
script_docx["type"] = "script-docx"
|
script_docx["type"] = "script-docx"
|
||||||
|
@ -541,13 +565,16 @@ def run_audit_in_counter(msg):
|
||||||
script_size = file_to_audit_docx.file.size
|
script_size = file_to_audit_docx.file.size
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2_docx = uploadDataToIPFSNode(_file)
|
hash2_docx = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-docx",
|
file_type="script-docx",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_docx["script_file_path"] = script_path1
|
script_docx["script_file_path"] = script_path1
|
||||||
script_docx["script_file"] = hash2_docx
|
script_docx["script_file"] = hash2_docx
|
||||||
script_docx["type"] = "script-docx"
|
script_docx["type"] = "script-docx"
|
||||||
|
@ -573,13 +600,16 @@ def run_audit_in_counter(msg):
|
||||||
# script_size = file_to_audit_docx.file.size
|
# script_size = file_to_audit_docx.file.size
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2 = uploadDataToIPFSNode(_file)
|
hash2 = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-pdf",
|
file_type="script-pdf",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_pdf["script_file_path"] = script_path1
|
script_pdf["script_file_path"] = script_path1
|
||||||
script_pdf["script_file"] = hash2
|
script_pdf["script_file"] = hash2
|
||||||
script_pdf["type"] = "script-pdf"
|
script_pdf["type"] = "script-pdf"
|
||||||
|
@ -603,13 +633,16 @@ def run_audit_in_counter(msg):
|
||||||
# script_size = file_to_audit_docx.file.size
|
# script_size = file_to_audit_docx.file.size
|
||||||
with open(script_path1, 'rb') as _file:
|
with open(script_path1, 'rb') as _file:
|
||||||
hash2 = uploadDataToIPFSNode(_file)
|
hash2 = uploadDataToIPFSNode(_file)
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path1)
|
filename = os.path.basename(script_path1)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-json",
|
file_type="script-json",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_json["script_file_path"] = script_path1
|
script_json["script_file_path"] = script_path1
|
||||||
script_json["script_file"] = hash2
|
script_json["script_file"] = hash2
|
||||||
script_json["type"] = "script-json"
|
script_json["type"] = "script-json"
|
||||||
|
@ -631,13 +664,16 @@ def run_audit_in_counter(msg):
|
||||||
with open(script_path, 'rb') as _file:
|
with open(script_path, 'rb') as _file:
|
||||||
hash1 = uploadDataToIPFSNode(_file)
|
hash1 = uploadDataToIPFSNode(_file)
|
||||||
script_csv["script_file"] = hash1
|
script_csv["script_file"] = hash1
|
||||||
django_file = File2(_file)
|
|
||||||
filename = os.path.basename(script_path)
|
filename = os.path.basename(script_path)
|
||||||
|
django_file = ContentFile(
|
||||||
|
_file.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="script-csv",
|
file_type="script-csv",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
script_csv["script_file_path"] = script_path
|
script_csv["script_file_path"] = script_path
|
||||||
script_csv["type"] = "script-csv"
|
script_csv["type"] = "script-csv"
|
||||||
|
|
||||||
|
@ -645,13 +681,16 @@ def run_audit_in_counter(msg):
|
||||||
audit_report_path = file_to_audit_report.file.path
|
audit_report_path = file_to_audit_report.file.path
|
||||||
with open(audit_report_path, 'rb') as file1:
|
with open(audit_report_path, 'rb') as file1:
|
||||||
hash2 = uploadDataToIPFSNode(file1)
|
hash2 = uploadDataToIPFSNode(file1)
|
||||||
django_file = File2(file1)
|
|
||||||
filename = os.path.basename(audit_report_path)
|
filename = os.path.basename(audit_report_path)
|
||||||
|
django_file = ContentFile(
|
||||||
|
file1.read(),
|
||||||
|
filename,
|
||||||
|
)
|
||||||
files, _ = MNFServersFile.objects.get_or_create(
|
files, _ = MNFServersFile.objects.get_or_create(
|
||||||
project_id= script_id,
|
project_id= script_id,
|
||||||
file_type="audit-report",
|
file_type="audit-report",
|
||||||
)
|
)
|
||||||
files.public_file.save(filename, django_file)
|
files.public_file.save(filename, django_file, save=True)
|
||||||
audit_report["script_file"] = hash2
|
audit_report["script_file"] = hash2
|
||||||
audit_report["script_file_path"] = audit_report_path
|
audit_report["script_file_path"] = audit_report_path
|
||||||
audit_report["type"] = "audit-report"
|
audit_report["type"] = "audit-report"
|
||||||
|
|
Loading…
Reference in New Issue