File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 2121from spython .utils import stream_command
2222import os
2323import re
24+ import shutil
2425import sys
26+ import tempfile
2527
2628def pull (self ,
2729 image = None ,
@@ -99,8 +101,20 @@ def pull(self,
99101
100102 # Option 1: For hash or commit, need return value to get final_image
101103 if name_by_commit or name_by_hash :
102- output = self ._run_command (cmd , capture = True )
103- final_image = output .split ('Container is at:' )[- 1 ].strip ('\n ' ).strip ()
104+
105+ # Set pull to temporary location
106+ tmp_folder = tempfile .mkdtemp ()
107+ self .setenv ('SINGULARITY_PULLFOLDER' , tmp_folder )
108+ self ._run_command (cmd , capture = capture )
109+
110+ try :
111+ tmp_image = os .path .join (tmp_folder , os .listdir (tmp_folder )[0 ])
112+ final_image = os .path .join (pull_folder , os .path .basename (tmp_image ))
113+ shutil .move (tmp_image , final_image )
114+ shutil .rmtree (tmp_folder )
115+
116+ except :
117+ bot .error ('Issue pulling image with commit or hash, try without?' )
104118
105119 # Option 2: Streaming we just run to show user
106120 elif stream is False :
You can’t perform that action at this time.
0 commit comments