jp (file/invite): added a --thumbnail argument

This commit is contained in:
Goffi 2019-05-03 13:05:47 +02:00
commit bf9284cf06

View file

@ -24,6 +24,7 @@ import os
import os.path
import tarfile
from sat.core.i18n import _
from sat.tools.common import data_format
from sat_frontends.jp.constants import Const as C
from sat_frontends.jp import common
from sat_frontends.tools import jid
@ -736,6 +737,12 @@ class ShareInvite(base.CommandBase):
default=u"files",
help=_(u"type of the repository"),
)
self.parser.add_argument(
"-T",
"--thumbnail",
type=base.unicode_decoder,
help=_(u"https URL of a image to use as thumbnail"),
)
self.parser.add_argument(
"service",
type=base.unicode_decoder,
@ -754,7 +761,13 @@ class ShareInvite(base.CommandBase):
self.host.quit()
def start(self):
self.path = os.path.abspath(self.args.path) if self.args.path else u""
self.path = os.path.normpath(self.args.path) if self.args.path else u""
extra = {}
if self.args.thumbnail is not None:
if not self.args.thumbnail.startswith(u'http'):
self.parser.error(_(u"only http(s) links are allowed with --thumbnail"))
else:
extra[u'thumb_url'] = self.args.thumbnail
self.host.bridge.FISInvite(
self.args.jid,
self.args.service,
@ -762,6 +775,7 @@ class ShareInvite(base.CommandBase):
self.args.namespace,
self.path,
self.args.name,
data_format.serialise(extra),
self.profile,
callback=self._FISInviteCb,
errback=partial(