Skip to content

Commit

Permalink
trying workaround for pull
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoch committed Sep 9, 2018
1 parent b7e4ec1 commit 6d0d25d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions spython/main/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from spython.utils import stream_command
import os
import re
import shutil
import sys
import tempfile

def pull(self,
image=None,
Expand Down Expand Up @@ -99,8 +101,20 @@ def pull(self,

# Option 1: For hash or commit, need return value to get final_image
if name_by_commit or name_by_hash:
output = self._run_command(cmd, capture=True)
final_image = output.split('Container is at:')[-1].strip('\n').strip()

# Set pull to temporary location
tmp_folder = tempfile.mkdtemp()
self.setenv('SINGULARITY_PULLFOLDER', tmp_folder)
self._run_command(cmd, capture=capture)

try:
tmp_image = os.path.join(tmp_folder, os.listdir(tmp_folder)[0])
final_image = os.path.join(pull_folder, os.path.basename(tmp_image))
shutil.move(tmp_image, final_image)
shutil.rmtree(tmp_folder)

except:
bot.error('Issue pulling image with commit or hash, try without?')

# Option 2: Streaming we just run to show user
elif stream is False:
Expand Down

0 comments on commit 6d0d25d

Please sign in to comment.