Quantcast
Channel: Pimoroni Buccaneers - Latest posts
Viewing all articles
Browse latest Browse all 53830

Twitter #hashtag to scroll pHAT

$
0
0

hi sandy, thanks a lot you've really helped a lot and everything seems to be working great although it seems my code is casuing it to loop the same tweet continually and it doesnt step onto the next ones.. have i missed something?

ive added a print to shell command so i can see the status and it seems static?
it seem to be stuck in the while loop

#!/usr/bin/env python

import time
import tweepy
import scrollphat

scrollphat.set_brightness(2)

class MyStreamListener(tweepy.StreamListener):
    def on_status(self, status):
        if not status.text.startswith('RT'):
            scroll_tweet(status)
    def on_error(self, status_code):
        if status_code == 420:
            return False

def scroll_tweet(status):
    status = '> > > > > >  @%s: %s    ' % (status.user.screen_name.upper(), status.text.upper())
    status = status.encode('ascii', 'ignore').decode('ascii') + '          '
    scrollphat.write_string(status)
    status_length = scrollphat.buffer_len()
    print status
    print
    print status_length
    print
    while scrollphat.buffer_len():
        scrollphat.scroll()
        time.sleep(0.1)
        status_length -= 1

consumer_key =''
consumer_secret =''

access_token = ''
access_token_secret = ''

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener)

myStream.filter(track=['#saintsfc', '@BBCSPort'], async=False)

Viewing all articles
Browse latest Browse all 53830

Trending Articles