Advertisement
Guest User

Untitled

a guest
Feb 12th, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import sys
  3. from twython import Twython
  4. from twython import TwythonError
  5. import os
  6.  
  7. client_args = {
  8. 'proxies': {'http': 'http://proxy.cromptonhouse.org:8000','https': 'https://proxy.cromptonhouse:8080'}}
  9.  
  10. CONSUMER_KEY = 'XXXXXXXXXX'
  11. CONSUMER_SECRET = 'XXXXXXXXXX'
  12. ACCESS_KEY = 'XXXXXXXXXX'
  13. ACCESS_SECRET = 'XXXXXXXXXX'
  14.  
  15.  
  16. api = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET, client_args=client_args)
  17.  
  18.  
  19. def send_tweet1(temp_value, temp_symbol, light_value, light_symbol, pressure_value, pressure_symbol, volume_value, volume_symbol):
  20. try:
  21. photo = open('twitterpicture.jpg','rb')
  22. 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))
  23. print "Successfully posted tweet."
  24. except TwythonError:
  25. print "Failed to post tweet - duplicate"
  26.  
  27.  
  28. def send_tweet2(temp_value, temp_symbol, light_value, light_symbol, pressure_value, pressure_symbol, volume_value, volume_symbol):
  29. try:
  30. 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))
  31. print "Successfully posted tweet."
  32. except TwythonError:
  33. print "Failed to post tweet - duplicate"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement