Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_file.py @ 2932:472fadadefe6
jp (file/invite): added a --thumbnail argument
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 03 May 2019 13:05:47 +0200 |
parents | 0b9faea5cb58 |
children | 18a98a541f7a |
comparison
equal
deleted
inserted
replaced
2931:b256e90612d0 | 2932:472fadadefe6 |
---|---|
22 import sys | 22 import sys |
23 import os | 23 import os |
24 import os.path | 24 import os.path |
25 import tarfile | 25 import tarfile |
26 from sat.core.i18n import _ | 26 from sat.core.i18n import _ |
27 from sat.tools.common import data_format | |
27 from sat_frontends.jp.constants import Const as C | 28 from sat_frontends.jp.constants import Const as C |
28 from sat_frontends.jp import common | 29 from sat_frontends.jp import common |
29 from sat_frontends.tools import jid | 30 from sat_frontends.tools import jid |
30 from sat.tools.common.ansi import ANSI as A | 31 from sat.tools.common.ansi import ANSI as A |
31 import tempfile | 32 import tempfile |
735 choices=[u"files", u"photos"], | 736 choices=[u"files", u"photos"], |
736 default=u"files", | 737 default=u"files", |
737 help=_(u"type of the repository"), | 738 help=_(u"type of the repository"), |
738 ) | 739 ) |
739 self.parser.add_argument( | 740 self.parser.add_argument( |
741 "-T", | |
742 "--thumbnail", | |
743 type=base.unicode_decoder, | |
744 help=_(u"https URL of a image to use as thumbnail"), | |
745 ) | |
746 self.parser.add_argument( | |
740 "service", | 747 "service", |
741 type=base.unicode_decoder, | 748 type=base.unicode_decoder, |
742 help=_(u"jid of the file sharing service hosting the repository"), | 749 help=_(u"jid of the file sharing service hosting the repository"), |
743 ) | 750 ) |
744 self.parser.add_argument( | 751 self.parser.add_argument( |
752 _(u'invitation sent do {entity}').format(entity=self.args.jid) | 759 _(u'invitation sent do {entity}').format(entity=self.args.jid) |
753 ) | 760 ) |
754 self.host.quit() | 761 self.host.quit() |
755 | 762 |
756 def start(self): | 763 def start(self): |
757 self.path = os.path.abspath(self.args.path) if self.args.path else u"" | 764 self.path = os.path.normpath(self.args.path) if self.args.path else u"" |
765 extra = {} | |
766 if self.args.thumbnail is not None: | |
767 if not self.args.thumbnail.startswith(u'http'): | |
768 self.parser.error(_(u"only http(s) links are allowed with --thumbnail")) | |
769 else: | |
770 extra[u'thumb_url'] = self.args.thumbnail | |
758 self.host.bridge.FISInvite( | 771 self.host.bridge.FISInvite( |
759 self.args.jid, | 772 self.args.jid, |
760 self.args.service, | 773 self.args.service, |
761 self.args.type, | 774 self.args.type, |
762 self.args.namespace, | 775 self.args.namespace, |
763 self.path, | 776 self.path, |
764 self.args.name, | 777 self.args.name, |
778 data_format.serialise(extra), | |
765 self.profile, | 779 self.profile, |
766 callback=self._FISInviteCb, | 780 callback=self._FISInviteCb, |
767 errback=partial( | 781 errback=partial( |
768 self.errback, | 782 self.errback, |
769 msg=_(u"can't send invitation: {}"), | 783 msg=_(u"can't send invitation: {}"), |