mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-26 23:45:47 +00:00
fixed output from calling subprocess
This commit is contained in:
parent
8f7256360f
commit
903bec2890
@ -38,6 +38,12 @@ class TarantoolDB:
|
|||||||
logger.info('Exception in _connect(): {}')
|
logger.info('Exception in _connect(): {}')
|
||||||
raise ConfigurationError
|
raise ConfigurationError
|
||||||
|
|
||||||
|
def _file_content_to_bytes(self, path):
|
||||||
|
with open(path, "r") as f:
|
||||||
|
execute = f.readlines()
|
||||||
|
f.close()
|
||||||
|
return "".join(execute).encode()
|
||||||
|
|
||||||
def _reconnect(self):
|
def _reconnect(self):
|
||||||
self.db_connect = tarantool.connect(host=self.host, port=self.port)
|
self.db_connect = tarantool.connect(host=self.host, port=self.port)
|
||||||
|
|
||||||
@ -60,14 +66,14 @@ class TarantoolDB:
|
|||||||
return cmd_resp
|
return cmd_resp
|
||||||
|
|
||||||
def run_command(self, command: str, config: dict):
|
def run_command(self, command: str, config: dict):
|
||||||
from subprocess import Popen, PIPE, run
|
from subprocess import run
|
||||||
print(f" commands: {command}")
|
print(f" commands: {command}")
|
||||||
ret = Popen(
|
host_port = "%s:%s" % (self.host, self.port)
|
||||||
['%s %s:%s < %s' % ("tarantoolctl connect", self.host, self.port, command)],
|
execute_cmd = self._file_content_to_bytes(path=command)
|
||||||
stdin=PIPE,
|
output = run(["tarantoolctl", "connect", host_port],
|
||||||
stdout=PIPE,
|
input=execute_cmd,
|
||||||
universal_newlines=True,
|
capture_output=True).stderr
|
||||||
bufsize=1,
|
output = output.decode()
|
||||||
shell=True).stdout # TODO stdout is not apppearing
|
if "nil value" in output:
|
||||||
print(f"ret ---- {ret.readlines()} ------")
|
raise DatabaseDoesNotExist
|
||||||
return False if "nil value" in ret else True
|
return False if "nil value" in output else True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user