2
2
import matplotlib
3
3
matplotlib .use ('Agg' )
4
4
import shutil
5
- from subprocess import Popen , PIPE , check_output , STDOUT
5
+ from subprocess import Popen , PIPE , check_output
6
6
import os
7
7
import pwd
8
8
import shlex
12
12
import math
13
13
14
14
print ("*****************************" )
15
- print ("OpenWorm Master Script v0.9.3 " )
15
+ print ("OpenWorm Master Script v0.9.2 " )
16
16
print ("*****************************" )
17
17
print ("" )
18
18
print ("This script attempts to run a full pass through the OpenWorm scientific libraries." )
76
76
def execute_with_realtime_output (command , directory , env = None ):
77
77
p = None
78
78
try :
79
-
80
- print ('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' )
81
- print ('>> Executing command: %s' % command )
82
- print ('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' )
83
- p = Popen (shlex .split (command ),
84
- stdout = PIPE ,
85
- stderr = STDOUT ,
86
- cwd = directory ,
87
- env = env )
79
+ p = Popen (shlex .split (command ), stdout = PIPE , bufsize = 1 , cwd = directory , env = env )
88
80
with p .stdout :
89
81
for line in iter (p .stdout .readline , b'' ):
90
- print ('>> %s' % line .decode ('utf-8' ), end = '' )
82
+ print (line .decode ('utf-8' ), end = '' )
91
83
p .wait () # wait for the subprocess to exit
92
84
except KeyboardInterrupt as e :
93
85
print ("Caught CTRL+C" )
94
86
if p :
95
87
p .kill ()
96
88
raise e
97
- print ('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>' )
98
- print ('>> Command exited with %i: %s' % (p .returncode ,command ))
99
- print ('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n ' )
100
-
101
89
102
90
103
91
sys .path .append (os .environ ['C302_HOME' ])
@@ -122,10 +110,6 @@ def execute_with_realtime_output(command, directory, env=None):
122
110
if 'DURATION' in os .environ :
123
111
sim_duration = float (os .environ ['DURATION' ])
124
112
125
- noc302 = False
126
- if 'NOC302' in os .environ :
127
- noc302 = bool (os .environ ['NOC302' ])
128
-
129
113
DEFAULTS = {'duration' : sim_duration ,
130
114
'dt' : 0.005 ,
131
115
'dtNrn' : 0.05 ,
@@ -135,7 +119,7 @@ def execute_with_realtime_output(command, directory, env=None):
135
119
'verbose' : False ,
136
120
'device' : 'GPU' ,
137
121
'configuration' : 'worm_crawl_half_resolution' ,
138
- 'noc302' : noc302 ,
122
+ 'noc302' : False ,
139
123
'datareader' : 'UpdatedSpreadsheetDataReader2' ,
140
124
'outDir' : OW_OUT_DIR }
141
125
@@ -167,9 +151,6 @@ def execute_with_realtime_output(command, directory, env=None):
167
151
DEFAULTS ['datareader' ],
168
152
'simulations' )
169
153
#DEFAULTS['outDir'])
170
-
171
- if noc302 : command += ' -noc302'
172
-
173
154
execute_with_realtime_output (command , os .environ ['SIBERNETIC_HOME' ], env = my_env )
174
155
except KeyboardInterrupt as e :
175
156
pass
@@ -181,13 +162,9 @@ def execute_with_realtime_output(command, directory, env=None):
181
162
for directory in dirnames :
182
163
if directory .startswith ('%s_%s' % (DEFAULTS ['c302params' ], DEFAULTS ['reference' ])):
183
164
all_subdirs .append (os .path .join (dirpath , directory ))
184
- if directory .startswith ('Sibernetic' ):
185
- all_subdirs .append (os .path .join (dirpath , directory ))
186
165
187
166
latest_subdir = max (all_subdirs , key = os .path .getmtime )
188
- print ('\n ========================================================================\n ' )
189
- print ('Finished main simulation, data saved in: %s' % latest_subdir )
190
- execute_with_realtime_output ('ls -alt %s' % latest_subdir , os .environ ['SIBERNETIC_HOME' ], env = my_env )
167
+
191
168
192
169
try :
193
170
os .mkdir ('%s/output' % OW_OUT_DIR )
@@ -221,9 +198,6 @@ def execute_with_realtime_output(command, directory, env=None):
221
198
print ("Moving %s to %s" % (wcon , new_sim_out ))
222
199
shutil .move (wcon , new_sim_out )
223
200
224
- time .sleep (2 )
225
-
226
-
227
201
228
202
# Rerun and record simulation
229
203
os .system ('export DISPLAY=:44' )
@@ -236,9 +210,7 @@ def execute_with_realtime_output(command, directory, env=None):
236
210
os .system ('tmux send-keys -t SiberneticRecording q' )
237
211
os .system ('tmux send-keys -t SiberneticRecording "exit" C-m' )
238
212
239
- time .sleep (5 )
240
-
241
- execute_with_realtime_output ('ls -alt %s' % latest_subdir , os .environ ['SIBERNETIC_HOME' ], env = my_env )
213
+ time .sleep (3 )
242
214
243
215
# Remove black frames at the beginning of the recorded video
244
216
command = "ffmpeg -i %s/%s -vf blackdetect=d=0:pic_th=0.70:pix_th=0.10 -an -f null - 2>&1 | grep blackdetect" % (new_sim_out , sibernetic_movie_name )
@@ -275,7 +247,7 @@ def execute_with_realtime_output(command, directory, env=None):
275
247
os .system ('ffmpeg -ss 1 -i %s/cut_%s -vf "select=gt(scene\,0.1)" -vsync vfr -vf fps=fps=1/1 %s' % (new_sim_out , sibernetic_movie_name , 'tmp/out%06d.jpg' ))
276
248
os .system ('ffmpeg -r 100 -i %s -r 100 -vb 60M %s/speeded_%s' % ('tmp/out%06d.jpg' , new_sim_out , sibernetic_movie_name ))
277
249
278
- os .system ('rm -r tmp/*' )
250
+ os .system ('sudo rm -r tmp/*' )
279
251
280
252
281
253
0 commit comments