Giter VIP home page Giter VIP logo

Comments (5)

thijstriemstra avatar thijstriemstra commented on July 30, 2024

after updating that in my code I

Can you share the code?

I'm still getting so errors.

What errors? what version of python/OS?

from luma.examples.

tiellas avatar tiellas commented on July 30, 2024
from __future__ import unicode_literals

consumer_key = "xx"
consumer_secret = "xx"
access_token = "xx"
access_token_secret = "xx"

search_terms = ['bladee']

import sys
import time
from pathlib import Path
from PIL import ImageFont

try:
    from Queue import Queue
except ImportError:
    from queue import Queue

from demo_opts import get_device
from luma.core.render import canvas
from luma.core.virtual import viewport


try:
    import tweepy
except ImportError:
    print("The tweepy library was not found. Run 'sudo -H pip install tweepy' to install it.")
    sys.exit()


def make_font(name, size):
    font_path = str(Path(__file__).resolve().parent.joinpath('fonts', name))
    return ImageFont.truetype(font_path, size)


def scroll_message(status, font=None, speed=1):
    author = u"@{0}".format(status.author.screen_name)
    full_text = u"{0}  {1}".format(author, status.text).replace("\n", " ")
    x = device.width

    # First measure the text size
    with canvas(device) as draw:
        w, h = draw.textsize(full_text, font)

    virtual = viewport(device, width=max(device.width, w + x + x), height=max(h, device.height))
    with canvas(virtual) as draw:
        draw.text((x, 0), full_text, font=font, fill="white")
        draw.text((x, 0), author, font=font, fill="yellow")

    i = 0
    while i < x + w:
        virtual.set_position((i, 0))
        i += speed
        time.sleep(0.025)


class listener(tweepy.Stream):

    def __init__(self, queue):
        super(listener, self).__init__()
        self.queue = queue

    def on_status(self, status):
        self.queue.put(status)


device = get_device()
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
queue = Queue()

if device.height >= 16:
    font = make_font("code2000.ttf", 12)
else:
    font = make_font("pixelmix.ttf", 8)

try:
    stream = tweepy.Stream(auth=api.auth, listener=listener(queue))
    stream.filter(track=search_terms, is_async=True)  # noqa: W606

    try:
        while True:
            status = queue.get()
            scroll_message(status, font=font)
    except KeyboardInterrupt:
        pass

finally:
    stream.disconnect()

### This is the full code^^^

Traceback (most recent call last):
  File "/home/tiellas/luma.examples/examples/tweet_scroll.py", line 108, in <module>
    stream = tweepy.Stream(auth=api.auth, listener=listener(queue))
  File "/home/tiellas/luma.examples/examples/tweet_scroll.py", line 89, in __init__
    super(listener, self).__init__()
TypeError: __init__() missing 4 required positional arguments: 'consumer_key', 'consumer_secret', 'access_token', and 'access_token_secret

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tiellas/luma.examples/examples/tweet_scroll.py", line 119, in <module>
    stream.disconnect()
NameError: name 'stream' is not defined`

This is the error^^

from luma.examples.

tiellas avatar tiellas commented on July 30, 2024

Sorry it formatted weird, im not proficient on here. But the code is the entire top section until "this is the code^^" and the error is the whole section beneath it

from luma.examples.

thijstriemstra avatar thijstriemstra commented on July 30, 2024

Sorry it formatted weird, im not proficient on here.

I'll fix that..

from luma.examples.

tiellas avatar tiellas commented on July 30, 2024

Sorry it formatted weird, im not proficient on here.

I'll fix that..

Great thanks, I noticed on mobile GitHub app the comment formatted fine. And I am using python3 on default raspberry pi OS (aka raspian bullseye I belive)

from luma.examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.