Skip to content

Commit

Permalink
using appending uuid4 to /tmp/osaka-* files (#37)
Browse files Browse the repository at this point in the history
Co-authored-by: dustinlo <dustin.k.lo@jpl.nasa.gov>
  • Loading branch information
DustinKLo and dustinlo authored May 3, 2023
1 parent 55edbd8 commit 33fea46
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion osaka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
from __future__ import division
from __future__ import absolute_import

__version__ = "1.2.1"
__version__ = "1.2.2"
__url__ = "https://github.com/hysds/osaka"
__description__ = "Osaka (Object Store Abstraction K Arcitecture)"
4 changes: 3 additions & 1 deletion osaka/storage/az.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import datetime
import os.path
import traceback
from uuid import uuid4

import osaka.base
import osaka.utils
import osaka.storage.file
Expand Down Expand Up @@ -101,7 +103,7 @@ def get(self, uri):
container, key = osaka.utils.get_container_and_path(
urllib.parse.urlparse(uri).path
)
fname = "/tmp/osaka-azure-" + str(datetime.datetime.now())
fname = "/tmp/osaka-azure-%s-%s" % (uuid4(), datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S.%f"))
with open(fname, "w"):
pass
fh = open(fname, "r+b")
Expand Down
5 changes: 3 additions & 2 deletions osaka/storage/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import datetime
import io
from uuid import uuid4

import osaka.utils
import osaka.base
Expand Down Expand Up @@ -201,8 +202,8 @@ def __init__(self, stream):
# If the stream is not a file, make a temporary file out of it
if self.filename is None or not os.path.exists(self.filename):
self.handler = File()
self.filename = "/tmp/osaka-temporary-" + datetime.datetime.utcnow().strftime(
"%Y%m%d%H%M%S.%f"
self.filename = "/tmp/osaka-temporary-%s-%s" % (
uuid4(), datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S.%f")
)
self.handler.connect(self.filename)
self.handler.put(stream, self.filename)
Expand Down
4 changes: 3 additions & 1 deletion osaka/storage/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import datetime
import os.path
import traceback
from uuid import uuid4

import osaka.base
import osaka.utils
import osaka.storage.file
Expand Down Expand Up @@ -69,7 +71,7 @@ def get(self, uri):
"""
osaka.utils.LOGGER.debug("Getting stream from URI: {0}".format(uri))
filename = urllib.parse.urlparse(uri).path
fname = "/tmp/osaka-ftp-" + str(datetime.datetime.now())
fname = "/tmp/osaka-ftp-%s-%s" % (uuid4(), datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S.%f"))
try:
with open(fname, "w") as tmpf:
self.ftp.retrbinary("RETR %s" % filename, tmpf.write)
Expand Down
4 changes: 3 additions & 1 deletion osaka/storage/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import datetime
import os.path
import json
from uuid import uuid4

import osaka.base
import osaka.utils
import osaka.storage.file
Expand Down Expand Up @@ -180,7 +182,7 @@ def get(self, uri):
container, key = osaka.utils.get_s3_container_and_path(uri, is_nominal_style=self.is_nominal_style)
bucket = self.bucket(container, create=False)
obj = bucket.Object(key)
fname = "/tmp/osaka-s3-" + str(datetime.datetime.now())
fname = "/tmp/osaka-s3-%s-%s" % (uuid4(), datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S.%f"))
with open(fname, "w"):
pass
fh = open(fname, "r+b")
Expand Down
4 changes: 4 additions & 0 deletions osaka/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def transfer(
def transfer_uri(self, source, shandle, dest, dhandle):
"""
Transfer a URI recursing into it if it is a composite
@param source: Str
@param shandle: osaka.storage class instance (source)
@param dest: Str
@param dhandle: osaka.storage class instance (destination)
"""
metrics = {
"source": source,
Expand Down

0 comments on commit 33fea46

Please sign in to comment.