Ciao a tutti, sto sviluppando un'applicazione che invia messaggi su un account twitter. Mi sto servendo della libreria Python Twitter Tools (PTT) sviluppata da Mike Verdone (http://mike.verdone.ca/twitter/). Il problema nasce nel momento in cui tento di inviare un messaggio contenente un'immagine da un client Unix (Centos). Se il tentativo avviene da un client Windows nessun problema. Il messaggio di errore รจ il seguente: BrokenPipeError: [Errno 32] Broken pipe Spero tanto che mi possiate essere d'aiuto.Un grazie in anticipo,RKelly Qui di seguito allego il codice utilizzato: # ============================================================================ # Name : test1.py # Author : RKelly # Version : test1 # Date : 08/31/2014 # Copyright : (c)2014 - RKelly # Description : Procedure for the publication messagges on Twitter # ============================================================================ #!/usr/bin/env python import os.path, time, datetime, json, twitter, urllib.request def send_to_twitter(status): # Account Twitter CONSUMER_KEY = "" CONSUMER_SECRET = "" ACCESS_KEY = "" ACCESS_SECRET = "" # Sezione di autenticazione (tokens e keys) t = twitter.Twitter(auth=twitter.OAuth(ACCESS_KEY, ACCESS_SECRET, CONSUMER_KEY, CONSUMER_SECRET)) # Invia un tweet try: # Send a tweet with an image included (or set your banner or logo similarily) # by just reading your image from the web or a file in a string: with open(status, "rb") as imagefile: params = {"media[]": imagefile.read(), "status": "Test invio immagine..."} outcome = t.statuses.update_with_media(**params) except twitter.TwitterHTTPError as twiterror: print(u'Oops. Error updating status. Status not updated!') except UnicodeEncodeError as twiterror: print(u'Twitter module raised this error:') #print(twiterror) else: print(u'Tweet {0} created at {1}'.format(outcome[u'id_str'], outcome[u'created_at'])) try: print(u'{0}'.format(status)) except UnicodeEncodeError: print(u'(Tried and failed to print the tweet. Weird charmap issue?)') print return outcome return None def polling(): send_to_twitter("image.jpg") #Variabile globale print("waiting... press <CTRL+C> to exit.\n") polling()
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python