Exemplo n.º 1
0
    def run(self):
        statuses = []
        last_tweet = None

        # Get the root tweet
        try:
            with self.api.lock:
                last_tweet = self.api.GetStatus(self.root_tweet_id)
            statuses.append(last_tweet)
        except (HTTPError, URLError):
            statuses = None
            last_tweet = None

        # get tweets in a loop, until there is no in_reply_to_status_id
        while last_tweet and last_tweet.in_reply_to_status_id:
            try:
                with self.api.lock:
                    last_tweet = self.api.GetStatus(last_tweet.in_reply_to_status_id)
                statuses.append(last_tweet)
            except (HTTPError, URLError):
                last_tweet = None
        
        # In case we've never seen some of these users, grab their profile images and cache them
        for status in statuses:
            usercache.add_to_av_cache(status.user)
            usercache.add_to_name_cache(status.user)

        statuses.reverse()

        gtk.gdk.threads_enter()
        try:
            self.pane.update_window(statuses)
        finally:
            gtk.gdk.threads_leave()
Exemplo n.º 2
0
    def run(self):
        try:
            # username/Home entries need to load the appropriate Home feed
            if self.list_name == self.username + '/Home':
                with self.api.lock:
                    statuses = self.api.GetHomeTimeline(count=self.num_entries)

            # For @username, check if it is one of our usernames, or
            # just needs to be searched on
            elif self.list_name == '@' + self.username:
                with self.api.lock:
                    statuses = self.api.GetMentions(count=self.num_entries)
            elif re.match('@', self.list_name):
                with self.api.lock:
                    results = self.api.Search(self.list_name, rpp=self.num_entries)
                statuses = results_to_statuses(results, self.api)

            # Direct Messages should match like /Home, above
            elif self.list_name == self.username + '/Direct Messages':
                with self.api.lock:
                    dms = self.api.GetDirectMessages()
                statuses = dms_to_statuses(dms)
                
            # User lookups go straight to the user
            elif re.match(r'user: '******'^user: '******'', self.list_name), count=self.num_entries)

            # Lists load the appropriate list from the appropriate account
            elif re.match(r'list: ', self.list_name):
                real_list = re.sub(r'list: .*/(.*)', r'\1', self.list_name)
                with self.api.lock:
                    statuses = self.api.GetListStatuses(real_list, per_page=self.num_entries)

            # Everything else is a straight search
            else:
                with self.api.lock:
                    results = self.api.Search(self.list_name, rpp=self.num_entries)
                statuses = results_to_statuses(results, self.api)

        except (HTTPError, URLError):
            statuses = None

        # For each user id present, populate the UserCaches
        if statuses:
            for status in statuses:
                usercache.add_to_av_cache(status.user)
                usercache.add_to_name_cache(status.user, self.api)

        gtk.gdk.threads_enter()
        try:
            self.pane.update_window(statuses)
        finally:
            gtk.gdk.threads_leave()
Exemplo n.º 3
0
    def run(self):
        screen_name = re.sub('user: '******'', self.user)

        try:
            with self.api.lock:
                user = self.api.GetUser(screen_name)
            usercache.add_to_av_cache(user)
            usercache.add_to_name_cache(user)
        except (HTTPError, URLError):
            verified = False
            user = None

        gtk.gdk.threads_enter()
        try:
            self.pane.user_box.update_info(user)
        finally:
            gtk.gdk.threads_leave()
Exemplo n.º 4
0
    def run(self):
        statuses = []
        with self.api.lock:
            try:
                statuses.append(self.api.GetStatus(self.single_tweet))
            except (HTTPError, URLError):
                statuses = None

        # In case we've never seen this user, grab their profile image
        for status in statuses:
            usercache.add_to_av_cache(status.user)
            usercache.add_to_name_cache(status.user)

        gtk.gdk.threads_enter()
        try:
            self.pane.update_window(statuses)
        finally:
            gtk.gdk.threads_leave()