Skip to content

Commit

Permalink
Adding support for S3 files in GPFile objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtabor committed Jul 14, 2021
1 parent 9223522 commit 808d3cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 0 additions & 8 deletions gp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,3 @@

# Import core functionality
from .core import GPException, GPFile, GPJob, GPJobSpec, GPResource, GPServer, GPTask, GPTaskParam, GPJSONEncoder

# Import subpackages, if available
try:
import gp.utils
except Exception:
# Ignore if subpackages are unavailable
True

8 changes: 7 additions & 1 deletion gp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ def open(self):
if self.server_data.authorization_header() is not None:
request.add_header('Authorization', self.server_data.authorization_header())
request.add_header('User-Agent', 'GenePatternRest')
return urllib.request.urlopen(request)
try:
return urllib.request.urlopen(request)
except urllib.error.HTTPError as e:
if e.geturl(): # Handle S3 redirects if one is encountered
return urllib.request.urlopen(urllib.request.Request(e.geturl()))
else:
raise e

def read(self):
"""
Expand Down

0 comments on commit 808d3cf

Please sign in to comment.