コード例 #1
0
    def dump(self, fp):
        """
        Dump this easyconfig to file, with the given filename.
        """
        eb_file = file(fp, "w")

        def to_str(x):
            """Return quoted version of x"""
            if isinstance(x, basestring):
                if '\n' in x or ('"' in x and "'" in x):
                    return '"""%s"""' % x
                elif "'" in x:
                    return '"%s"' % x
                else:
                    return "'%s'" % x
            else:
                return "%s" % x

        # ordered groups of keys to obtain a nice looking easyconfig file
        grouped_keys = [
                        ["name", "version", "versionprefix", "versionsuffix"],
                        ["homepage", "description"],
                        ["toolchain", "toolchainopts"],
                        ["source_urls", "sources"],
                        ["patches"],
                        ["dependencies"],
                        ["parallel", "maxparallel"],
                        ["osdependencies"]
                        ]

        # print easyconfig parameters ordered and in groups specified above
        ebtxt = []
        printed_keys = []
        for group in grouped_keys:
            for key1 in group:
                val = self._config[key1][0]
                for key2, [def_val, _, _] in DEFAULT_CONFIG.items():
                    # only print parameters that are different from the default value
                    if key1 == key2 and val != def_val:
                        ebtxt.append("%s = %s" % (key1, to_str(val)))
                        printed_keys.append(key1)
            ebtxt.append("")

        # print other easyconfig parameters at the end
        for key, [val, _, _] in DEFAULT_CONFIG.items():
            if not key in printed_keys and val != self._config[key][0]:
                ebtxt.append("%s = %s" % (key, to_str(self._config[key][0])))

        eb_file.write('\n'.join(ebtxt))
        eb_file.close()
コード例 #2
0
    def det_full_module_name(self, ec):
        """
        Determine full module name from given easyconfig, according to a testing module naming scheme,
        using all available easyconfig parameters.

        @param ec: dict-like object with easyconfig parameter values (e.g. 'name', 'version', etc.)

        @return: string with full module name, e.g.: ('gzip', '1.5'), ('intel', 'intelmpi', 'gzip', '1.5')
        """
        res = ''
        for key in sorted(DEFAULT_CONFIG.keys()):
            if isinstance(ec[key], dict):
                res += '%s=>' % key
                for item_key in sorted(ec[key].keys()):
                    res += '%s:%s,' % (item_key, ec[key][item_key])
            else:
                res += str(ec[key])
        ec_sha1 = sha1(res).hexdigest()
        _log.debug("SHA1 for string '%s' obtained for %s: %s" % (res, ec, ec_sha1))
        return os.path.join(ec['name'], ec_sha1)
コード例 #3
0
    def det_full_module_name(self, ec):
        """
        Determine full module name from given easyconfig, according to a testing module naming scheme,
        using all available easyconfig parameters.

        @param ec: dict-like object with easyconfig parameter values (e.g. 'name', 'version', etc.)

        @return: string with full module name, e.g.: ('gzip', '1.5'), ('intel', 'intelmpi', 'gzip', '1.5')
        """
        res = ''
        for key in sorted(DEFAULT_CONFIG.keys()):
            if isinstance(ec[key], dict):
                res += '%s=>' % key
                for item_key in sorted(ec[key].keys()):
                    res += '%s:%s,' % (item_key, ec[key][item_key])
            else:
                res += str(ec[key])
        ec_sha1 = sha1(res).hexdigest()
        _log.debug("SHA1 for string '%s' obtained for %s: %s" %
                   (res, ec, ec_sha1))
        return os.path.join(ec['name'], ec_sha1)