def __init__(self, anaconda, methodstr): # Create temporary repo to store methodstr needed for # createDialog parent method. temprepo = AnacondaYumRepo("UITmpMethodstrRepo") temprepo.name = "Installation Repo" temprepo.anacondaBaseURLs = [methodstr] RepoEditor.__init__(self, anaconda, temprepo)
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 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