summaryrefslogtreecommitdiffstats
path: root/iw
diff options
context:
space:
mode:
Diffstat (limited to 'iw')
-rw-r--r--iw/task_gui.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/iw/task_gui.py b/iw/task_gui.py
index ad4117c75..cf46f7338 100644
--- a/iw/task_gui.py
+++ b/iw/task_gui.py
@@ -16,6 +16,11 @@ from iw_gui import *
from rhpl.translate import _, N_
from constants import productName
+import network
+
+from yuminstall import AnacondaYumRepo
+import yum.Errors
+
class TaskWindow(InstallWindow):
def getNext(self):
if self.xml.get_widget("customRadio").get_active():
@@ -51,10 +56,70 @@ class TaskWindow(InstallWindow):
return False
return True
+ def _addRepo(self, *args):
+ # FIXME: Need to bring up the network
+ if not network.hasActiveNetDev():
+ self.intf.messageWindow("Need network",
+ "additional repos can only be configured "
+ "if you have a network available.",
+ custom_icon="error")
+ return gtk.RESPONSE_CANCEL
+
+ (dxml, dialog) = gui.getGladeWidget("addrepo.glade", "addRepoDialog")
+ gui.addFrame(dialog)
+ dialog.show_all()
+
+ while 1:
+ rc = dialog.run()
+ if rc == gtk.RESPONSE_CANCEL:
+ break
+
+ reponame = dxml.get_widget("nameEntry").get_text()
+ reponame.strip()
+ if len(reponame) == 0:
+ self.intf.messageWindow(_("Invalid Repository Name"),
+ _("You must provide a non-zero length "
+ "repository name."))
+ continue
+
+ repourl = dxml.get_widget("urlEntry").get_text()
+ repourl.strip()
+ if (len(repourl) == 0 or not
+ (repourl.startswith("http://") or
+ repourl.startswith("ftp://"))):
+ self.intf.messageWindow(_("Invalid Repository URL"),
+ _("You must provide an HTTP or FTP "
+ "URL to a repository."))
+ continue
+
+ # FIXME: this is yum specific
+ repo = AnacondaYumRepo(uri=repourl, repoid=reponame)
+ repo.basecachedir = self.backend.ayum.conf.cachedir
+ repo.enable()
+ self.backend.ayum.repos.add(repo)
+
+ try:
+ self.backend.doRepoSetup(self.anaconda, reponame,
+ fatalerrors = False)
+ except yum.Errors.RepoError, e:
+ self.intf.messageWindow(_("Error"),
+ _("Unable to read package metadata from repository. "
+ "This may be due to a missing repodata directory. "
+ "Please ensure that your repository has been "
+ "correctly generated.\n\n%s" %(e,)),
+ type="ok", custom_icon="error")
+ self.backend.ayum.repos.delete(reponame)
+ continue
+ break
+
+ dialog.destroy()
+ return rc
+
def getScreen (self, anaconda):
self.intf = anaconda.intf
self.dispatch = anaconda.dispatch
self.backend = anaconda.backend
+ self.anaconda = anaconda
self.tasks = anaconda.id.instClass.tasks
self.taskcbs = {}
@@ -86,4 +151,6 @@ class TaskWindow(InstallWindow):
self.xml.get_widget("mainLabel").hide()
self.xml.get_widget("cbVBox").hide()
+ self.xml.get_widget("addRepoButton").connect("clicked", self._addRepo)
+
return vbox