Skip to content

Commit

Permalink
Merge pull request #52 from geofranzi/47-creation-of-cog-files
Browse files Browse the repository at this point in the history
47 creation of cog files
  • Loading branch information
geofranzi authored May 3, 2024
2 parents 532e9d2 + c3bff03 commit dc8911e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions framework/climate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def post(self, request):

response = JsonResponse(
{
"wget-command": 'wget --content-disposition --input-file' +
"wget-command": 'wget --content-disposition --input-file ' +
f'"https://leutra.geogr.uni-jena.de/backend_geoportal/climate/get_climate_txt?hash={unique_filehash}"'
}
)
Expand All @@ -117,7 +117,7 @@ def get(self, request):

dir_content_element = []
dir_content_element.append(f)
dir_content_element.append(str(file_stats.st_size / (1024 * 1024)) + " MB")
dir_content_element.append(self.sizeof_fmt(file_stats.st_size))
creation_date = None

try:
Expand All @@ -136,6 +136,14 @@ def get(self, request):
response = JsonResponse({"content": dir_content})
return response

def sizeof_fmt(self, num, suffix="B"):
for unit in ("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi"):
if abs(num) < 1024.0:
return f"{num:3.1f} {unit}{suffix}"
num /= 1024.0

return f"{num:.1f}Yi{suffix}"


# returns a single file (if it is present in the specified directory ('TESTCONTENT_DIR' rn)
class GetFileView(APIView):
Expand Down

0 comments on commit dc8911e

Please sign in to comment.