summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2002-11-01 23:00:18 +0000
committerJeremy Katz <katzj@redhat.com>2002-11-01 23:00:18 +0000
commit2ff37e6c7e31eea589da78e06115135a80af4f80 (patch)
tree8127d0dec53b72552ba56c08692308201c934b56
parent0598e7df508a41be0440a68c345b15a20c67b0bf (diff)
downloadanaconda-2ff37e6c7e31eea589da78e06115135a80af4f80.tar.gz
anaconda-2ff37e6c7e31eea589da78e06115135a80af4f80.tar.xz
anaconda-2ff37e6c7e31eea589da78e06115135a80af4f80.zip
move to urllib2. this should make catching exceptions on transfer errors 'better'
-rw-r--r--comps.py4
-rw-r--r--urlinstall.py19
2 files changed, 16 insertions, 7 deletions
diff --git a/comps.py b/comps.py
index 55d57cf78..cbcff5282 100644
--- a/comps.py
+++ b/comps.py
@@ -20,7 +20,7 @@ import rpm
import os
from string import *
import types
-import urllib
+import urllib2
import time
import language
@@ -701,7 +701,7 @@ class ComponentSet:
connected = 0
while not connected:
try:
- file = urllib.urlopen(filename)
+ file = urllib2.urlopen(filename)
except IOError, (errnum, msg):
log("IOError %s occurred getting %s: %s", filename,
errnum, str(msg))
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)