mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-26 15:35:45 +00:00
fix run function utils.py in /palentmint/backend/tarantool
This commit is contained in:
parent
5275747c50
commit
1a050d5f33
@ -2,21 +2,40 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def run(command, path=None):
|
|
||||||
|
|
||||||
|
def run(command,path=None,file_name=None):
|
||||||
|
config = {
|
||||||
|
"login": "admin",
|
||||||
|
"host": "admin:pass@127.0.0.1:3301",
|
||||||
|
"service": "tarantoolctl connect"
|
||||||
|
}
|
||||||
|
if file_name is not None:
|
||||||
|
file = open(file_name, 'r')
|
||||||
|
commands = [line + '\n' for line in file.readlines() if len(str(line)) > 1]
|
||||||
|
file.close()
|
||||||
|
process = subprocess.Popen(command + config["host"],
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
universal_newlines=True,
|
||||||
|
bufsize=0,
|
||||||
|
shell=True)
|
||||||
|
|
||||||
|
for cmd in commands:
|
||||||
|
process.stdin.write(cmd)
|
||||||
|
process.stdin.close()
|
||||||
|
|
||||||
|
for line in process.stdout:
|
||||||
|
print(line)
|
||||||
|
|
||||||
if path is not None:
|
if path is not None:
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
p = subprocess.Popen(
|
process = subprocess.Popen(command,stdin=subprocess.PIPE,
|
||||||
command
|
stdout=subprocess.PIPE,
|
||||||
)
|
universal_newlines=True,
|
||||||
|
bufsize=0,
|
||||||
|
shell=True)
|
||||||
|
output ,error = process.communicate()
|
||||||
|
if process.returncode != 0:
|
||||||
|
print(str(process.returncode) + "\n" + str(output) + "\n" + str(error))
|
||||||
|
|
||||||
# output, error = p.communicate() # TODO Here was problem that we are waiting for outputs
|
|
||||||
# if p.returncode != 0:
|
|
||||||
# print(str(p.returncode) + "\n" + str(output) + "\n" + str(error))
|
|
||||||
else:
|
|
||||||
p = subprocess.Popen(
|
|
||||||
command
|
|
||||||
)
|
|
||||||
|
|
||||||
# output, error = p.communicate()
|
|
||||||
# if p.returncode != 0:
|
|
||||||
# print(str(p.returncode) + "\n" + str(output) + "\n" + str(error))
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user