Skip to content

Commit

Permalink
Error handling for download response code.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhtdht020 committed Nov 29, 2020
1 parent 43ca505 commit 09a3b80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Binary file modified assets/gui/splash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 11 additions & 7 deletions download.py
Expand Up @@ -15,15 +15,19 @@ def get(app_name, output=None, extract=False, repo="hbb1.oscwii.org"):
except requests.exceptions.SSLError:
app_data = requests.get("http://" + repo + "/hbb/" + app_name + "/" + app_name + ".zip")

with open(output, "wb") as app_data_file:
app_data_file.write(app_data.content)
if app_data.status_code == 200:
with open(output, "wb") as app_data_file:
app_data_file.write(app_data.content)

# Extract to ExtractedApps if needed
if extract is True:
with ZipFile(output, 'r') as zip_ref:
zip_ref.extractall("ExtractedApps")
# Extract to ExtractedApps if needed
if extract is True:
with ZipFile(output, 'r') as zip_ref:
zip_ref.extractall("ExtractedApps")

print(GREEN + "Download success! Output: " + output)
print(GREEN + "Download success! Output: " + output)

else:
print(FAIL + "Download failed. HTTP status code is not 200.")


def hbb(output):
Expand Down

0 comments on commit 09a3b80

Please sign in to comment.