示例#1
0
    def _parse_siteconf(self, siteconf):
        if not siteconf:
            return

        if not os.path.exists(siteconf):
            msger.warning("cannot read config file: %s" % siteconf)
            return

        parser = ConfigParser.SafeConfigParser()
        parser.read(siteconf)

        for section in parser.sections():
            if section in self.DEFAULTS:
                getattr(self, section).update(dict(parser.items(section)))

        # append common section items to other sections
        for section in self.DEFAULTS.keys():
            if section != "common" and not section.startswith('bootstrap'):
                getattr(self, section).update(self.common)

        # check and normalize the scheme of proxy url
        if self.create['proxy']:
            m = re.match('^(\w+)://.*', self.create['proxy'])
            if m:
                scheme = m.group(1)
                if scheme not in ('http', 'https', 'ftp', 'socks'):
                    msger.error("%s: proxy scheme is incorrect" % siteconf)
            else:
                msger.warning("%s: proxy url w/o scheme, use http as default"
                              % siteconf)
                self.create['proxy'] = "http://" + self.create['proxy']

        proxy.set_proxies(self.create['proxy'], self.create['no_proxy'])

        for section in parser.sections():
            if section.startswith('bootstrap'):
                name = section
                repostr = {}
                for option in parser.options(section):
                    if option == 'name':
                        name = parser.get(section, 'name')
                        continue

                    val = parser.get(section, option)
                    if '_' in option:
                        (reponame, repoopt) = option.split('_')
                        if repostr.has_key(reponame):
                            repostr[reponame] += "%s:%s," % (repoopt, val)
                        else:
                            repostr[reponame] = "%s:%s," % (repoopt, val)
                        continue

                    if val.split(':')[0] in ('file', 'http', 'https', 'ftp'):
                        if repostr.has_key(option):
                            repostr[option] += "name:%s,baseurl:%s," % (option, val)
                        else:
                            repostr[option]  = "name:%s,baseurl:%s," % (option, val)
                        continue

                self.bootstraps[name] = repostr
示例#2
0
    def set_runtime(self, runtime):
        if runtime not in ("bootstrap", "native"):
            msger.error("Invalid runtime mode: %s" % runtime)

        if misc.get_distro()[0] in ("tizen", "Tizen"):
            runtime = "native"
        self.create['runtime'] = runtime
示例#3
0
文件: conf.py 项目: saukko/mic
    def _parse_siteconf(self, siteconf):
        if not siteconf:
            return

        if not os.path.exists(siteconf):
            raise errors.ConfigError("Failed to find config file: %s" % siteconf)

        parser = ConfigParser.SafeConfigParser()
        parser.read(siteconf)

        for section in parser.sections():
            if section in self.DEFAULTS:
                getattr(self, section).update(dict(parser.items(section)))

        # append common section items to other sections
        for section in self.DEFAULTS.keys():
            if section != "common" and not section.startswith("bootstrap"):
                getattr(self, section).update(self.common)

        if self.create["proxy"]:
            urlptn = re.compile("://")
            m = urlptn.search(self.create["proxy"])
            if m:
                scheme = self.create["proxy"].split(":")[0]
                if scheme not in ("http", "https", "ftp", "socks"):
                    msger.error("%s: proxy scheme is incorrect" % siteconf)
            else:
                msger.warning("%s: proxy set without scheme, use http default" % siteconf)
                self.create["proxy"] = "http://%s" % self.create["proxy"]
        proxy.set_proxies(self.create["proxy"], self.create["no_proxy"])

        for section in parser.sections():
            if section.startswith("bootstrap"):
                name = section
                repostr = {}
                for option in parser.options(section):
                    if option == "name":
                        name = parser.get(section, "name")
                        continue

                    val = parser.get(section, option)
                    if "_" in option:
                        (reponame, repoopt) = option.split("_")
                        if repostr.has_key(reponame):
                            repostr[reponame] += "%s:%s," % (repoopt, val)
                        else:
                            repostr[reponame] = "%s:%s," % (repoopt, val)
                        continue

                    if val.split(":")[0] in ("file", "http", "https", "ftp"):
                        if repostr.has_key(option):
                            repostr[option] += "name:%s,baseurl:%s," % (option, val)
                        else:
                            repostr[option] = "name:%s,baseurl:%s," % (option, val)
                        continue

                self.bootstraps[name] = repostr
示例#4
0
    def _parse_siteconf(self, siteconf):
        if not siteconf:
            return

        if not os.path.exists(siteconf):
            msger.warning("cannot read config file: %s" % siteconf)
            return

        parser = ConfigParser.SafeConfigParser()
        parser.read(siteconf)

        for section in parser.sections():
            if section in self.DEFAULTS:
                getattr(self, section).update(dict(parser.items(section)))

        # append common section items to other sections
        for section in self.DEFAULTS.keys():
            if section != "common":
                getattr(self, section).update(self.common)

        # check and normalize the scheme of proxy url
        if self.create['proxy']:
            m = re.match('^(\w+)://.*', self.create['proxy'])
            if m:
                scheme = m.group(1)
                if scheme not in ('http', 'https', 'ftp', 'socks'):
                    msger.error("%s: proxy scheme is incorrect" % siteconf)
            else:
                msger.warning("%s: proxy url w/o scheme, use http as default"
                              % siteconf)
                self.create['proxy'] = "http://" + self.create['proxy']

        proxy.set_proxies(self.create['proxy'], self.create['no_proxy'])

        # bootstrap option handling
        self.set_runtime(self.create['runtime'])
        if isinstance(self.bootstrap['packages'], basestring):
            packages = self.bootstrap['packages'].replace('\n', ' ')
            if packages.find(',') != -1:
                packages = packages.split(',')
            else:
                packages = packages.split()
            self.bootstrap['packages'] = packages
