Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 859ca7c

Browse files
committed
use tempfile
1 parent 3f1ad0d commit 859ca7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/copy_from_gcp_to_aws.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
download_to_local,
66
upload_one_file,
77
)
8+
import tempfile
89
import gcsfs
910
import os
1011
import logging
@@ -40,8 +41,10 @@ def one_file(filename):
4041
if file_index > 18000:
4142
print(filename)
4243

43-
download_to_local(remote_filename=filename, local_filename="temp.nc")
44-
upload_one_file(remote_filename=aws_filename, local_filename="temp.nc")
44+
with tempfile.NamedTemporaryFile(suffix=".tif") as t:
45+
name = t.name
46+
download_to_local(remote_filename=filename, local_filename=name)
47+
upload_one_file(remote_filename=aws_filename, local_filename=name)
4548

4649

4750
# loop over files

0 commit comments

Comments
 (0)