예제 #1
0
파일: repoadd.py 프로젝트: sanjana098/faf
    def run(self, cmdline, db):
        repo = (db.session.query(Repo)
                .filter(Repo.name == cmdline.NAME)
                .first())

        if repo:
            self.log_error("Repository '{0}' already defined"
                           .format(cmdline.NAME))
            return 1

        self.log_info("Adding repository '{0}' ({1})"
                      .format(cmdline.NAME, cmdline.URL))

        new = Repo()
        new.name = cmdline.NAME
        new.type = cmdline.TYPE
        for url in cmdline.URL:
            new_url = Url()
            new_url.url = url
            new.url_list.append(new_url)

        if cmdline.nice_name:
            new.nice_name = cmdline.nice_name

        new.nogpgcheck = cmdline.nogpgcheck

        db.session.add(new)
        db.session.flush()
        return 0
예제 #2
0
    def run(self, cmdline, db):
        repo = (db.session.query(Repo)
                          .filter(Repo.name == cmdline.NAME)
                          .first())

        if repo:
            self.log_error("Repository '{0}' already defined"
                           .format(cmdline.NAME))
            return 1

        self.log_info("Adding repository '{0}' ({1})"
                      .format(cmdline.NAME, cmdline.URL))

        new = Repo()
        new.name = cmdline.NAME
        new.type = cmdline.TYPE
        for url in cmdline.URL:
            new_url = Url()
            new_url.url = url
            new.url_list.append(new_url)

        if cmdline.nice_name:
            new.nice_name = cmdline.nice_name

        new.nogpgcheck = cmdline.nogpgcheck

        db.session.add(new)
        db.session.flush()
예제 #3
0
    def _import_yum_repo(self, fp):
        """
        Parse open .repo file `fp` and return
        list of Repo instances.

        Section name is used as repository name,
        baseurl (required) and gpgcheck are stored.
        """

        parser = ConfigParser.SafeConfigParser()
        try:
            parser.readfp(fp)
        except ConfigParser.Error as exc:
            self.log_error("Exception while parsing repository file: "
                           "'{0}'".format(exc))
            return None

        result = []
        for section in parser.sections():
            new = Repo()
            new.name = section
            new.type = "yum"
            if not parser.has_option(section, "baseurl"):
                self.log_error("Repo '{0}' is missing required"
                               " option 'baseurl'".format(section))
                return None

            new.url = parser.get(section, "baseurl")

            if parser.has_option(section, "gpgcheck"):
                new.nogpgcheck = parser.getint(section, "gpgcheck") == 0

            result.append(new)

        return result
예제 #4
0
파일: repoimport.py 프로젝트: jfilak/faf
    def _import_yum_repo(self, fp):
        """
        Parse open .repo file `fp` and return
        list of Repo instances.

        Section name is used as repository name,
        baseurl (required) and gpgcheck are stored.
        """

        parser = ConfigParser.SafeConfigParser()
        try:
            parser.readfp(fp)
        except ConfigParser.Error as exc:
            self.log_error("Exception while parsing repository file: "
                           "'{0}'".format(exc))
            return None

        result = []
        for section in parser.sections():
            new = Repo()
            new.name = section
            new.type = "yum"
            if not parser.has_option(section, "baseurl"):
                self.log_error("Repo '{0}' is missing required"
                               " option 'baseurl'".format(section))
                return None

            new.url = parser.get(section, "baseurl")

            if parser.has_option(section, "gpgcheck"):
                new.nogpgcheck = parser.getint(section, "gpgcheck") == 0

            result.append(new)

        return result
예제 #5
0
파일: repoimport.py 프로젝트: mzidek-gh/faf
    def import_repo(self, fp, repo_type):
        """
        Parse open .repo file `fp` and return
        list of Repo instances.

        Section name is used as repository name,
        baseurl (required) and gpgcheck are stored.
        """

        parser = configparser.SafeConfigParser()
        try:
            parser.readfp(fp)  #pylint: disable=deprecated-method
        except configparser.Error as exc:
            self.log_error("Exception while parsing repository file: "
                           "'{0}'".format(exc))
            return None

        result = []
        for section in parser.sections():
            new = Repo()
            new.name = section
            new.type = repo_type
            if not parser.has_option(section, "baseurl"):
                self.log_error("Repo '{0}' is missing required"
                               " option 'baseurl'".format(section))
                return None

            new_url = Url()
            new_url.url = parser.get(section, "baseurl")
            new.url_list = [new_url]

            if parser.has_option(section, "gpgcheck"):
                new.nogpgcheck = parser.getint(section, "gpgcheck") == 0

            result.append(new)

        return result
예제 #6
0
파일: repoimport.py 프로젝트: abrt/faf
    def import_repo(self, fp, repo_type):
        """
        Parse open .repo file `fp` and return
        list of Repo instances.

        Section name is used as repository name,
        baseurl (required) and gpgcheck are stored.
        """

        parser = configparser.SafeConfigParser()
        try:
            parser.readfp(fp) #pylint: disable=deprecated-method
        except configparser.Error as exc:
            self.log_error("Exception while parsing repository file: "
                           "'{0}'".format(exc))
            return None

        result = []
        for section in parser.sections():
            new = Repo()
            new.name = section
            new.type = repo_type
            if not parser.has_option(section, "baseurl"):
                self.log_error("Repo '{0}' is missing required"
                               " option 'baseurl'".format(section))
                return None

            new_url = Url()
            new_url.url = parser.get(section, "baseurl")
            new.url_list = [new_url]

            if parser.has_option(section, "gpgcheck"):
                new.nogpgcheck = parser.getint(section, "gpgcheck") == 0

            result.append(new)

        return result