Skip to content

Commit

Permalink
Merge pull request #57 from 4dn-dcic/s3unzip
Browse files Browse the repository at this point in the history
Update s3_utils.py
  • Loading branch information
SooLee authored Feb 11, 2020
2 parents ca6e33c + 5d6bffd commit bfbd5a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions dcicutils/s3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,16 @@ def unzip_s3_to_s3(self, zipped_s3key, dest_dir, acl=None):
bytestream = BytesIO(s3_stream)
zipstream = ZipFile(bytestream, 'r')

# directory should be first name in the list
# The contents of zip can sometimes be like
# ["foo/", "file1", "file2", "file3"]
# and other times like
# ["file1", "file2", "file3"]
file_list = zipstream.namelist()
basedir_name = file_list.pop(0)
assert basedir_name.endswith('/')
if file_list[0].endswith('/'):
# in case directory first name in the list
basedir_name = file_list.pop(0)
else:
basedir_name = ''

ret_files = {}
for file_name in file_list:
Expand Down
2 changes: 1 addition & 1 deletion test/test_ff_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def test_faceted_search_users(integrated_ff):
'ff_env': ff_env,
'item_facets': all_facets}
resp = ff_utils.faceted_search(**neg_affiliation)
assert len(resp) == 20
assert len(resp) == 23
neg_affiliation = {'item_type': 'user',
'Affiliation': '-4DN Testing Lab',
'key': key,
Expand Down
1 change: 1 addition & 0 deletions test/test_jh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def test_jh_open_4dn_file(integrated_ff):
assert 'No such file or directory' in str(exec_info6.value)


@pytest.mark.skip(reason="we no longer have tracking items")
def test_add_mounted_file_to_session(integrated_ff):
test_server = integrated_ff['ff_key']['server']
initialize_jh_env(test_server)
Expand Down

0 comments on commit bfbd5a8

Please sign in to comment.