diff options
author | Jeremy Katz <katzj@redhat.com> | 2002-11-01 23:00:18 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2002-11-01 23:00:18 +0000 |
commit | 2ff37e6c7e31eea589da78e06115135a80af4f80 (patch) | |
tree | 8127d0dec53b72552ba56c08692308201c934b56 /urlinstall.py | |
parent | 0598e7df508a41be0440a68c345b15a20c67b0bf (diff) | |
download | anaconda-2ff37e6c7e31eea589da78e06115135a80af4f80.tar.gz anaconda-2ff37e6c7e31eea589da78e06115135a80af4f80.tar.xz anaconda-2ff37e6c7e31eea589da78e06115135a80af4f80.zip |
move to urllib2. this should make catching exceptions on transfer errors 'better'
Diffstat (limited to 'urlinstall.py')
-rw-r--r-- | urlinstall.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/urlinstall.py b/urlinstall.py index ce5d6db4e..ad388f29b 100644 --- a/urlinstall.py +++ b/urlinstall.py @@ -18,7 +18,7 @@ from installmethod import InstallMethod import os import rpm import time -import urllib +import urllib2 import string import struct import socket @@ -34,8 +34,17 @@ from rhpl.log import log FILENAME = 1000000 DISCNUM = 1000002 -class UrlInstallMethod(InstallMethod): +def urlretrieve(location, file): + """Downloads from location and saves to file." + + url = urllib2.urlopen(location) + f = open(file, 'w+') + f.write(url.read()) + f.close() + url.close() + +class UrlInstallMethod(InstallMethod): def readCompsViaMethod(self, hdlist): fname = self.findBestFileMatch(None, 'comps.xml') # if not local then assume its on host @@ -63,7 +72,7 @@ class UrlInstallMethod(InstallMethod): connected = 0 while not connected: try: - urllib.urlretrieve(fullPath, file) + urlretrieve(fullPath, file) except IOError, (errnum, msg): log("IOError %s occurred getting %s: %s", errnum, fullPath, str(msg)) @@ -88,7 +97,7 @@ class UrlInstallMethod(InstallMethod): connected = 0 while not connected: try: - urllib.urlretrieve(fullPath, file) + urlretrieve(fullPath, file) except IOError, (errnum, msg): log("IOError %s occurred getting %s: %s", errnum, fullPath, str(msg)) @@ -106,7 +115,7 @@ class UrlInstallMethod(InstallMethod): while not connected: try: - url = urllib.urlopen(self.baseUrl + "/RedHat/base/hdlist") + url = urllib2.urlopen(self.baseUrl + "/RedHat/base/hdlist") except IOError, (errnum, msg): log("IOError %s occurred getting %s: %s", errnum, self.baseUrl + "/RedHat/base/hdlist", msg) |