[boobmsg] Photos command
This commit is contained in:
parent
5b508ca340
commit
36b66e9238
1 changed files with 37 additions and 1 deletions
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
from weboob.core import CallErrors
|
from weboob.core import CallErrors
|
||||||
from weboob.capabilities.messages import ICapMessages, Message, Thread
|
from weboob.capabilities.messages import ICapMessages, Message, Thread
|
||||||
|
|
@ -205,7 +207,6 @@ class ProfileFormatter(IFormatter):
|
||||||
result += u'\t%s\n' % s
|
result += u'\t%s\n' % s
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Boobmsg(ReplApplication):
|
class Boobmsg(ReplApplication):
|
||||||
APPNAME = 'boobmsg'
|
APPNAME = 'boobmsg'
|
||||||
VERSION = '0.c'
|
VERSION = '0.c'
|
||||||
|
|
@ -236,6 +237,10 @@ class Boobmsg(ReplApplication):
|
||||||
def load_default_backends(self):
|
def load_default_backends(self):
|
||||||
self.load_backends(ICapMessages, storage=self.create_storage())
|
self.load_backends(ICapMessages, storage=self.create_storage())
|
||||||
|
|
||||||
|
def main(self, argv):
|
||||||
|
self.load_config()
|
||||||
|
return ReplApplication.main(self, argv)
|
||||||
|
|
||||||
def do_status(self, line):
|
def do_status(self, line):
|
||||||
"""
|
"""
|
||||||
status
|
status
|
||||||
|
|
@ -427,3 +432,34 @@ class Boobmsg(ReplApplication):
|
||||||
self.logger.error(u'Profile not found')
|
self.logger.error(u'Profile not found')
|
||||||
else:
|
else:
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
|
def do_photos(self, id):
|
||||||
|
"""
|
||||||
|
profile ID
|
||||||
|
|
||||||
|
Display photos of a profile
|
||||||
|
"""
|
||||||
|
photo_cmd = self.config.get('photo_viewer')
|
||||||
|
if photo_cmd is None:
|
||||||
|
print >>sys.stderr, "Configuration error: photo_viewer is undefined"
|
||||||
|
return
|
||||||
|
|
||||||
|
_id, backend_name = self.parse_id(id, unique_backend=True)
|
||||||
|
|
||||||
|
found = 0
|
||||||
|
for backend, contact in self.do('get_contact', _id, backends=backend_name):
|
||||||
|
if contact:
|
||||||
|
# Write photo to temporary files
|
||||||
|
tmp_files = []
|
||||||
|
for photo in contact.photos.values():
|
||||||
|
f = NamedTemporaryFile(suffix='.jpg')
|
||||||
|
photo = backend.fillobj(photo, 'data')
|
||||||
|
f.write(photo.data)
|
||||||
|
tmp_files.append(f)
|
||||||
|
os.system(photo_cmd % ' '.join([file.name for file in tmp_files]))
|
||||||
|
found = 1
|
||||||
|
|
||||||
|
if not found:
|
||||||
|
self.logger.error(u'Profile not found')
|
||||||
|
else:
|
||||||
|
self.flush()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue