Exemplo n.º 1
0
    def process_queries(self, queries):
        # If this is an old Trac version, update the timeline.
        if self.tm.old_trac:
            # Setup the TracTimeline instance
            try:
                self.timeline = TracTimeline.all_timelines.get(
                    base_url=self.tm.get_base_url())
            except TracTimeline.DoesNotExist:
                self.timeline = TracTimeline(base_url=self.tm.get_base_url())
            # Check when the timeline was last updated.
            timeline_age = datetime.datetime.utcnow(
            ) - self.timeline.last_polled
            # Set up timeline URL.
            timeline_url = urlparse.urljoin(
                self.timeline.base_url,
                "timeline?ticket=on&daysback=%d&format=rss" %
                (timeline_age.days + 1))
            # Add the URL to the waiting list
            self.add_url_to_waiting_list(url=timeline_url,
                                         callback=self.handle_timeline_rss)

        # Add all the queries to the waiting list
        for query in queries:
            query_url = query.get_query_url()
            self.add_url_to_waiting_list(url=query_url,
                                         callback=self.handle_query_csv)
            query.last_polled = datetime.datetime.utcnow()
            query.save()

        # URLs are now all prepped, so start pushing them onto the reactor.
        self.push_urls_onto_reactor()
Exemplo n.º 2
0
 def __init__(self, base_url, tracker_name):
     self.tracker_name = tracker_name
     try:
         self.timeline = TracTimeline.all_timelines.get(base_url = base_url)
     except TracTimeline.DoesNotExist:
         self.timeline = TracTimeline(base_url = base_url)
     # Unsure if this is required here, but can't hurt.
     self.timeline.save()