-
Notifications
You must be signed in to change notification settings - Fork 23
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
add DOWNLOAD
staging action
#3282
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #3282 +/- ##
==========================================
+ Coverage 42.78% 42.91% +0.12%
==========================================
Files 97 97
Lines 11310 11286 -24
==========================================
+ Hits 4839 4843 +4
+ Misses 6471 6443 -28 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left 2 comments @andre-merzky. Thanks.
def download(self, src, tgt, flags): | ||
tgt = ru.Url(tgt).path | ||
self.mkdir(os.path.dirname(tgt), flags) | ||
ru.sh_callout('wget -r %s -O %s' % (src, tgt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I am mistaken, but some Linux flavors might not have the wget
command. So to avoid this, I think Python approach is the most guaranteed to work in most cases as Python interpreter must exist. So I would suggest to do the following:
import requests
def download(self, src: str, tgt: str, flags:str) -> None:
"""Download the remote file to the current tgt directory."""
response = requests.get(src, stream=True)
tgt = ru.Url(tgt).path
try:
response.raise_for_status() # Check if the download was successful
except Exception as e:
print(f'ERROR: skipping staging, download failed due to: {e}')
return
self.mkdir(os.path.dirname(tgt), flags)
# Save the file content
with open(tgt, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, we can use python for that, will change!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @andre-merzky
This fixes #3266