Пример #1
0
def post():
    """When ready, this method will post contributions from users that
    choosen to use our internal message service instead of twitter,
    identica or whatever."""
    audience = request.values.get('aid')
    newbuzz = Buzz(
        owner_nick=auth.authenticated_user().display_name,
        owner_avatar=u'',
        user=auth.authenticated_user(),
        content=request.values.get('message')[:300],
        type_=get_or_create(BuzzType, name=u'site')[0])
    newbuzz.audience_id = audience
    session.commit()
    return msg.ok(_('Notice posted successfuly. Please wait a few while '
                    'your message is approved.'))
Пример #2
0
def post():
    """When ready, this method will post contributions from users that
    choosen to use our internal message service instead of twitter,
    identica or whatever."""
    audience = request.values.get('aid')
    newbuzz = Buzz(owner_nick=auth.authenticated_user().display_name,
                   owner_avatar=u'',
                   user=auth.authenticated_user(),
                   content=request.values.get('message')[:300],
                   type_=get_or_create(BuzzType, name=u'site')[0])
    newbuzz.audience_id = audience
    session.commit()
    return msg.ok(
        _('Notice posted successfuly. Please wait a few while '
          'your message is approved.'))
Пример #3
0
    def process(self):
        """Here's the place that we actually call the stream API and
        capture found tweets.

        Each time we receive a new tweet, we create a `Buzz' instance
        with it's owner and content info and then yield it to the
        caller. None is saved to the database here.
        """
        print 'processing %s, %s' % (self.profileids, self.hashtags)
        try:
            stream = FilterStream(conf.TWITTER_STREAM_USERNAME,
                                  conf.TWITTER_STREAM_PASSWORD,
                                  follow=self.profileids,
                                  track=self.hashtags)

            for tweet in stream:
                # We're creating a new entry in our buzz entity for each
                # tweet received. We are also setting this buzz as a
                # twitter one and yielding it to the caller that will be
                # the responsible for saving it in the database.
                if tweet.has_key('user'):
                    type_ = get_or_create(BuzzType, name=u'twitter')[0]
                    buzz = Buzz(
                        owner_nick=tweet['user']['screen_name'],
                        owner_avatar=tweet['user']['profile_image_url'],
                        content=tweet['text'],
                        type_=type_)
                    yield buzz

        except (ConnectionError, HTTPError), exc:
            # Something got screwed, let's try some seconds late.
            # FIXME: We really should limit the number of tries here and
            # warning the sysadmin that something is wrong.
            name = exc.__class__.__name__
            print 'Crawler::%s trying again soon...' % name
            sleep(30)
            self.process()
Пример #4
0
    def process(self):
        """Here's the place that we actually call the stream API and
        capture found tweets.

        Each time we receive a new tweet, we create a `Buzz' instance
        with it's owner and content info and then yield it to the
        caller. None is saved to the database here.
        """
        print 'processing %s, %s' % (self.profileids, self.hashtags)
        try:
            stream = FilterStream(
                conf.TWITTER_STREAM_USERNAME,
                conf.TWITTER_STREAM_PASSWORD,
                follow=self.profileids, track=self.hashtags)

            for tweet in stream:
                # We're creating a new entry in our buzz entity for each
                # tweet received. We are also setting this buzz as a
                # twitter one and yielding it to the caller that will be
                # the responsible for saving it in the database.
                if tweet.has_key('user'):
                    type_ = get_or_create(BuzzType, name=u'twitter')[0]
                    buzz = Buzz(
                        owner_nick=tweet['user']['screen_name'],
                        owner_avatar=tweet['user']['profile_image_url'],
                        content=tweet['text'],
                        type_=type_)
                    yield buzz

        except (ConnectionError, HTTPError), exc:
            # Something got screwed, let's try some seconds late.
            # FIXME: We really should limit the number of tries here and
            # warning the sysadmin that something is wrong.
            name = exc.__class__.__name__
            print 'Crawler::%s trying again soon...' % name
            sleep(30)
            self.process()