mirror of
https://github.com/RasppleII/a2server.git
synced 2025-08-15 17:27:21 +00:00
install-gsos.py: Improve download func output
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=python:
|
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=python:
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
import os, sys, subprocess
|
import os, sys, subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -103,10 +106,8 @@ def download_from_sources(fileinfo, output_dir):
|
|||||||
if not quiet:
|
if not quiet:
|
||||||
print("Downloading %s:" % (fileinfo["file"]))
|
print("Downloading %s:" % (fileinfo["file"]))
|
||||||
for (source, url) in fileinfo["sources"]:
|
for (source, url) in fileinfo["sources"]:
|
||||||
if verbose:
|
if not quiet:
|
||||||
print(" Trying %s (%s)..." % (source, url))
|
print(" Trying %s..." % (source), end="")
|
||||||
elif not quiet:
|
|
||||||
print(" Trying %s..." % (source))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
html = urlrequest.urlopen(url)
|
html = urlrequest.urlopen(url)
|
||||||
@@ -115,6 +116,8 @@ def download_from_sources(fileinfo, output_dir):
|
|||||||
f.write(data)
|
f.write(data)
|
||||||
f.close()
|
f.close()
|
||||||
except:
|
except:
|
||||||
|
if not quiet:
|
||||||
|
print(" download failed.")
|
||||||
if 'f' in locals():
|
if 'f' in locals():
|
||||||
if not f.isclosed():
|
if not f.isclosed():
|
||||||
f.close()
|
f.close()
|
||||||
@@ -122,12 +125,12 @@ def download_from_sources(fileinfo, output_dir):
|
|||||||
|
|
||||||
digest = sha1sum_file(output_path)
|
digest = sha1sum_file(output_path)
|
||||||
if digest == fileinfo["digest"]:
|
if digest == fileinfo["digest"]:
|
||||||
if verbose:
|
if not quiet:
|
||||||
print(" Digest of %s matches, download complete.\n" % (digest))
|
print(" successfully downloaded.")
|
||||||
elif not quiet:
|
|
||||||
print(" Download complete.\n")
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
if not quiet:
|
||||||
|
print(" failed (digest mismatch).")
|
||||||
if verbose:
|
if verbose:
|
||||||
print(" Expected: %s\n Received: %s"
|
print(" Expected: %s\n Received: %s"
|
||||||
% (fileinfo["digest"], digest))
|
% (fileinfo["digest"], digest))
|
||||||
|
Reference in New Issue
Block a user