def run(self): applyFuncs = [ self._applyURL, self._applyMedia, self._applyNfs, self._applyHd ] while True: rc = self.dialog.run() if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]: break reponame = self.nameEntry.get_text() reponame.strip() if len(reponame) == 0: self.intf.messageWindow(_("Invalid Repository Name"), _("You must provide a repository name.")) continue # Always create a new repo object here instead of attempting to # somehow expire the metadata and refetch. We'll just have to make # sure that if we're just editing the repo, we grab all the # attributes from the old one before deleting it. if self.repo: # use temporary id so that we don't get Duplicate Repo error # when adding newRepoObj = AnacondaYumRepo("UIedited_%s" % self.anaconda.backend.ayum.repoIDcounter.next()) newRepoObj.cost = self.repo.cost removeOld = True else: newRepoObj = AnacondaYumRepo(reponame.replace(" ", "")) removeOld = False # corresponds to self.repos.setCacheDir in AnacondaYum.doConfigSetup newRepoObj.basecachedir = self.anaconda.backend.ayum.conf.cachedir type = self.typeComboBox.get_active() if (not applyFuncs[type](newRepoObj) or not self._addAndEnableRepo(newRepoObj)): continue if not setupRepo(self.anaconda, newRepoObj): self._disableAndRemoveRepo(newRepoObj) continue if removeOld: try: os.unlink("%s/cachecookie" % self.repo.cachedir) os.unlink("%s/repomd.xml" % self.repo.cachedir) except: pass self.repo.disable() self.repo.close() self.anaconda.backend.ayum.repos.delete(self.repo.id) log.info("deleted (UI) repository %s with source URL %s, id:%s" % (self.repo.name, self.repo.mirrorlist or self.repo.baseurl, self.repo.id)) try: shutil.rmtree(self.repo.cachedir) except Exception as e: log.warning("error removing cachedir for %s: %s" %(self.repo, e)) pass if (newRepoObj.enablegroups or (removeOld and self.repo.enablegroups)): # update groups information try: self.anaconda.backend.ayum.doGroupSetup() except Exception as e: log.debug("unable to reset group information after UI repo edit: %s" % e) else: log.info("group information reset after UI repo edit") self.repo = newRepoObj break self.dialog.hide() return rc
def _addRepo(self, *args): if not network.hasActiveNetDev(): net = NetworkConfigurator(self.anaconda.id.network) ret = net.run() net.destroy() if ret == gtk.RESPONSE_CANCEL: return gtk.RESPONSE_CANCEL (dxml, dialog) = gui.getGladeWidget("addrepo.glade", "addRepoDialog") gui.addFrame(dialog) lbl = dxml.get_widget("descLabel") txt = lbl.get_text() lbl.set_text(txt % (productName, )) 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.name = reponame repo.basecachedir = self.backend.ayum.conf.cachedir repo.enable() try: self.backend.ayum.repos.add(repo) except yum.Errors.DuplicateRepoError, e: self.intf.messageWindow( _("Error"), _("The repository %s has already been added. Please " "choose a different repository name and " "URL.") % reponame, type="ok", custom_icon="error") continue if not self._setupRepo(repo): continue s = self.xml.get_widget("repoList").get_model() s.append([repo.isEnabled(), repo.name, repo]) self.repos[repo.name] = (repo.baseurl[0], None) break
def run(self): applyFuncs = [ self._applyURL, self._applyMedia, self._applyNfs, self._applyHd ] while True: rc = self.dialog.run() if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]: break reponame = self.nameEntry.get_text() reponame.strip() if len(reponame) == 0: self.intf.messageWindow(_("Invalid Repository Name"), _("You must provide a repository name.")) self.dialog.present() continue # Always create a new repo object here instead of attempting to # somehow expire the metadata and refetch. We'll just have to make # sure that if we're just editing the repo, we grab all the # attributes from the old one before deleting it. if self.repo: # use temporary id so that we don't get Duplicate Repo error # when adding newRepoObj = AnacondaYumRepo("UIedited_%s" % self.anaconda.backend.ayum.repoIDcounter.next()) newRepoObj.cost = self.repo.cost removeOld = True else: newRepoObj = AnacondaYumRepo(reponame.replace(" ", "")) removeOld = False # corresponds to self.repos.setCacheDir in AnacondaYum.doConfigSetup newRepoObj.basecachedir = self.anaconda.backend.ayum.conf.cachedir type = self.typeComboBox.get_active() if (not applyFuncs[type](newRepoObj) or not self._addAndEnableRepo(newRepoObj)): self.dialog.present() continue if not setupRepo(self.anaconda, newRepoObj): self._disableAndRemoveRepo(newRepoObj) self.dialog.present() continue if removeOld: try: os.unlink("%s/cachecookie" % self.repo.cachedir) os.unlink("%s/repomd.xml" % self.repo.cachedir) except: pass self.repo.disable() self.repo.close() self.anaconda.backend.ayum.repos.delete(self.repo.id) log.info("deleted (UI) repository %s with source URL %s, id:%s" % (self.repo.name, self.repo.mirrorlist or self.repo.baseurl, self.repo.id)) try: shutil.rmtree(self.repo.cachedir) except Exception as e: log.warning("error removing cachedir for %s: %s" %(self.repo, e)) pass if (newRepoObj.enablegroups or (removeOld and self.repo.enablegroups)): # update groups information try: self.anaconda.backend.ayum.doGroupSetup() except Exception as e: log.debug("unable to reset group information after UI repo edit: %s" % e) else: log.info("group information reset after UI repo edit") self.repo = newRepoObj break self.dialog.hide() return rc
def _addRepo(self, *args): if not network.hasActiveNetDev(): net = NetworkConfigurator(self.anaconda.id.network) ret = net.run() net.destroy() if ret == gtk.RESPONSE_CANCEL: return gtk.RESPONSE_CANCEL (dxml, dialog) = gui.getGladeWidget("addrepo.glade", "addRepoDialog") gui.addFrame(dialog) lbl = dxml.get_widget("descLabel") txt = lbl.get_text() lbl.set_text(txt %(productName,)) 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.name = reponame repo.basecachedir = self.backend.ayum.conf.cachedir repo.enable() try: self.backend.ayum.repos.add(repo) except yum.Errors.DuplicateRepoError, e: self.intf.messageWindow(_("Error"), _("The repository %s has already been added. Please " "choose a different repository name and " "URL.") % reponame, type="ok", custom_icon="error") continue if not self._setupRepo(repo): continue s = self.xml.get_widget("repoList").get_model() s.append([repo.isEnabled(), repo.name, repo]) self.repos[repo.name] = (repo.baseurl[0], None) break