Skip to content

Commit

Permalink
Final modifications to enable read and write through NgasDROP
Browse files Browse the repository at this point in the history
  • Loading branch information
awicenec committed Apr 12, 2021
1 parent a06e313 commit 3d96b57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions daliuge-engine/dlg/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ def _is_length_unknown(self):

def _getClient(self):
return ngaslite.open(
self._ngasSrv, self._fileId, port=self._ngasPort, timeout=self._ngasTimeout)
self._ngasSrv, self._fileId, port=self._ngasPort, timeout=self._ngasTimeout,\
mode=self._mode, mimeType=self._mimeType)

def _open(self, **kwargs):
if self._mode == OpenMode.OPEN_WRITE:
Expand All @@ -348,9 +349,7 @@ def _open(self, **kwargs):
# when finishArchive is called.
self._buf = b''
self._writtenDataSize = 0
return self._getClient()
else:
return self._getClient()
return self._getClient()

def _close(self, **kwargs):
if self._mode == OpenMode.OPEN_WRITE:
Expand Down
11 changes: 6 additions & 5 deletions daliuge-engine/dlg/ngaslite.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
logger = logging.getLogger(__name__)


def open(host, fileId, port=7777, timeout=None):
url = 'http://%s:%d/RETRIEVE?file_id=%s' % (host, port, fileId)
logger.debug("Issuing RETRIEVE request: %s" % (url))
conn = urlrequest.urlopen(url)
return conn
def open(host, fileId, port=7777, timeout=None, mode=1, mimeType='application/octet-stream'):
if mode == 1:
return retrieve(host, fileId, port=port, timeout=timeout)
else:
return beginArchive(host, fileId, port=port, timeout=timeout, mimeType=mimeType)

def retrieve(host, fileId, port=7777, timeout=None):
"""
Expand All @@ -65,6 +65,7 @@ def beginArchive(host, fileId, port=7777, timeout=0, length=-1, mimeType='applic
Once all the data has been sent, the `finishArchive` method of this module
should be invoked to check that all went well with the archiving.
"""
logger.debug("Issuing ARCHIVE for file %s request to: http://%s:%d" % (fileId, host,port))
conn = httplib.HTTPConnection(host, port, timeout=timeout)
conn.putrequest('POST', '/QARCHIVE?filename=' + fileId)
conn.putheader('Content-Type', mimeType)
Expand Down

0 comments on commit 3d96b57

Please sign in to comment.