def get_latest_files(): """Download the latest files from the IEEE""" if _sys.version_info[0] == 3: # Python 3.x from urllib.request import Request, urlopen else: # Python 2.x from urllib2 import Request, urlopen urls = [ 'http://standards.ieee.org/regauth/oui/oui.txt', 'http://standards.ieee.org/regauth/oui/iab.txt', ] for url in urls: _sys.stdout.write('downloading latest copy of %s\n' % url) request = Request(url) response = urlopen(request) save_path = _path.dirname(__file__) filename = _path.join(save_path, _os.path.basename(response.geturl())) fh = open(filename, 'w') fh.write(response.read()) fh.close() # Make sure the line endings are consistent across platforms. dos2unix(filename)
def get_latest_files(): """Download the latest files from IANA""" if _sys.version_info[0] == 3: # Python 3.x from urllib.request import Request, urlopen else: # Python 2.x from urllib2 import Request, urlopen urls = [ 'http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xml', 'http://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xml', 'http://www.iana.org/assignments/multicast-addresses/multicast-addresses.xml', ] for url in urls: _sys.stdout.write('downloading latest copy of %s\n' % url) request = Request(url) response = urlopen(request) save_path = _path.dirname(__file__) basename = _os.path.basename(response.geturl().rstrip('/')) filename = _path.join(save_path, basename) fh = open(filename, 'wb') fh.write(response.read()) fh.close() # Make sure the line endings are consistent across platforms. dos2unix(filename)