Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

47 creation of cog files #52

Merged
merged 3 commits into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading