Blog/backend/start.py
2024-01-18 18:17:43 +03:00

76 lines
No EOL
5 KiB
Python

import subprocess
user_path = "../User"
post_path = "../Post"
comment_path = "../Comment"
password = "one"
user_compile_command = f"sshpass -p {password} neo-go contract compile -i {user_path}/user.go -c {user_path}/user.yml -m {user_path}/user.json"
subprocess.run(user_compile_command, shell=True, check=False)
user_deploy_command = f"sshpass -p {password} neo-go contract deploy -i {user_path}/user.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m {user_path}/user.json --force"
proc = subprocess.Popen(user_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
user_out_list = []
while True:
line = proc.stdout.readline()
if not line:
break
user_out_list.append(line.rstrip())
user_hash = str(user_out_list[-1], encoding='utf-8').replace("Contract: ", "")
post_compile_command = f"sshpass -p {password} neo-go contract compile -i {post_path}/post_contract.go -c {post_path}/post_contract.yml -m {post_path}/post_contract.json"
subprocess.run(post_compile_command, shell=True, check=False)
post_deploy_command = f"sshpass -p {password} neo-go contract deploy -i {post_path}/post_contract.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m {post_path}/post_contract.json --force"
proc = subprocess.Popen(post_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
post_out_list = []
while True:
line = proc.stdout.readline()
if not line:
break
post_out_list.append(line.rstrip())
post_hash = str(post_out_list[-1], encoding='utf-8').replace("Contract: ", "")
comment_compile_command = f"sshpass -p {password} neo-go contract compile -i {comment_path}/comment.go -c {comment_path}/comment.yml -m {comment_path}/comment.json"
subprocess.run(comment_compile_command, shell=True, check=False)
comment_deploy_command = f"sshpass -p {password} neo-go contract deploy -i {comment_path}/comment.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m {comment_path}/comment.json --force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
comment_out_list = []
while True:
line = proc.stdout.readline()
if not line:
break
comment_out_list.append(line.rstrip())
comment_hash = str(comment_out_list[-1], encoding='utf-8').replace("Contract: ", "")
print(user_hash, post_hash, comment_hash)
########################################
comment_deploy_command = f"sshpass -p {password} neo-go contract invokefunction -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 {user_hash} newUser hui228336 hui228336 hui228336 1 Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn--force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
comment_deploy_command = f"sshpass -p {password} neo-go contract invokefunction -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 {user_hash} newUser hui1488 hui1488 hui1488 1 Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn--force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
comment_deploy_command = f"sshpass -p {password} neo-go contract invokefunction -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 {post_hash} newPost hui228336 hui hui --force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
comment_deploy_command = f"sshpass -p {password} neo-go contract invokefunction -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 {post_hash} newPost hui228336 hui22 hui22 --force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
comment_deploy_command = f"sshpass -p {password} neo-go contract invokefunction -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 {comment_hash} createNewComment hui228336 post_1 some_text --force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
comment_deploy_command = f"sshpass -p {password} neo-go contract invokefunction -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 {comment_hash} createNewComment hui1488 post_1 some_text --force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
comment_deploy_command = f"sshpass -p {password} neo-go contract invokefunction -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 {comment_hash} createNewComment hui1488 post_1 some_text --force"
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
########################################