comparison sat_frontends/jp/cmd_file.py @ 2916:0b9faea5cb58

jp (file/share): added invite command to invite an entity to a file sharing repository
author Goffi <goffi@goffi.org>
date Sun, 14 Apr 2019 08:21:51 +0200
parents 003b8b4b56a7
children 472fadadefe6
comparison
equal deleted inserted replaced
2915:d1fcb8e9aced 2916:0b9faea5cb58
699 exit_code=C.EXIT_BRIDGE_ERRBACK, 699 exit_code=C.EXIT_BRIDGE_ERRBACK,
700 ), 700 ),
701 ) 701 )
702 702
703 703
704 class ShareInvite(base.CommandBase):
705 def __init__(self, host):
706 super(ShareInvite, self).__init__(
707 host, "invite", help=_(u"send invitation for a shared repository")
708 )
709 self.need_loop = True
710
711 def add_parser_options(self):
712 self.parser.add_argument(
713 "-n",
714 "--name",
715 type=base.unicode_decoder,
716 default=u"",
717 help=_(u"name of the repository"),
718 )
719 self.parser.add_argument(
720 "-N",
721 "--namespace",
722 type=base.unicode_decoder,
723 default=u"",
724 help=_(u"namespace of the repository"),
725 )
726 self.parser.add_argument(
727 "-P",
728 "--path",
729 type=base.unicode_decoder,
730 help=_(u"path to the repository"),
731 )
732 self.parser.add_argument(
733 "-t",
734 "--type",
735 choices=[u"files", u"photos"],
736 default=u"files",
737 help=_(u"type of the repository"),
738 )
739 self.parser.add_argument(
740 "service",
741 type=base.unicode_decoder,
742 help=_(u"jid of the file sharing service hosting the repository"),
743 )
744 self.parser.add_argument(
745 "jid",
746 type=base.unicode_decoder,
747 help=_(u"jid of the person to invite"),
748 )
749
750 def _FISInviteCb(self):
751 self.disp(
752 _(u'invitation sent do {entity}').format(entity=self.args.jid)
753 )
754 self.host.quit()
755
756 def start(self):
757 self.path = os.path.abspath(self.args.path) if self.args.path else u""
758 self.host.bridge.FISInvite(
759 self.args.jid,
760 self.args.service,
761 self.args.type,
762 self.args.namespace,
763 self.path,
764 self.args.name,
765 self.profile,
766 callback=self._FISInviteCb,
767 errback=partial(
768 self.errback,
769 msg=_(u"can't send invitation: {}"),
770 exit_code=C.EXIT_BRIDGE_ERRBACK,
771 ),
772 )
773
774
704 class Share(base.CommandBase): 775 class Share(base.CommandBase):
705 subcommands = (ShareList, SharePath) 776 subcommands = (ShareList, SharePath, ShareInvite)
706 777
707 def __init__(self, host): 778 def __init__(self, host):
708 super(Share, self).__init__( 779 super(Share, self).__init__(
709 host, "share", use_profile=False, help=_(u"files sharing management") 780 host, "share", use_profile=False, help=_(u"files sharing management")
710 ) 781 )