Skip to content

Commit 92a280b

Browse files
committed
Update latest master py script with more output
1 parent 41c0626 commit 92a280b

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

master_openworm.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import math
1313

1414
print("*****************************")
15-
print("OpenWorm Master Script v0.9.2")
15+
print("OpenWorm Master Script v0.9.3")
1616
print("*****************************")
1717
print("")
1818
print("This script attempts to run a full pass through the OpenWorm scientific libraries.")
@@ -79,25 +79,29 @@ def execute_with_realtime_output(command, directory, env=None):
7979

8080
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
8181
print('>> Executing command: %s'%command)
82-
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
82+
print('>> --------------------------------------------------------------')
8383
p = Popen(shlex.split(command),
8484
stdout=PIPE,
8585
stderr=STDOUT,
8686
cwd=directory,
8787
env=env)
8888
with p.stdout:
8989
for line in iter(p.stdout.readline, b''):
90-
print('>> %s'%line.decode('utf-8'), end='')
90+
print('>> %s'%line.decode('utf-8'), end='')
9191
p.wait() # wait for the subprocess to exit
9292
except KeyboardInterrupt as e:
9393
print("Caught CTRL+C")
9494
if p:
9595
p.kill()
9696
raise e
97-
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
97+
print('>> --------------------------------------------------------------')
9898
print('>> Command exited with %i: %s'%(p.returncode,command))
9999
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n')
100100

101+
if p.returncode!=0:
102+
print('Exiting as the last command failed')
103+
exit(p.returncode)
104+
101105

102106

103107
sys.path.append(os.environ['C302_HOME'])
@@ -142,6 +146,8 @@ def execute_with_realtime_output(command, directory, env=None):
142146
my_env = os.environ.copy()
143147
my_env["DISPLAY"] = ":44"
144148

149+
# Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol.
150+
# In contrast to other display servers, Xvfb performs all graphical operations in virtual memory without showing any screen output.
145151
os.system('Xvfb :44 -listen tcp -ac -screen 0 1920x1080x24+32 &') # TODO: terminate xvfb after recording
146152

147153
try:
@@ -223,18 +229,21 @@ def execute_with_realtime_output(command, directory, env=None):
223229

224230
time.sleep(2)
225231

226-
227-
228232
# Rerun and record simulation
229233
os.system('export DISPLAY=:44')
230234
sibernetic_movie_name = '%s.mp4' % os.path.split(latest_subdir)[-1]
231-
os.system('tmux new-session -d -s SiberneticRecording "DISPLAY=:44 ffmpeg -r 30 -f x11grab -draw_mouse 0 -s 1920x1080 -i :44 -filter:v "crop=1200:800:100:100" -cpu-used 0 -b:v 384k -qmin 10 -qmax 42 -maxrate 384k -bufsize 1000k -an %s/%s"' % (new_sim_out, sibernetic_movie_name))
235+
command = 'tmux new-session -d -s SiberneticRecording "DISPLAY=:44 ffmpeg -r 30 -f x11grab -draw_mouse 0 -s 1920x1080 -i :44 -filter:v "crop=1200:800:100:100" -cpu-used 0 -b:v 384k -qmin 10 -qmax 42 -maxrate 384k -bufsize 1000k -an %s/%s"' % (new_sim_out, sibernetic_movie_name)
236+
execute_with_realtime_output(command, os.environ['SIBERNETIC_HOME'], env=my_env)
237+
238+
time.sleep(3)
239+
240+
execute_with_realtime_output('tmux list-sessions', os.environ['SIBERNETIC_HOME'], env=my_env)
232241

233242
command = './Release/Sibernetic -f %s -l_from lpath=%s' % (DEFAULTS['configuration'], latest_subdir)
234243
execute_with_realtime_output(command, os.environ['SIBERNETIC_HOME'], env=my_env)
235244

236-
os.system('tmux send-keys -t SiberneticRecording q')
237-
os.system('tmux send-keys -t SiberneticRecording "exit" C-m')
245+
execute_with_realtime_output('tmux send-keys -t SiberneticRecording q', os.environ['SIBERNETIC_HOME'], env=my_env)
246+
execute_with_realtime_output('tmux send-keys -t SiberneticRecording "exit" C-m', os.environ['SIBERNETIC_HOME'], env=my_env)
238247

239248
time.sleep(5)
240249

0 commit comments

Comments
 (0)