25
25
PATH_ROOT = os .path .dirname (__file__ )
26
26
27
27
28
+ def _create_temp_file ():
29
+ """
30
+ Get a temporary file.
31
+ """
32
+
33
+ (_ , filename ) = tempfile .mkstemp (suffix = ".mpk" )
34
+
35
+ return filename
36
+
37
+
38
+ def _delete_temp_file (filename ):
39
+ """
40
+ Delete a temporary file.
41
+ """
42
+
43
+ try :
44
+ os .remove (filename )
45
+ except OSError :
46
+ pass
47
+
48
+
28
49
def _get_run_mesher (use_script , file_geometry , file_voxel ):
29
50
"""
30
51
Run the mesher.
@@ -166,8 +187,8 @@ def run_workflow(name, use_script):
166
187
file_tolerance = os .path .join (folder_examples , "config" , "tolerance.yaml" )
167
188
168
189
# get the temporary files
169
- ( _ , file_voxel ) = tempfile . mkstemp ( suffix = ".mpk" )
170
- ( _ , file_solution ) = tempfile . mkstemp ( suffix = ".mpk" )
190
+ file_voxel = _create_temp_file ( )
191
+ file_solution = _create_temp_file ( )
171
192
172
193
# run the workflow and load the results
173
194
try :
@@ -181,8 +202,8 @@ def run_workflow(name, use_script):
181
202
data_voxel = scisave .load_data (file_voxel )
182
203
data_solution = scisave .load_data (file_solution )
183
204
finally :
184
- # close the temporary files
185
- os . remove (file_voxel )
186
- os . remove (file_solution )
205
+ # delete the temporary files
206
+ _delete_temp_file (file_voxel )
207
+ _delete_temp_file (file_solution )
187
208
188
209
return data_voxel , data_solution
0 commit comments