2626
2727'''
2828
29- from singularity . cli import Singularity
29+ from spython . main import Client
3030from .criteria import (
3131 assess_content ,
3232 include_file ,
@@ -48,7 +48,6 @@ def extract_guts(image_path,tar,file_filter,tag_root=True,include_sizes=True):
4848 read the memory in tar, or from fileystem
4949 '''
5050
51- cli = Singularity ()
5251 results = dict ()
5352 digest = dict ()
5453
@@ -64,7 +63,7 @@ def extract_guts(image_path,tar,file_filter,tag_root=True,include_sizes=True):
6463 if member .isdir () or member .issym ():
6564 continue
6665 elif assess_content (member ,file_filter ):
67- digest [member_name ] = extract_content (image_path ,member .name ,cli , return_hash = True )
66+ digest [member_name ] = extract_content (image_path , member .name , return_hash = True )
6867 included = True
6968 elif include_file (member ,file_filter ):
7069 hasher = hashlib .md5 ()
@@ -91,21 +90,18 @@ def get_memory_tar(image_path):
9190 '''get an in memory tar of an image. Use carefully, not as reliable
9291 as get_image_tar
9392 '''
94- cli = Singularity ()
95- byte_array = cli .export (image_path )
93+ byte_array = Client .export (image_path )
9694 file_object = io .BytesIO (byte_array )
9795 tar = tarfile .open (mode = "r|*" , fileobj = file_object )
9896 return (file_object ,tar )
9997
10098
101- def get_image_tar (image_path , S = None ):
99+ def get_image_tar (image_path ):
102100 '''get an image tar, either written in memory or to
103101 the file system. file_obj will either be the file object,
104102 or the file itself.
105103 '''
106104 bot .debug ('Generate file system tar...' )
107- if S is None :
108- S = Singularity ()
109105 file_obj = S .export (image_path = image_path )
110106 if file_obj is None :
111107 bot .error ("Error generating tar, exiting." )
@@ -128,17 +124,15 @@ def delete_image_tar(file_obj, tar):
128124 return deleted
129125
130126
131- def extract_content (image_path ,member_name ,cli = None , return_hash = False ):
127+ def extract_content (image_path , member_name , return_hash = False ):
132128 '''extract_content will extract content from an image using cat.
133129 If hash=True, a hash sum is returned instead
134130 '''
135131 if member_name .startswith ('./' ):
136132 member_name = member_name .replace ('.' ,'' ,1 )
137133 if return_hash :
138134 hashy = hashlib .md5 ()
139- if cli == None :
140- cli = Singularity ()
141- content = cli .execute (image_path ,'cat %s' % (member_name ))
135+ content = Client .execute (image_path ,'cat %s' % (member_name ))
142136 if not isinstance (content ,bytes ):
143137 content = content .encode ('utf-8' )
144138 content = bytes (content )
0 commit comments