示例#5
0
 def run(self):
     while True:
         try:
             task = self.__getqueue.get(block=False)
             stat = self.__install(task)
             if stat == 0:
                 self.__putqueue.put(task, block=False)
                 self.__quiet or \
                 msger.info("[+] %s" % task)
             else:
                 self.__quiet or \
                 msger.error("[-] %s" % task)
         except Queue.Empty:
             break
示例#6
0
文件: conf.py 项目: jfding/mic
    def __set_ksconf(self, ksconf):
        if not os.path.isfile(ksconf):
            msger.error('Cannot find ks file: %s' % ksconf)

        self.__ksconf = ksconf
        self._parse_kickstart(ksconf)
示例#7
0
文件: conf.py 项目: csdb/mic
    def __set_ksconf(self, ksconf):
        if not os.path.isfile(ksconf):
            msger.error('Cannot find ks file: %s' % ksconf)

        self.__ksconf = ksconf
        self._parse_kickstart(ksconf)
示例#8
0
    def _parse_siteconf(self, siteconf):
        if not siteconf:
            return

        if not os.path.exists(siteconf):
            raise errors.ConfigError("Failed to find config file: %s" \
                                     % siteconf)

        parser = ConfigParser.SafeConfigParser()
        parser.read(siteconf)

        for section in parser.sections():
            if section in self.DEFAULTS:
                getattr(self, section).update(dict(parser.items(section)))

        # append common section items to other sections
        for section in self.DEFAULTS.keys():
            if section != "common" and not section.startswith('bootstrap'):
                getattr(self, section).update(self.common)

        if self.create['proxy']:
            urlptn = re.compile('://')
            m = urlptn.search(self.create['proxy'])
            if m:
                scheme = self.create['proxy'].split(':')[0]
                if scheme not in ('http', 'https', 'ftp', 'socks'):
                    msger.error("%s: proxy scheme is incorrect" % siteconf)
            else:
                msger.warning(
                    "%s: proxy set without scheme, use http default" %
                    siteconf)
                self.create['proxy'] = "http://%s" % self.create['proxy']
        proxy.set_proxies(self.create['proxy'], self.create['no_proxy'])

        for section in parser.sections():
            if section.startswith('bootstrap'):
                name = section
                repostr = {}
                for option in parser.options(section):
                    if option == 'name':
                        name = parser.get(section, 'name')
                        continue

                    val = parser.get(section, option)
                    if '_' in option:
                        (reponame, repoopt) = option.split('_')
                        if repostr.has_key(reponame):
                            repostr[reponame] += "%s:%s," % (repoopt, val)
                        else:
                            repostr[reponame] = "%s:%s," % (repoopt, val)
                        continue

                    if val.split(':')[0] in ('file', 'http', 'https', 'ftp'):
                        if repostr.has_key(option):
                            repostr[option] += "name:%s,baseurl:%s," % (option,
                                                                        val)
                        else:
                            repostr[option] = "name:%s,baseurl:%s," % (option,
                                                                       val)
                        continue

                self.bootstraps[name] = repostr
示例#9
0
文件: conf.py 项目: sledges/mic
    def _parse_siteconf(self, siteconf):
        if not siteconf:
            return

        if not os.path.exists(siteconf):
            msger.warning("cannot read config file: %s" % siteconf)
            return

        parser = ConfigParser.SafeConfigParser()
        parser.read(siteconf)

        for section in parser.sections():
            if section in self.DEFAULTS:
                getattr(self, section).update(dict(parser.items(section)))

        # append common section items to other sections
        for section in self.DEFAULTS.keys():
            if section != "common" and not section.startswith('bootstrap'):
                getattr(self, section).update(self.common)

        # check and normalize the scheme of proxy url
        if self.create['proxy']:
            m = re.match('^(\w+)://.*', self.create['proxy'])
            if m:
                scheme = m.group(1)
                if scheme not in ('http', 'https', 'ftp', 'socks'):
                    msger.error("%s: proxy scheme is incorrect" % siteconf)
            else:
                msger.warning("%s: proxy url w/o scheme, use http as default" %
                              siteconf)
                self.create['proxy'] = "http://" + self.create['proxy']

        proxy.set_proxies(self.create['proxy'], self.create['no_proxy'])

        for section in parser.sections():
            if section.startswith('bootstrap'):
                name = section
                repostr = {}
                for option in parser.options(section):
                    if option == 'name':
                        name = parser.get(section, 'name')
                        continue

                    val = parser.get(section, option)
                    if '_' in option:
                        (reponame, repoopt) = option.split('_')
                        if repostr.has_key(reponame):
                            repostr[reponame] += "%s:%s," % (repoopt, val)
                        else:
                            repostr[reponame] = "%s:%s," % (repoopt, val)
                        continue

                    if val.split(':')[0] in ('file', 'http', 'https', 'ftp'):
                        if repostr.has_key(option):
                            repostr[option] += "name:%s,baseurl:%s," % \
                                                (option, val)
                        else:
                            repostr[option]  = "name:%s,baseurl:%s," % \
                                                (option, val)
                        continue

                self.bootstraps[name] = repostr