Skip to content

Instantly share code, notes, and snippets.

@YoSmudge
Created October 29, 2012 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoSmudge/3975608 to your computer and use it in GitHub Desktop.
Save YoSmudge/3975608 to your computer and use it in GitHub Desktop.
from escpos import *
import requests
import sys
import textwrap
from time import sleep
import twitter
p = escpos.Escpos(7344, 3, 0)
devwidth = 31
pad = " "
def printLine():
"""
Print a line across the screen
"""
for i in range(0,devwidth):
sendString('#')
def sendString(s):
p.text(s)
sys.stdout.write(s)
def newLine():
sendString("\n"+pad)
def printString(txt):
wrapped = textwrap.wrap(txt,devwidth)
for line in wrapped:
newLine()
sendString(line)
newLine()
try:
t = twitter.Api(
consumer_key='',
consumer_secret='',
access_token_key='',
access_token_secret=''
)
latestId = 0
newLine()
newLine()
while True:
#Request the twitter API stuff
s = t.GetMentions(since_id=latestId)
s.reverse()
for status in s:
if status.id > latestId:
latestId = status.id
printLine()
printString("Tweet from @{0}".format(status.user.screen_name))
printString("{0}".format(status.text.encode('ascii', 'ignore')))
printLine()
newLine()
newLine()
newLine()
newLine()
sleep(2)
sleep(30)
except KeyboardInterrupt:
print "Shutting down"
p.__del__()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment