@@ -88,36 +88,29 @@ def extract_guts(image_path,tar,file_filter,tag_root=True,include_sizes=True):
8888
8989
9090def get_memory_tar (image_path ):
91- '''get an in memory tar of an image (does not require sudo!)'''
91+ '''get an in memory tar of an image. Use carefully, not as reliable
92+ as get_image_tar
93+ '''
9294 cli = Singularity ()
9395 byte_array = cli .export (image_path )
9496 file_object = io .BytesIO (byte_array )
9597 tar = tarfile .open (mode = "r|*" , fileobj = file_object )
9698 return (file_object ,tar )
9799
98100
99- def get_image_tar (image_path ,write_file = True , S = None ):
101+ def get_image_tar (image_path ,S = None ):
100102 '''get an image tar, either written in memory or to
101103 the file system. file_obj will either be the file object,
102104 or the file itself.
103105 '''
104-
105- # Singularity 2.3 and up
106- if not write_file :
107- file_obj ,tar = get_memory_tar (image_path )
108- bot .debug ('Generate in memory tar...' )
109-
110- # Singularity < version 2.3
111- else :
112- bot .debug ('Generate file system tar...' )
113- if S is None :
114- S = Singularity ()
115- file_obj = S .export (image_path = image_path )
116- if file_obj is None :
117- bot .error ("Error generating tar, exiting." )
118- sys .exit (1 )
119- tar = tarfile .open (file_obj )
120-
106+ bot .debug ('Generate file system tar...' )
107+ if S is None :
108+ S = Singularity ()
109+ file_obj = S .export (image_path = image_path )
110+ if file_obj is None :
111+ bot .error ("Error generating tar, exiting." )
112+ sys .exit (1 )
113+ tar = tarfile .open (file_obj )
121114 return file_obj , tar
122115
123116
@@ -149,8 +142,7 @@ def extract_content(image_path,member_name,cli=None,return_hash=False):
149142 cli = Singularity ()
150143 content = cli .execute (image_path ,'cat %s' % (member_name ))
151144 if not isinstance (content ,bytes ):
152- if isinstance (content ,str ):
153- content = content .encode ('utf-8' )
145+ content = content .encode ('utf-8' )
154146 content = bytes (content )
155147 # If permissions don't allow read, return None
156148 if len (content ) == 0 :
0 commit comments