blockchain script json csv
This commit is contained in:
parent
13b31e49aa
commit
0a96bc224a
|
@ -0,0 +1 @@
|
||||||
|
./kitchen_counter/media/
|
|
@ -1,14 +1,17 @@
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
import boto3
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import datetime
|
import datetime
|
||||||
|
import json
|
||||||
|
import tempfile
|
||||||
|
|
||||||
# django
|
# django
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
|
||||||
# all external imports
|
# all external imports
|
||||||
from scriptAudit.models import States
|
from scriptAudit.models import States
|
||||||
from centralisedFileSystem.models import Script
|
from centralisedFileSystem.models import Script, File
|
||||||
from scriptAudit.models import ScriptAuditModel
|
from scriptAudit.models import ScriptAuditModel
|
||||||
from mnfapp.models import MNFScriptDatabase, SampleScript, ScriptTranslations
|
from mnfapp.models import MNFScriptDatabase, SampleScript, ScriptTranslations
|
||||||
from users.models import UserCredentialsForBlockchain,BlockchainUserInfo
|
from users.models import UserCredentialsForBlockchain,BlockchainUserInfo
|
||||||
|
@ -18,7 +21,7 @@ from centralizePayment.views import auto_refund
|
||||||
from juggernaut.views import update_juggernaut
|
from juggernaut.views import update_juggernaut
|
||||||
from auto_email.views import sendmail
|
from auto_email.views import sendmail
|
||||||
from lpp.views import task_assigner
|
from lpp.views import task_assigner
|
||||||
from utils import filesystem
|
from utils import filesystem, utilities
|
||||||
from conversion.translation.newconversion import ScriptTranslation
|
from conversion.translation.newconversion import ScriptTranslation
|
||||||
from scriptAudit.mnf_script_audit import NeutralAudit
|
from scriptAudit.mnf_script_audit import NeutralAudit
|
||||||
from Blockchain2.DataStorage import uploadDataToIPFSNode
|
from Blockchain2.DataStorage import uploadDataToIPFSNode
|
||||||
|
@ -499,8 +502,6 @@ class Conversion:
|
||||||
object_name = "OUTPUT/" + (self.translated_script_object.translated_script_path.split("/"))[-1]
|
object_name = "OUTPUT/" + (self.translated_script_object.translated_script_path.split("/"))[-1]
|
||||||
filee = basePath + self.translated_script_object.translated_script_path
|
filee = basePath + self.translated_script_object.translated_script_path
|
||||||
# Upload the file
|
# Upload the file
|
||||||
import os
|
|
||||||
import boto3
|
|
||||||
bucket = "conversion-kitchen"
|
bucket = "conversion-kitchen"
|
||||||
s3_client = boto3.client('s3',
|
s3_client = boto3.client('s3',
|
||||||
aws_access_key_id="AKIAQVLBBGCB45RMLKVW",
|
aws_access_key_id="AKIAQVLBBGCB45RMLKVW",
|
||||||
|
@ -543,6 +544,37 @@ class Conversion:
|
||||||
scriptconversion["translated_scriptFile_hash"] = hash
|
scriptconversion["translated_scriptFile_hash"] = hash
|
||||||
scriptconversion["translated_scriptFile_path"] = translated_scripttt
|
scriptconversion["translated_scriptFile_path"] = translated_scripttt
|
||||||
print("blockchain script conversion 5")
|
print("blockchain script conversion 5")
|
||||||
|
|
||||||
|
print("audit blockchain")
|
||||||
|
print("blockchain script conversion 5.1")
|
||||||
|
# blockchain upload of csv-json data
|
||||||
|
adit_id = obj.converted_audit_id
|
||||||
|
|
||||||
|
file_to_audit = File.objects.get(
|
||||||
|
script=adit_id,
|
||||||
|
type="script-csv"
|
||||||
|
)
|
||||||
|
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_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"
|
||||||
|
scriptconversion["script-json"] = script_json
|
||||||
|
print("blockchain script conversion 5.2")
|
||||||
|
|
||||||
blockchain_obj = UserCredentialsForBlockchain.objects.get(user=self.user)
|
blockchain_obj = UserCredentialsForBlockchain.objects.get(user=self.user)
|
||||||
UserId = blockchain_obj.user_id
|
UserId = blockchain_obj.user_id
|
||||||
Project = obj.translation_id
|
Project = obj.translation_id
|
||||||
|
|
Loading…
Reference in New Issue