Ejemplo n.º 1
0
    def add_easyconfig(self, cfg, name, version, stats, previous):
        """
        Add easyconfig to repository

        :param cfg: location of easyconfig file
        :param name: software name
        :param version: software install version, incl. toolchain & versionsuffix
        :param stats: build stats, to add to archived easyconfig
        :param previous: list of previous build stats
        :return: location of archived easyconfig
        """
        # create directory for eb file
        full_path = os.path.join(self.wc, self.subdir, name)

        yeb_format = is_yeb_format(cfg, None)
        if yeb_format:
            extension = YEB_FORMAT_EXTENSION
            prefix = "buildstats: ["

        else:
            extension = EB_FORMAT_EXTENSION
            prefix = "buildstats = ["

        # destination
        dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension))

        txt = "# Built with EasyBuild version %s on %s\n" % (
            VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S"))

        # copy file
        txt += read_file(cfg)

        # append a line to the eb file so that we don't have git merge conflicts
        statscomment = "\n# Build statistics\n"
        statsprefix = prefix
        statssuffix = "]\n"
        if previous:
            statstxt = statscomment + statsprefix + '\n'
            for entry in previous + [stats]:
                statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n'
            statstxt += statssuffix
        else:
            statstxt = statscomment + statsprefix + stats_to_str(
                stats, isyeb=yeb_format) + statssuffix

        txt += statstxt
        write_file(dest, txt)

        return dest
Ejemplo n.º 2
0
    def add_easyconfig(self, cfg, name, version, stats, previous):
        """
        Add the eb-file for for software name and version to the repository.
        stats should be a dict containing stats.
        if previous is true -> append the stats to the file
        This will return the path to the created file (for use in subclasses)
        """
        # create directory for eb file
        full_path = os.path.join(self.wc, self.subdir, name)
        if not os.path.isdir(full_path):
            os.makedirs(full_path)

        # destination
        dest = os.path.join(full_path, "%s.eb" % version)

        txt = "# Built with %s on %s\n" % (VERBOSE_VERSION,
                                           time.strftime("%Y-%m-%d_%H-%M-%S"))

        # copy file
        txt += read_file(cfg)

        # append a line to the eb file so we don't have git merge conflicts
        if not previous:
            statsprefix = "\n# Build statistics\nbuildstats = ["
            statssuffix = "]\n"
        else:
            # statstemplate = "\nbuildstats.append(%s)\n"
            statsprefix = "\nbuildstats.append("
            statssuffix = ")\n"

        txt += statsprefix + stats_to_str(stats) + statssuffix
        write_file(dest, txt)

        return dest
Ejemplo n.º 3
0
    def add_easyconfig(self, cfg, name, version, stats, previous):
        """
        Add the eb-file for software name and version to the repository.
        stats should be a dict containing statistics.
        if previous is true -> append the statistics to the file
        This will return the path to the created file (for use in subclasses)
        """
        # create directory for eb file
        full_path = os.path.join(self.wc, self.subdir, name)
        mkdir(full_path, parents=True)

        # destination
        dest = os.path.join(full_path, "%s-%s.eb" % (name, version))

        txt = "# Built with EasyBuild version %s on %s\n" % (VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S"))

        # copy file
        txt += read_file(cfg)

        # append a line to the eb file so that we don't have git merge conflicts
        if not previous:
            statsprefix = "\n# Build statistics\nbuildstats = ["
            statssuffix = "]\n"
        else:
            # statstemplate = "\nbuildstats.append(%s)\n"
            statsprefix = "\nbuildstats.append("
            statssuffix = ")\n"

        txt += statsprefix + stats_to_str(stats) + statssuffix
        write_file(dest, txt)

        return dest
Ejemplo n.º 4
0
    def add_easyconfig(self, cfg, name, version, stats, previous):
        """
        Add easyconfig to repository

        :param cfg: location of easyconfig file
        :param name: software name
        :param version: software install version, incl. toolchain & versionsuffix
        :param stats: build stats, to add to archived easyconfig
        :param previous: list of previous build stats
        :return: location of archived easyconfig
        """
        # create directory for eb file
        full_path = os.path.join(self.wc, self.subdir, name)

        yeb_format = is_yeb_format(cfg, None)
        if yeb_format:
            extension = YEB_FORMAT_EXTENSION
            prefix = "buildstats: ["

        else:
            extension = EB_FORMAT_EXTENSION
            prefix = "buildstats = ["

        # destination
        dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension))

        txt = "# Built with EasyBuild version %s on %s\n" % (VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S"))

        # copy file
        txt += read_file(cfg)

        # append a line to the eb file so that we don't have git merge conflicts
        statscomment = "\n# Build statistics\n"
        statsprefix = prefix
        statssuffix = "]\n"
        if previous:
            statstxt = statscomment + statsprefix + '\n'
            for entry in previous + [stats]:
                statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n'
            statstxt += statssuffix
        else:
            statstxt = statscomment + statsprefix + stats_to_str(stats, isyeb=yeb_format) + statssuffix

        txt += statstxt
        write_file(dest, txt)

        return dest
Ejemplo n.º 5
0
    def add_easyconfig(self, cfg, name, version, stats, previous):
        """
        Add the eb-file for software name and version to the repository.
        stats should be a dict containing statistics.
        if previous is true -> append the statistics to the file
        This will return the path to the created file (for use in subclasses)
        """
        # create directory for eb file
        full_path = os.path.join(self.wc, self.subdir, name)
        mkdir(full_path, parents=True)
        yeb_format = is_yeb_format(cfg, None)

        if yeb_format:
            extension = YEB_FORMAT_EXTENSION
            prefix = "buildstats: ["

        else:
            extension = EB_FORMAT_EXTENSION
            prefix = "buildstats = ["

        # destination
        dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension))

        txt = "# Built with EasyBuild version %s on %s\n" % (
            VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S"))

        # copy file
        txt += read_file(cfg)

        # append a line to the eb file so that we don't have git merge conflicts
        statscomment = "\n# Build statistics\n"
        statsprefix = prefix
        statssuffix = "]\n"
        if previous:
            statstxt = statscomment + statsprefix + '\n'
            for entry in previous + [stats]:
                statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n'
            statstxt += statssuffix
        else:
            statstxt = statscomment + statsprefix + stats_to_str(
                stats, isyeb=yeb_format) + statssuffix

        txt += statstxt
        write_file(dest, txt)

        return dest
Ejemplo n.º 6
0
    def add_easyconfig(self, cfg, name, version, stats, previous):
        """
        Add the eb-file for software name and version to the repository.
        stats should be a dict containing statistics.
        if previous is true -> append the statistics to the file
        This will return the path to the created file (for use in subclasses)
        """
        # create directory for eb file
        full_path = os.path.join(self.wc, self.subdir, name)
        mkdir(full_path, parents=True)
        yeb_format = is_yeb_format(cfg, None)

        if yeb_format:
            extension = YEB_FORMAT_EXTENSION
            prefix = "buildstats: ["

        else:
            extension = EB_FORMAT_EXTENSION
            prefix = "buildstats = ["

        # destination
        dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension))

        txt = "# Built with EasyBuild version %s on %s\n" % (VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S"))

        # copy file
        txt += read_file(cfg)

        # append a line to the eb file so that we don't have git merge conflicts
        statscomment = "\n# Build statistics\n"
        statsprefix = prefix
        statssuffix = "]\n"
        if previous:
            statstxt = statscomment + statsprefix + '\n'
            for entry in previous + [stats]:
                statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n'
            statstxt += statssuffix
        else:
            statstxt = statscomment + statsprefix + stats_to_str(stats, isyeb=yeb_format) + statssuffix

        txt += statstxt
        write_file(dest, txt)

        return dest
    def add_easyconfig(self, cfg, name, version, stats, previous):
        """
        Add the eb-file for for software name and version to the repository.
        stats should be a dict containing stats.
        if previous is true -> append the stats to the file
        This will return the path to the created file (for use in subclasses)
        """
        # create directory for eb file
        full_path = os.path.join(self.wc, self.subdir, name)
        if not os.path.isdir(full_path):
            os.makedirs(full_path)

        # destination
        dest = os.path.join(full_path, "%s.eb" % version)

        try:
            dest_file = open(dest, 'w')
            dest_file.write("# Built with %s on %s\n" % (VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S")))

            # copy file
            for line in open(cfg):
                dest_file.write(line)

            # append a line to the eb file so we don't have git merge conflicts
            if not previous:
                statsprefix = "\n# Build statistics\nbuildstats = ["
                statssuffix = "]\n"
            else:
                # statstemplate = "\nbuildstats.append(%s)\n"
                statsprefix = "\nbuildstats.append("
                statssuffix = ")\n"

            dest_file.write(statsprefix + stats_to_str(stats) + statssuffix)
            dest_file.close()

        except IOError, err:
            self.log.exception("Copying file %s to %s (wc: %s) failed (%s)" % (cfg, dest, self.wc, err))