|
12 | 12 | import math
|
13 | 13 |
|
14 | 14 | print("*****************************")
|
15 |
| -print("OpenWorm Master Script v0.9.2") |
| 15 | +print("OpenWorm Master Script v0.9.3") |
16 | 16 | print("*****************************")
|
17 | 17 | print("")
|
18 | 18 | 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):
|
79 | 79 |
|
80 | 80 | print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
|
81 | 81 | print('>> Executing command: %s'%command)
|
82 |
| - print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 82 | + print('>> --------------------------------------------------------------') |
83 | 83 | p = Popen(shlex.split(command),
|
84 | 84 | stdout=PIPE,
|
85 | 85 | stderr=STDOUT,
|
86 | 86 | cwd=directory,
|
87 | 87 | env=env)
|
88 | 88 | with p.stdout:
|
89 | 89 | for line in iter(p.stdout.readline, b''):
|
90 |
| - print('>> %s'%line.decode('utf-8'), end='') |
| 90 | + print('>> %s'%line.decode('utf-8'), end='') |
91 | 91 | p.wait() # wait for the subprocess to exit
|
92 | 92 | except KeyboardInterrupt as e:
|
93 | 93 | print("Caught CTRL+C")
|
94 | 94 | if p:
|
95 | 95 | p.kill()
|
96 | 96 | raise e
|
97 |
| - print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 97 | + print('>> --------------------------------------------------------------') |
98 | 98 | print('>> Command exited with %i: %s'%(p.returncode,command))
|
99 | 99 | print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n')
|
100 | 100 |
|
| 101 | + if p.returncode!=0: |
| 102 | + print('Exiting as the last command failed') |
| 103 | + exit(p.returncode) |
| 104 | + |
101 | 105 |
|
102 | 106 |
|
103 | 107 | sys.path.append(os.environ['C302_HOME'])
|
@@ -142,6 +146,8 @@ def execute_with_realtime_output(command, directory, env=None):
|
142 | 146 | my_env = os.environ.copy()
|
143 | 147 | my_env["DISPLAY"] = ":44"
|
144 | 148 |
|
| 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. |
145 | 151 | os.system('Xvfb :44 -listen tcp -ac -screen 0 1920x1080x24+32 &') # TODO: terminate xvfb after recording
|
146 | 152 |
|
147 | 153 | try:
|
@@ -223,18 +229,21 @@ def execute_with_realtime_output(command, directory, env=None):
|
223 | 229 |
|
224 | 230 | time.sleep(2)
|
225 | 231 |
|
226 |
| - |
227 |
| - |
228 | 232 | # Rerun and record simulation
|
229 | 233 | os.system('export DISPLAY=:44')
|
230 | 234 | 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) |
232 | 241 |
|
233 | 242 | command = './Release/Sibernetic -f %s -l_from lpath=%s' % (DEFAULTS['configuration'], latest_subdir)
|
234 | 243 | execute_with_realtime_output(command, os.environ['SIBERNETIC_HOME'], env=my_env)
|
235 | 244 |
|
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) |
238 | 247 |
|
239 | 248 | time.sleep(5)
|
240 | 249 |
|
|
0 commit comments