Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0054.py @ 765:787ee59dba9c
plugins radiocol, xep-0054: better handling of upload errors:
- radiocolSongAdded is now asynchronous
- _buildAvatar return a Failure if the image is not readable
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 17 Dec 2013 18:44:53 +0100 |
parents | 99eee75ec1b7 |
children | bfabeedbf32e |
comparison
equal
deleted
inserted
replaced
764:d0e809014ea2 | 765:787ee59dba9c |
---|---|
21 from twisted.internet import threads | 21 from twisted.internet import threads |
22 from twisted.internet.defer import inlineCallbacks, returnValue | 22 from twisted.internet.defer import inlineCallbacks, returnValue |
23 from twisted.words.protocols.jabber import jid | 23 from twisted.words.protocols.jabber import jid |
24 from twisted.words.protocols.jabber.xmlstream import IQ | 24 from twisted.words.protocols.jabber.xmlstream import IQ |
25 from twisted.words.xish import domish | 25 from twisted.words.xish import domish |
26 from twisted.python.failure import Failure | |
26 import os.path | 27 import os.path |
27 | 28 |
28 from zope.interface import implements | 29 from zope.interface import implements |
29 | 30 |
30 from wokkel import disco, iwokkel | 31 from wokkel import disco, iwokkel |
234 | 235 |
235 def _buildSetAvatar(self, vcard_set, filepath): | 236 def _buildSetAvatar(self, vcard_set, filepath): |
236 try: | 237 try: |
237 img = Image.open(filepath) | 238 img = Image.open(filepath) |
238 except IOError: | 239 except IOError: |
239 raise exceptions.DataError("Can't open image") | 240 return Failure(exceptions.DataError("Can't open image")) |
240 | 241 |
241 if img.size != (64, 64): | 242 if img.size != (64, 64): |
242 img = img.resize((64, 64)) | 243 img = img.resize((64, 64)) |
243 img_buf = StringIO() | 244 img_buf = StringIO() |
244 img.save(img_buf, 'PNG') | 245 img.save(img_buf, 'PNG') |