anisotropy/src/salome_utils.py

43 lines
964 B
Python
Raw Normal View History

2021-03-18 17:29:30 +05:00
import salome
2021-03-22 15:44:22 +05:00
import subprocess
import logging
2021-03-18 17:29:30 +05:00
def hasDesktop() -> bool:
return salome.sg.hasDesktop()
2021-03-22 22:49:56 +05:00
def startServer(port):
2021-03-19 21:59:30 +05:00
logging.info("Starting SALOME on port {} ...".format(port))
p = subprocess.Popen(["salome", "start", "--port", str(port), "-t"],
2021-03-22 22:49:56 +05:00
shell = False,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
2021-03-19 21:59:30 +05:00
return p
2021-03-22 22:49:56 +05:00
def killServer(port):
2021-03-19 21:59:30 +05:00
logging.info("Terminating SALOME on port {} ...".format(port))
p = subprocess.Popen(["salome", "kill", str(port)],
shell = True,
2021-03-22 22:49:56 +05:00
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
2021-03-19 21:59:30 +05:00
return p
2021-03-22 22:49:56 +05:00
def execute(port, cmd):
2021-03-19 21:59:30 +05:00
logging.info("Executing command in the SALOME on port {} ...".format(port))
2021-03-22 22:49:56 +05:00
# cmd = "python -m"; = "python -c"
p = subprocess.Popen(["salome", "remote", "-p", str(port), "--", str(cmd)],
2021-03-19 21:59:30 +05:00
shell = True,
2021-03-22 22:49:56 +05:00
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
2021-03-19 21:59:30 +05:00
return p