anisotropy/src/salome_utils.py

60 lines
1.4 KiB
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))
p = subprocess.Popen(["salome", "start", "--port", str(port), "-t"],
2021-03-24 21:27:12 +05:00
#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
def runExecute(port, scriptpath, *args):
logging.info("Starting SALOME on port {}".format(port))
p = subprocess.Popen(["salome", "start", "--shutdown-servers=1", "--port", str(port), "-t", scriptpath, "args:{}".format(", ".join([str(arg) for arg in args]))],
stderr = subprocess.STDOUT)
_, err = p.communicate()
if err:
if p.returncode == 1:
logging.error(err)
else:
logging.warning(err)
return p.returncode
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))
p = subprocess.Popen(["salome", "kill", str(port)],
2021-03-24 21:27:12 +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
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"
p = subprocess.Popen(["salome", "remote", "-p", str(port), "--", str(cmd)],
2021-03-24 21:27:12 +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