mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-05-24 01:14:01 +00:00
parent
dc1c14ae92
commit
bb88a1d3f9
@ -84,14 +84,34 @@ class ChatEnv:
|
|||||||
|
|
||||||
success_info = "The software run successfully without errors."
|
success_info = "The software run successfully without errors."
|
||||||
try:
|
try:
|
||||||
command = "cd {}; ls -l; python3 main.py;".format(directory)
|
|
||||||
process = subprocess.Popen(command, shell=True, preexec_fn=os.setsid,
|
# check if we are on windows or linux
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
if os.name == 'nt':
|
||||||
|
command = "cd {} && dir && python main.py".format(directory)
|
||||||
|
process = subprocess.Popen(
|
||||||
|
command,
|
||||||
|
shell=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
command = "cd {}; ls -l; python3 main.py;".format(directory)
|
||||||
|
process = subprocess.Popen(command,
|
||||||
|
shell=True,
|
||||||
|
preexec_fn=os.setsid,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE
|
||||||
|
)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
return_code = process.returncode
|
return_code = process.returncode
|
||||||
# Check if the software is still running
|
# Check if the software is still running
|
||||||
if process.poll() is None:
|
if process.poll() is None:
|
||||||
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
if "killpg" in dir(os):
|
||||||
|
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
||||||
|
else:
|
||||||
|
os.kill(process.pid, signal.SIGTERM)
|
||||||
|
|
||||||
if return_code == 0:
|
if return_code == 0:
|
||||||
return False, success_info
|
return False, success_info
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user