Skip to content

Commit baedf0e

Browse files
committed
Greater flex about display
1 parent d4ad254 commit baedf0e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

master_openworm.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ def execute_with_realtime_output(command, directory, env=None):
100100

101101
if p.returncode!=0:
102102
print('Exiting as the last command failed')
103-
exit(p.returncode)
103+
#exit(p.returncode)
104104

105105

106106

107107
sys.path.append(os.environ['C302_HOME'])
108108

109109
try:
110-
os.system('xhost +')
110+
os.system('echo Granting permissions for xhost && xhost +')
111111
except:
112112
print("Unexpected error: %s" % sys.exc_info()[0])
113113

@@ -144,11 +144,12 @@ def execute_with_realtime_output(command, directory, env=None):
144144
'outDir': OW_OUT_DIR}
145145

146146
my_env = os.environ.copy()
147-
my_env["DISPLAY"] = ":44"
147+
DISPLAY = ':44'
148+
my_env["DISPLAY"] = DISPLAY
148149

149150
# Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol.
150151
# In contrast to other display servers, Xvfb performs all graphical operations in virtual memory without showing any screen output.
151-
os.system('Xvfb :44 -listen tcp -ac -screen 0 1920x1080x24+32 &') # TODO: terminate xvfb after recording
152+
os.system('echo Starting xvfb && Xvfb %s -listen tcp -ac -screen 0 1920x1080x24+32 &'%DISPLAY) # TODO: terminate xvfb after recording
152153

153154
try:
154155
command = """python sibernetic_c302.py
@@ -230,9 +231,11 @@ def execute_with_realtime_output(command, directory, env=None):
230231
time.sleep(2)
231232

232233
# Rerun and record simulation
233-
os.system('export DISPLAY=:44')
234+
execute_with_realtime_output('ls -alt /tmp/.X11-unix', os.environ['SIBERNETIC_HOME'], env=my_env)
235+
os.system('export DISPLAY=%s'%DISPLAY)
236+
execute_with_realtime_output('ls -alt /tmp/.X11-unix', os.environ['SIBERNETIC_HOME'], env=my_env)
234237
sibernetic_movie_name = '%s.mp4' % os.path.split(latest_subdir)[-1]
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)
238+
command = 'tmux new-session -d -P -s SiberneticRecording "DISPLAY=%s ffmpeg -r 30 -f x11grab -draw_mouse 0 -s 1920x1080 -i %s -filter:v "crop=1200:800:100:100" -cpu-used 0 -b:v 384k -qmin 10 -qmax 42 -maxrate 384k -bufsize 1000k -an %s/%s"' % (DISPLAY, DISPLAY, new_sim_out, sibernetic_movie_name)
236239
execute_with_realtime_output(command, os.environ['SIBERNETIC_HOME'], env=my_env)
237240

238241
time.sleep(3)

0 commit comments

Comments
 (0)