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

tools: make nodedownload.py Python 3 compatible #29104

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 7 additions & 5 deletions tools/configure.d/nodedownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
# Moved some utilities here from ../../configure

from __future__ import print_function
import urllib
import hashlib
import sys
import zipfile
import tarfile
import fpformat
import contextlib
try:
from urllib.request import FancyURLopener, URLopener
except ImportError:
from urllib import FancyURLopener, URLopener

def formatSize(amt):
"""Format a size as a string in MB"""
return fpformat.fix(amt / 1024000., 1)
return "%.1f" % (amt / 1024000.)

def spin(c):
"""print out an ASCII 'spinner' based on the value of counter 'c'"""
spin = ".:|'"
return (spin[c % len(spin)])

class ConfigOpener(urllib.FancyURLopener):
class ConfigOpener(FancyURLopener):
"""fancy opener used by retrievefile. Set a UA"""
# append to existing version (UA)
version = '%s node.js/configure' % urllib.URLopener.version
version = '%s node.js/configure' % URLopener.version

def reporthook(count, size, total):
"""internal hook used by retrievefile"""
Expand Down