summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--image.py12
-rw-r--r--installmethod.py4
-rw-r--r--packages.py52
-rw-r--r--urlinstall.py24
4 files changed, 68 insertions, 24 deletions
diff --git a/image.py b/image.py
index 41a79c1db..bfa94d297 100644
--- a/image.py
+++ b/image.py
@@ -12,7 +12,7 @@
#
from comps import ComponentSet, HeaderListFromFile
-from installmethod import InstallMethod
+from installmethod import InstallMethod, FileCopyException
import iutil
import os
import isys
@@ -251,9 +251,9 @@ class CdromInstallMethod(ImageInstallMethod):
pass
tmppath = self.getTempPath()
- copied = 0
+ tries = 0
# FIXME: should retry a few times then prompt for new cd
- while not copied:
+ while tries < 5:
try:
shutil.copy(self.tree + "/RedHat/RPMS/" + h[1000000],
tmppath + h[1000000])
@@ -262,7 +262,11 @@ class CdromInstallMethod(ImageInstallMethod):
errnum, h[1000000], str(msg))
time.sleep(5)
else:
- copied = 1
+ break
+ tries = tries + 1
+
+ if tries >= 5:
+ raise FileCopyException
return tmppath + h[1000000]
diff --git a/installmethod.py b/installmethod.py
index a933d886a..19b0e0d74 100644
--- a/installmethod.py
+++ b/installmethod.py
@@ -17,6 +17,10 @@ from comps import ComponentSet
from rhpl.log import log
+class FileCopyException(Exception):
+ def __init__(self, s = ""):
+ self.str = s
+
class InstallMethod:
diff --git a/packages.py b/packages.py
index 733229f2c..82f05a379 100644
--- a/packages.py
+++ b/packages.py
@@ -29,6 +29,7 @@ from flags import flags
from constants import *
from syslogd import syslog
from comps import PKGTYPE_MANDATORY, PKGTYPE_DEFAULT
+from installmethod import FileCopyException
from rhpl.log import log
from rhpl.translate import _
@@ -110,14 +111,32 @@ def writeXConfiguration(id, instPath):
id.desktop.write(instPath)
def readPackages(intf, method, id):
- if (not id.hdList):
+ while id.hdList is None:
w = intf.waitWindow(_("Reading"), _("Reading package information..."))
- id.hdList = method.readHeaders()
- id.instClass.setPackageSelection(id.hdList)
- w.pop()
-
- if not id.comps:
- id.comps = method.readComps(id.hdList)
+ try:
+ id.hdList = method.readHeaders()
+ except FileCopyException:
+ w.pop()
+ method.unmountCD()
+ intf.messageWindow(_("Error"),
+ _("Unable to read header list. This may be "
+ "due to a missing file or bad media. "
+ "Press <return> to try again."))
+ continue
+
+ w.pop()
+ id.instClass.setPackageSelection(id.hdList)
+
+ while id.comps is None:
+ try:
+ id.comps = method.readComps(id.hdList)
+ except FileCopyException:
+ method.unmountCD()
+ intf.messageWindow(_("Error"),
+ _("Unable to read comps file. This may be "
+ "due to a missing file or bad media. "
+ "Press <return> to try again."))
+ continue
id.instClass.setGroupSelection(id.comps)
# XXX
@@ -280,9 +299,9 @@ class InstallCallback:
self.size = h[rpm.RPMTAG_SIZE]
while self.rpmFD < 0:
- fn = self.method.getFilename(h, self.pkgTimer)
# log("Opening rpm %s", fn)
try:
+ fn = self.method.getFilename(h, self.pkgTimer)
self.rpmFD = os.open(fn, os.O_RDONLY)
# Make sure this package seems valid
@@ -300,7 +319,7 @@ class InstallCallback:
except:
pass
self.rpmFD = -1
- raise SystemError
+ raise FileCopyException
except:
self.method.unmountCD()
self.messageWindow(_("Error"),
@@ -530,8 +549,17 @@ def doPreInstall(method, id, intf, instPath, dir):
# make sure that all comps that include other comps are
# selected (i.e. - recurse down the selected comps and turn
# on the children
-
- method.mergeFullHeaders(id.hdList)
+ while 1:
+ try:
+ method.mergeFullHeaders(id.hdList)
+ except FileCopyException:
+ method.unmountCD()
+ intf.messageWindow(_("Error"),
+ _("Unable to merge header list. This may be "
+ "due to a missing file or bad media. "
+ "Press <return> to try again."))
+ else:
+ break
if upgrade:
# An old mtab can cause confusion (esp if loop devices are
@@ -722,7 +750,7 @@ def doInstall(method, id, intf, instPath):
cb.initWindow = intf.waitWindow(_("Install Starting"),
_("Starting install process, this may take several minutes..."))
- ts.setProbFilter(~rpm.RPMPROB_FILTER_DISKSPACE)
+ ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)
problems = ts.run(cb.cb, 0)
if problems:
diff --git a/urlinstall.py b/urlinstall.py
index 688fecda8..6ccafdb79 100644
--- a/urlinstall.py
+++ b/urlinstall.py
@@ -14,7 +14,7 @@
#
from comps import ComponentSet, HeaderList
-from installmethod import InstallMethod
+from installmethod import InstallMethod, FileCopyException
import os
import rpm
import time
@@ -69,8 +69,8 @@ class UrlInstallMethod(InstallMethod):
file = tmppath + os.path.basename(fullPath)
- connected = 0
- while not connected:
+ tries = 0
+ while tries < 5:
try:
urlretrieve(fullPath, file)
except IOError, (errnum, msg):
@@ -78,7 +78,11 @@ class UrlInstallMethod(InstallMethod):
errnum, fullPath, str(msg))
time.sleep(5)
else:
- connected = 1
+ break
+ tries = tries + 1
+
+ if tries >= 5:
+ raise FileCopyException
return file
@@ -104,16 +108,16 @@ class UrlInstallMethod(InstallMethod):
time.sleep(5)
else:
connected = 1
-
+
return file
def unlinkFilename(self, fullName):
os.remove(fullName)
def readHeaders(self):
- connected = 0
+ tries = 0
- while not connected:
+ while tries < 5:
try:
url = urllib2.urlopen(self.baseUrl + "/RedHat/base/hdlist")
except IOError, (errnum, msg):
@@ -121,7 +125,11 @@ class UrlInstallMethod(InstallMethod):
errnum, self.baseUrl + "/RedHat/base/hdlist", msg)
time.sleep(5)
else:
- connected = 1
+ break
+ tries = tries + 1
+
+ if tries >= 5:
+ raise FileCopyException
raw = url.read(16)
hl = []