Skip to content

Commit 31c50e5

Browse files
cclausstargos
authored andcommitted
tools: make nodedownload.py Python 3 compatible
PR-URL: #29104 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 9057814 commit 31c50e5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tools/configure.d/nodedownload.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@
22
# Moved some utilities here from ../../configure
33

44
from __future__ import print_function
5-
import urllib
65
import hashlib
76
import sys
87
import zipfile
98
import tarfile
10-
import fpformat
119
import contextlib
10+
try:
11+
from urllib.request import FancyURLopener, URLopener
12+
except ImportError:
13+
from urllib import FancyURLopener, URLopener
1214

1315
def formatSize(amt):
1416
"""Format a size as a string in MB"""
15-
return fpformat.fix(amt / 1024000., 1)
17+
return "%.1f" % (amt / 1024000.)
1618

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

22-
class ConfigOpener(urllib.FancyURLopener):
24+
class ConfigOpener(FancyURLopener):
2325
"""fancy opener used by retrievefile. Set a UA"""
2426
# append to existing version (UA)
25-
version = '%s node.js/configure' % urllib.URLopener.version
27+
version = '%s node.js/configure' % URLopener.version
2628

2729
def reporthook(count, size, total):
2830
"""internal hook used by retrievefile"""

0 commit comments

Comments
 (0)