Пример #1
0
    def expand_build_context(build_context, unexpanded_id, file_step,
            past=0):
        """Expands out the build_contexts and returns a dict of the form
        {
                "expanded_id": expanded_build_contex,
                "expanded_id": expanded_build_context,
                ...
        }
        """
        # Handle bgpdumps (glob target with time_step: null)
        if file_step is None:
            return {unexpanded_id: {}}

        start_time = build_context["start_time"]
        end_time = build_context.get("end_time") or start_time

        start_time = util.floor_timestamp_given_time_step(
                start_time, file_step)
        end_time = util.floor_timestamp_given_time_step(
                end_time, file_step)

        end_inclusive = False
        if end_time == start_time:
            end_inclusive = True

        if past:
            file_step_delta = util.convert_to_timedelta(file_step)
            start_time = start_time - past*file_step_delta

        timestamps = util.BuilderArrowFactory.range(
                file_step,
                start_time,
                end_time,
                end_inclusive=end_inclusive)

        new_build_context = copy.copy(build_context)
        new_build_context.pop("force", None)
        expanded_dict = {}
        for timestamp in timestamps:
            expanded_id = timestamp.strftime(unexpanded_id)

            time_delta = util.convert_to_timedelta(file_step)
            new_build_context["start_time"] = timestamp
            new_build_context["end_time"] = timestamp + time_delta
            expanded_dict[expanded_id] = copy.copy(new_build_context)
        return expanded_dict
Пример #2
0
    def expand_build_context(build_context, unexpanded_id, file_step, past=0):
        """Expands out the build_contexts and returns a dict of the form
        {
                "expanded_id": expanded_build_contex,
                "expanded_id": expanded_build_context,
                ...
        }
        """
        # Handle bgpdumps (glob target with time_step: null)
        if file_step is None:
            return {unexpanded_id: {}}

        start_time = build_context["start_time"]
        end_time = build_context.get("end_time") or start_time

        start_time = util.floor_timestamp_given_time_step(
            start_time, file_step)
        end_time = util.floor_timestamp_given_time_step(end_time, file_step)

        end_inclusive = False
        if end_time == start_time:
            end_inclusive = True

        if past:
            file_step_delta = util.convert_to_timedelta(file_step)
            start_time = start_time - past * file_step_delta

        timestamps = util.BuilderArrowFactory.range(
            file_step, start_time, end_time, end_inclusive=end_inclusive)

        new_build_context = copy.copy(build_context)
        new_build_context.pop("force", None)
        expanded_dict = {}
        for timestamp in timestamps:
            expanded_id = timestamp.strftime(unexpanded_id)

            time_delta = util.convert_to_timedelta(file_step)
            new_build_context["start_time"] = timestamp
            new_build_context["end_time"] = timestamp + time_delta
            expanded_dict[expanded_id] = copy.copy(new_build_context)
        return expanded_dict
Пример #3
0
    def past_cache_time(self):
        """Returns true if the job is past it's cache time

        This implementation returns true if the oldest mtime is older than
        the cache_time or if non of the targets exist
        """
        cache_time = self.cache_time
        if cache_time is None:
            return True
        cache_delta = convert_to_timedelta(cache_time)
        current_time = arrow.get()
        for target_edge in self.build_graph.out_edges(self.unique_id, data=True):
            if target_edge[2]["kind"] == "produces":
                target = self.build_graph.node[target_edge[1]]["object"]
                if not target.get_exists():
                    return True
                elif arrow.get(target.get_mtime()) + cache_delta < current_time:
                    return True
        return False
Пример #4
0
 def past_curfew(self):
     time_delta = convert_to_timedelta(self.curfew)
     end_time = self.build_context["end_time"]
     curfew_time = end_time + time_delta
     return curfew_time < arrow.get()