Skip to content

Commit 1f2787c

Browse files
committed
need to get image file hash
1 parent 90a510f commit 1f2787c

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

singularity/hub/auth.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@
3333
import sys
3434

3535

36+
def basic_auth_header(username, password):
37+
'''basic_auth_header will return a base64 encoded header object to
38+
generate a token
39+
:param username: the username
40+
:param password: the password
41+
'''
42+
s = "%s:%s" % (username, password)
43+
if sys.version_info[0] >= 3:
44+
s = bytes(s, 'utf-8')
45+
credentials = base64.b64encode(s).decode('utf-8')
46+
else:
47+
credentials = base64.b64encode(s)
48+
auth = {"Authorization": "Basic %s" % credentials}
49+
return auth
50+
51+
52+
3653
def get_headers(token=None):
3754
'''get_headers will return a simple default header for a json
3855
post. This function will be adopted as needed.

singularity/package.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,6 @@ def package(image_path,spec_path=None,output_folder=None,runscript=True,
178178
if spec_path is not None:
179179
singularity_spec = "".join(read_file(spec_path))
180180
to_package['Singularity'] = singularity_spec
181-
182-
# Package the image with an sha1, identical standard, as VERSION
183-
if old_version == False:
184-
hashes = get_image_hashes(image_path)
185-
to_package["HASHES"] = hashes
186-
to_package["VERSION"] = hashes['IDENTICAL']
187-
else:
188181
to_package["VERSION"] = get_image_file_hash(image_path)
189182

190183

0 commit comments

Comments
 (0)