INNER CODE UNIT · Python
download_cb
MathCancer/PhysiCell · beta/download_binary.py:70
def download_cb(blocknum, blocksize, totalsize):
readsofar = blocknum * blocksize
if totalsize > 0:
percent = readsofar * 1e2 / totalsize
s = "\r%5.1f%% %*d / %d" % (
percent, len(str(totalsize)), readsofar, totalsize)
sys.stderr.write(s)
if readsofar >= totalsize: # near the end
sys.stderr.write("\n")
else: # total size is unknown
sys.stderr.write("read %d\n" % (readsofar,))
urllib.request.urlretrieve(url, my_file, download_cb)
print('> Creating backup of XML settings, Makefile, main.cpp')
if os.path.exists("Makefile"):
shutil.copyfile("Makefile", "Makefile-backup")
if os.path.exists("main.cpp"):