File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 21
21
from spython .utils import stream_command
22
22
import os
23
23
import re
24
+ import shutil
24
25
import sys
26
+ import tempfile
25
27
26
28
def pull (self ,
27
29
image = None ,
@@ -99,8 +101,20 @@ def pull(self,
99
101
100
102
# Option 1: For hash or commit, need return value to get final_image
101
103
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?' )
104
118
105
119
# Option 2: Streaming we just run to show user
106
120
elif stream is False :
You can’t perform that action at this time.
0 commit comments