Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- from twython import Twython
- from twython import TwythonError
- import os
- client_args = {
- 'proxies': {'http': 'http://proxy.cromptonhouse.org:8000','https': 'https://proxy.cromptonhouse:8080'}}
- CONSUMER_KEY = 'XXXXXXXXXX'
- CONSUMER_SECRET = 'XXXXXXXXXX'
- ACCESS_KEY = 'XXXXXXXXXX'
- ACCESS_SECRET = 'XXXXXXXXXX'
- api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET, client_args=client_args)
- def send_tweet1(temp_value, temp_symbol, light_value, light_symbol, pressure_value, pressure_symbol, volume_value, volume_symbol):
- try:
- photo = open('twitterpicture.jpg','rb')
- api.update_status_with_media(media=photo, status="Temp: {0}{1}. Light Level: {2:.2f} {3}. Pressure: {4:.2f} {5}. Volume: {6:.2f} {7}.".format(temp_value, temp_symbol, light_value, light_symbol, pressure_value, pressure_symbol, volume_value, volume_symbol))
- print "Successfully posted tweet."
- except TwythonError:
- print "Failed to post tweet - duplicate"
- def send_tweet2(temp_value, temp_symbol, light_value, light_symbol, pressure_value, pressure_symbol, volume_value, volume_symbol):
- try:
- api.update_status(status="Temp: {0}{1}. Light Level: {2:.2f} {3}. Pressure: {4:.2f} {5}. Volume: {6:.2f} {7}.".format(temp_value, temp_symbol, light_value, light_symbol, pressure_value, pressure_symbol, volume_value, volume_symbol))
- print "Successfully posted tweet."
- except TwythonError:
- print "Failed to post tweet - duplicate"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement