comparison frontends/src/jp/cmd_file.py @ 2516:842bd1594077

jp (file/send): --name can now be specified
author Goffi <goffi@goffi.org>
date Wed, 14 Mar 2018 07:57:04 +0100
parents 8e770ac05b0c
children
comparison
equal deleted inserted replaced
2515:00480cf83fa1 2516:842bd1594077
45 self.parser.add_argument("files", type=str, nargs='+', metavar='file', help=_(u"a list of file")) 45 self.parser.add_argument("files", type=str, nargs='+', metavar='file', help=_(u"a list of file"))
46 self.parser.add_argument("jid", type=base.unicode_decoder, help=_(u"the destination jid")) 46 self.parser.add_argument("jid", type=base.unicode_decoder, help=_(u"the destination jid"))
47 self.parser.add_argument("-b", "--bz2", action="store_true", help=_(u"make a bzip2 tarball")) 47 self.parser.add_argument("-b", "--bz2", action="store_true", help=_(u"make a bzip2 tarball"))
48 self.parser.add_argument("-d", "--path", type=base.unicode_decoder, help=(u"path to the directory where the file must be stored")) 48 self.parser.add_argument("-d", "--path", type=base.unicode_decoder, help=(u"path to the directory where the file must be stored"))
49 self.parser.add_argument("-N", "--namespace", type=base.unicode_decoder, help=(u"namespace of the file")) 49 self.parser.add_argument("-N", "--namespace", type=base.unicode_decoder, help=(u"namespace of the file"))
50 self.parser.add_argument("-n", "--name", type=base.unicode_decoder, default=u'', help=(u"name to use (DEFAULT: use source file name)"))
50 51
51 def start(self): 52 def start(self):
52 """Send files to jabber contact""" 53 """Send files to jabber contact"""
53 self.send_files() 54 self.send_files()
54 55
112 self.disp(_(u"Adding {}").format(file_), 1) 113 self.disp(_(u"Adding {}").format(file_), 1)
113 bz2.add(file_) 114 bz2.add(file_)
114 bz2.close() 115 bz2.close()
115 self.disp(_(u"Done !"), 1) 116 self.disp(_(u"Done !"), 1)
116 117
117 self.host.bridge.fileSend(self.full_dest_jid, buf.name, archive_name, '', extra, self.profile, callback=lambda pid, file_=buf.name: self.gotId(pid, file_), errback=self.error) 118 self.host.bridge.fileSend(self.full_dest_jid, buf.name, self.args.name or archive_name, '', extra, self.profile,
119 callback=lambda pid, file_=buf.name: self.gotId(pid, file_), errback=self.error)
118 else: 120 else:
119 for file_ in self.args.files: 121 for file_ in self.args.files:
120 path = os.path.abspath(file_) 122 path = os.path.abspath(file_)
121 self.host.bridge.fileSend(self.full_dest_jid, path, '', '', extra, self.profile, callback=lambda pid, file_=file_: self.gotId(pid, file_), errback=self.error) 123 self.host.bridge.fileSend(self.full_dest_jid, path, self.args.name, '', extra, self.profile,
124 callback=lambda pid, file_=file_: self.gotId(pid, file_), errback=self.error)
122 125
123 126
124 class Request(base.CommandBase): 127 class Request(base.CommandBase):
125 128
126 def __init__(self, host): 129 def __init__(self, host):