commit e32bfc67a38791f0aa8ba70869ac268de91da20e Author: James Devine Date: Mon Feb 3 06:48:39 2014 -0800 diff --git a/Robotboothpicture.py b/Robotboothpicture.py new file mode 100644 index 0000000..87a4399 --- /dev/null +++ b/Robotboothpicture.py @@ -0,0 +1,48 @@ +#tweets a picture at you, based on a scanned QR code containing a twitter handle in plaintext. +#use with the ZXing barcode/QR code reader app, needs to be installed to work +#You will also need to unpack tweepy successfully +#finally, this script was written to run on SL4A within Android, rather than in native python. +#ps don't forget to leave the phone plugged in, otherwise it will run out of battery + +import android +import tweepy +import time + + +droid=android.Android() +#droid.wakeLockAcquirePartial() +CONSUMER_KEY = 'yourkeyhere' +CONSUMER_SECRET = 'yoursecrethere' +ACCESS_KEY = 'youraccessthingyhere' +ACCESS_SECRET = 'and the secret access thing here' + +droid.makeToast("Starting Auth") +auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) +droid.makeToast("Starting Authset") +auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) +droid.makeToast("Starting API") +api = tweepy.API(auth) + + +picdir = '/sdcard/pbooth/' +piccount = 1 + +runcontinuous = True + +while (runcontinuous == True): + time.sleep(10) + droid.ttsSpeak("Hello, I'm the robot photo booth! Please show me your QR code") + code = droid.scanBarcode() + scan = code.result + if scan: + droid.ttsSpeak("Smile! Taking picture now.") + time.sleep(2) + pictemp = picdir + str(code[1]['extras']['SCAN_RESULT']) + pictemp = pictemp + '%05i.jpeg' + droid.cameraCapturePicture(pictemp % piccount) + tweet = "@" + code[1]['extras']['SCAN_RESULT'] + " here is your picture. Have a nice day!" + api.status_update_with_media(pictemp % piccount, status=tweet) + droid.ttsSpeak("All finished. Your picture has now been tweeted. Thank you") + time.sleep(5) + piccount += 1 +