anisotropy/src/salome_utils.py

44 lines
962 B
Python
Raw Normal View History

2021-03-24 21:27:12 +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))
2021-03-24 21:27:12 +05:00
p = subprocess.run(["salome", "start", "--port", str(port), "-t"],
#shell = False,
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-24 21:27:12 +05:00
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))
2021-03-24 21:27:12 +05:00
p = subprocess.run(["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-24 21:27:12 +05:00
def remote(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"
2021-03-24 21:27:12 +05:00
p = subprocess.run(["salome", "remote", "-p", str(port), "--", str(cmd)],
#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