Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashtag to scrollPhathd #875

Closed
MrGJones opened this issue Apr 9, 2017 · 2 comments
Closed

hashtag to scrollPhathd #875

MrGJones opened this issue Apr 9, 2017 · 2 comments
Labels
Bug This is regarding a bug with the library Duplicate This is a duplicate

Comments

@MrGJones
Copy link

MrGJones commented Apr 9, 2017

hi i have a rpizerow scrolling tweets to a scrollphat hd show here http://forums.pimoroni.com/t/twitter-hashtag-to-scroll-phat/1609

and i keep getting this error, can anyone help with this please? :)

`Traceback (most recent call last):
File "/home/pi/Pimoroni/gScrollPhatHD.py", line 60, in
myStream.filter(track=['hug'], async=False)
File "build/bdist.linux-armv6l/egg/tweepy/streaming.py", line 450, in filter
self._start(async)
File "build/bdist.linux-armv6l/egg/tweepy/streaming.py", line 364, in _start
self._run()
File "build/bdist.linux-armv6l/egg/tweepy/streaming.py", line 297, in _run
six.reraise(*exc_info)
File "build/bdist.linux-armv6l/egg/tweepy/streaming.py", line 266, in _run
self._read_loop(resp)
File "build/bdist.linux-armv6l/egg/tweepy/streaming.py", line 316, in _read_loop
line = buf.read_line().strip()
File "build/bdist.linux-armv6l/egg/tweepy/streaming.py", line 181, in read_line
self._buffer += self._stream.read(self._chunk_size)
File "/usr/lib/python2.7/dist-packages/urllib3/response.py", line 214, in read
raise ProtocolError('Connection broken: %r' % e, e)
ProtocolError: ('Connection broken: IncompleteRead(0 bytes read, 512 more expected)', IncompleteRead(0 bytes read, 512 more expected))

`
#!/usr/bin/env python

import sys
import time
import tweepy
import scrollphathd
from scrollphathd.fonts import font5x7smoothed

scrollphathd.clear()

while True:
try:
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')            
        scrollphathd.write_string(status,font=font5x7smoothed, brightness=0.1)
        status_length = scrollphathd.write_string(status, x=0, y=0,font=font5x7smoothed, brightness=0.1)
        print status
        print 'status length --->',status_length
        while status_length > 0:
                #print 'status length',status_length
                #print 'buffer_len',scrollphathd.write_string(status, x=0, y=0,font=font5x7smoothed, brightness=0.1)
                #scrollphathd.flip(x=True)
                scrollphathd.rotate(degrees=180)
                scrollphathd.show()
                scrollphathd.scroll(1)
                time.sleep(0.01)
                status_length -= 1
        else:
                scrollphathd.scroll(0)
                scrollphathd.clear()
            
    consumer_key =''
    consumer_secret =''

    access_token = ''
    access_token_secret = ''

    #scrollphathd.write_string("Loading Tweets")
    #scrollphathd.scroll()
    #time.sleep(0.1)

    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=['hug'], async=False)

except KeyboardInterrupt:
    scrollphathd.clear()
    sys.exit(-1)

`

@wodim
Copy link

wodim commented May 12, 2017

It clearly says what the error is. The connection to Twitter was broken. Just reconnect.

@Harmon758
Copy link
Member

Duplicate of #237.

For code block usage, see https://help.github.com/articles/creating-and-highlighting-code-blocks/.

@Harmon758 Harmon758 added Bug This is regarding a bug with the library Duplicate This is a duplicate labels Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is regarding a bug with the library Duplicate This is a duplicate
Projects
None yet
Development

No branches or pull requests

3 participants