Merge pull request 'fix backend' (#14) from add_ШУШ into master
Reviewed-on: https://codeberg.org/NaMe2te/Blog/pulls/14
This commit is contained in:
commit
5a6cd4bbb8
1 changed files with 22 additions and 16 deletions
|
@ -1,8 +1,6 @@
|
||||||
import http.server
|
import http.server
|
||||||
import socketserver
|
import socketserver
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
import pexpect
|
|
||||||
from urllib.parse import urlparse, parse_qs
|
from urllib.parse import urlparse, parse_qs
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
|
@ -13,27 +11,31 @@ class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
query = parse_qs(parsed_path.query)
|
query = parse_qs(parsed_path.query)
|
||||||
print(query)
|
print(query)
|
||||||
|
|
||||||
if 'command' in query and 'args' in query:
|
if "command" in query and "args" in query:
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Content-type', 'text/html')
|
self.send_header("Content-type", "text/html")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(bytes(f"command: {query['command']}, args: {query['args']}", "utf-8"))
|
self.wfile.write(bytes(f"command: {query['command']}, args: {query['args']}", "utf-8"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.send_header('Content-type', 'text/html')
|
self.send_header("Content-type", "text/html")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(bytes("Bad request", "utf-8"))
|
self.wfile.write(bytes("Bad request", "utf-8"))
|
||||||
|
|
||||||
PORT = 2281
|
|
||||||
Handler = MyHttpRequestHandler
|
|
||||||
|
|
||||||
def compile_and_deploy_contract():
|
def compile_and_deploy_contract(
|
||||||
password = 'one'
|
user_path: str,
|
||||||
|
post_path: str,
|
||||||
|
comment_path: str,
|
||||||
|
password: str,
|
||||||
|
) -> dict[str, str]:
|
||||||
|
|
||||||
# User
|
# User
|
||||||
user_compile_command = "neo-go contract compile -i ../User/user.go -c User/user.yml -m User/user.json"
|
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)
|
subprocess.run(user_compile_command, shell=True, check=False)
|
||||||
|
|
||||||
user_deploy_command = "neo-go contract deploy -i ../User/user.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m User/user.json --force"
|
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)
|
proc = subprocess.Popen(user_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
|
|
||||||
user_out_list = []
|
user_out_list = []
|
||||||
|
@ -47,10 +49,10 @@ def compile_and_deploy_contract():
|
||||||
print(user_hash)
|
print(user_hash)
|
||||||
|
|
||||||
# Post
|
# Post
|
||||||
post_compile_command = "neo-go contract compile -i ../Post/post_contract.go -c Post/post_contract.yml -m Post/post_contract.json"
|
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)
|
subprocess.run(post_compile_command, shell=True, check=False)
|
||||||
|
|
||||||
post_deploy_command = "neo-go contract deploy -i ../Post/post_contract.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m Post/post_contract.json --force"
|
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)
|
proc = subprocess.Popen(post_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
|
|
||||||
post_out_list = []
|
post_out_list = []
|
||||||
|
@ -64,10 +66,10 @@ def compile_and_deploy_contract():
|
||||||
print(post_hash)
|
print(post_hash)
|
||||||
|
|
||||||
# Comment
|
# Comment
|
||||||
comment_compile_command = "neo-go contract compile -i ../Comment/comment.go -c Comment/comment.yml -m Comment/comment.json"
|
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)
|
subprocess.run(comment_compile_command, shell=True, check=False)
|
||||||
|
|
||||||
comment_deploy_command = "neo-go contract deploy -i ../Comment/comment.nef -w /home/ftmi-krasotka/Desktop/frostfs_test/frostfs-aio/morph/node-wallet.json -r http://localhost:30333 -m Comment/comment.json --force"
|
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)
|
proc = subprocess.Popen(comment_deploy_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
|
|
||||||
comment_out_list = []
|
comment_out_list = []
|
||||||
|
@ -80,8 +82,12 @@ def compile_and_deploy_contract():
|
||||||
comment_hash = str(comment_out_list[-1]).replace("Contract: ", "")
|
comment_hash = str(comment_out_list[-1]).replace("Contract: ", "")
|
||||||
print(comment_hash)
|
print(comment_hash)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
compile_and_deploy_contract()
|
compile_and_deploy_contract("../User", "../Post", "../Comment", "one")
|
||||||
|
|
||||||
|
PORT = 2281
|
||||||
|
Handler = MyHttpRequestHandler
|
||||||
|
|
||||||
# with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
# with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
||||||
# print("Сервер запущен на порту", PORT)
|
# print("Сервер запущен на порту", PORT)
|
||||||
|
|
Loading…
Reference in a new issue