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

Fix downloading of Mbed 2 when zip is too big #857

Merged
merged 2 commits into from
Mar 4, 2019
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
11 changes: 7 additions & 4 deletions mbed/mbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,14 @@ def fetch_rev(url, rev):
try:
if not os.path.exists(rev_file):
action("Downloading library build \"%s\" (might take a while)" % rev)
outfd = open(rev_file, 'wb')
inurl = urlopen(url)
outfd.write(inurl.read())
outfd.close()
except:
with open(rev_file, 'wb') as outfd:
data = None
while data != '':
# Download and write the data in 1 MB chunks
data = inurl.read(1024 * 1024)
outfd.write(data)
except Exception:
if os.path.isfile(rev_file):
os.remove(rev_file)
raise Exception(128, "Download failed!\nPlease try again later.")
Expand Down