annotate frontends/src/jp/jp @ 627:d207c2186519

core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised: - new BridgeInitError and BridgeExceptionNoService are in core.exceptions - D-Bus NotSupported is catched in bridge, and launch a BridgeInitError - BridgeInitError stop SàT core, jp, and quick_frontends with an explanation message. fix bug 27
author Goffi <goffi@goffi.org>
date Fri, 21 Jun 2013 02:00:37 +0200
parents 0730fc83ef51
children 09bbd5c00244
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
goffi@necton2
parents:
diff changeset
1 #! /usr/bin/python
goffi@necton2
parents:
diff changeset
2 # -*- coding: utf-8 -*-
goffi@necton2
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
4 # jp: a SAT command line tool
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
10 # (at your option) any later version.
0
goffi@necton2
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
15 # GNU Affero General Public License for more details.
0
goffi@necton2
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 601
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0
goffi@necton2
parents:
diff changeset
19
402
f03688bdb858 jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents: 401
diff changeset
20 from __future__ import with_statement
f03688bdb858 jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents: 401
diff changeset
21
0
goffi@necton2
parents:
diff changeset
22 #consts
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 165
diff changeset
23 name = u"jp"
459
cf005701624b copyleft date update
Goffi <goffi@goffi.org>
parents: 402
diff changeset
24 about = name+u""" v%s (c) Jérôme Poisson (aka Goffi) 2009, 2010, 2011, 2012
0
goffi@necton2
parents:
diff changeset
25
goffi@necton2
parents:
diff changeset
26 ---
572
ca13633d3b6b dates update
Goffi <goffi@goffi.org>
parents: 542
diff changeset
27 """+name+u""" Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (aka Goffi)
0
goffi@necton2
parents:
diff changeset
28 This program comes with ABSOLUTELY NO WARRANTY;
goffi@necton2
parents:
diff changeset
29 This is free software, and you are welcome to redistribute it
goffi@necton2
parents:
diff changeset
30 under certain conditions.
goffi@necton2
parents:
diff changeset
31 ---
goffi@necton2
parents:
diff changeset
32
goffi@necton2
parents:
diff changeset
33 This software is a command line tool for jabber
goffi@necton2
parents:
diff changeset
34 Get the latest version at http://www.goffi.org
goffi@necton2
parents:
diff changeset
35 """
goffi@necton2
parents:
diff changeset
36
goffi@necton2
parents:
diff changeset
37 global pbar_available
goffi@necton2
parents:
diff changeset
38 pbar_available = True #checked before using ProgressBar
goffi@necton2
parents:
diff changeset
39
goffi@necton2
parents:
diff changeset
40 ### logging ###
goffi@necton2
parents:
diff changeset
41 import logging
goffi@necton2
parents:
diff changeset
42 from logging import debug, info, error, warning
goffi@necton2
parents:
diff changeset
43 logging.basicConfig(level=logging.DEBUG,
goffi@necton2
parents:
diff changeset
44 format='%(message)s')
goffi@necton2
parents:
diff changeset
45 ###
goffi@necton2
parents:
diff changeset
46
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
47 import gettext
613
0730fc83ef51 quick frontend, jp: fix locales
Thomas Preud'homme <robotux@celest.fr>
parents: 609
diff changeset
48 gettext.install('jp', unicode=True)
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
49
0
goffi@necton2
parents:
diff changeset
50 import sys
goffi@necton2
parents:
diff changeset
51 import os
goffi@necton2
parents:
diff changeset
52 from os.path import abspath, basename, dirname
goffi@necton2
parents:
diff changeset
53 from optparse import OptionParser
236
7cf093e138b6 jp: fixed bad sat.tools.jid import
Goffi <goffi@goffi.org>
parents: 228
diff changeset
54 from sat.tools.jid import JID
0
goffi@necton2
parents:
diff changeset
55 import gobject
627
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
56 from sat_frontends.bridge.DBus import DBusBridgeFrontend
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
57 from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError
601
a4f6f78f0620 jp, core: jp's clean_ustr moved to a new general utils module
Goffi <goffi@goffi.org>
parents: 588
diff changeset
58 from sat.tools.utils import clean_ustr
0
goffi@necton2
parents:
diff changeset
59 import tarfile
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
60 import tempfile
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
61 import shutil
0
goffi@necton2
parents:
diff changeset
62 try:
goffi@necton2
parents:
diff changeset
63 from progressbar import ProgressBar, Percentage, Bar, ETA, FileTransferSpeed
goffi@necton2
parents:
diff changeset
64 except ImportError, e:
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
65 info (_('ProgressBar not available, please download it at http://pypi.python.org/pypi/progressbar'))
Goffi <goffi@goffi.org>
parents: 57
diff changeset
66 info (_('Progress bar deactivated\n--\n'))
0
goffi@necton2
parents:
diff changeset
67 pbar_available=False
goffi@necton2
parents:
diff changeset
68
goffi@necton2
parents:
diff changeset
69
goffi@necton2
parents:
diff changeset
70
goffi@necton2
parents:
diff changeset
71
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
72 class JP(object):
0
goffi@necton2
parents:
diff changeset
73 def __init__(self):
165
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 156
diff changeset
74 try:
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 156
diff changeset
75 self.bridge=DBusBridgeFrontend()
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 156
diff changeset
76 except BridgeExceptionNoService:
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 156
diff changeset
77 print(_(u"Can't connect to SàT backend, are you sure it's launched ?"))
627
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
78 sys.exit(1)
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
79 except BridgeInitError:
d207c2186519 core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents: 613
diff changeset
80 print(_(u"Can't init bridge"))
165
8a2053de6f8c Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents: 156
diff changeset
81 sys.exit(1)
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
82 self.transfer_data = None
0
goffi@necton2
parents:
diff changeset
83
goffi@necton2
parents:
diff changeset
84 def check_options(self):
goffi@necton2
parents:
diff changeset
85 """Check command line options"""
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
86 usage=_("""
0
goffi@necton2
parents:
diff changeset
87 %prog [options] [FILE1 FILE2 ...] JID
goffi@necton2
parents:
diff changeset
88 %prog -w [options] [JID1 JID2 ...]
goffi@necton2
parents:
diff changeset
89
goffi@necton2
parents:
diff changeset
90 %prog --help for options list
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
91 """)
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 165
diff changeset
92 version = unicode(self.bridge.getVersion())
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 165
diff changeset
93 parser = OptionParser(usage=usage,version=about % version)
0
goffi@necton2
parents:
diff changeset
94
110
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
95 parser.add_option("-p", "--profile", action="store", type="string", default='@DEFAULT@',
156
a216dfbb0d50 jp: added default value in --profile option's help
Goffi <goffi@goffi.org>
parents: 110
diff changeset
96 help=_("Use PROFILE profile key (default: %default)"))
0
goffi@necton2
parents:
diff changeset
97 parser.add_option("-b", "--bz2", action="store_true", default=False,
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
98 help=_("Make a bzip2 tarball"))
0
goffi@necton2
parents:
diff changeset
99 parser.add_option("-w", "--wait-file", action="store_true", default=False,
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
100 help=_("Wait for a file to be sent by a contact"))
0
goffi@necton2
parents:
diff changeset
101 parser.add_option("-m", "--multiple", action="store_true", default=False,
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
102 help=_("Accept multiple files (you'll have to stop manually)"))
0
goffi@necton2
parents:
diff changeset
103 parser.add_option("-f", "--force", action="store_true", default=False,
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
104 help=_("Force overwritting of existing files"))
110
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
105 parser.add_option("-g", "--progress", action="store_true", default=False,
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
106 help=_("Show progress bar"))
0
goffi@necton2
parents:
diff changeset
107 parser.add_option("-s", "--separate", action="store_true", default=False,
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
108 help=_("Separate xmpp messages: send one message per line instead of one message alone."))
0
goffi@necton2
parents:
diff changeset
109 parser.add_option("-n", "--new-line", action="store_true", default=False,
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
110 help=_("Add a new line at the beginning of the input (usefull for ascii art ;))"))
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
111 parser.add_option("--connect", action="store_true", default=False,
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
112 help=_("Connect the profile before doing anything else"))
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
113 parser.add_option("--pipe-in", action="store_true", default=False,
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
114 help=_("Wait for the reception of a pipe stream"))
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
115 parser.add_option("--pipe-out", action="store_true", default=False,
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
116 help=_("Pipe a stream out "))
0
goffi@necton2
parents:
diff changeset
117
goffi@necton2
parents:
diff changeset
118 (self.options, args) = parser.parse_args()
goffi@necton2
parents:
diff changeset
119
goffi@necton2
parents:
diff changeset
120 if len(args) < 1 and not self.options.wait_file:
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
121 parser.error(_("You must specify the destination JID (Jabber ID)").encode('utf-8'))
0
goffi@necton2
parents:
diff changeset
122
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
123 if self.options.wait_file or self.options.pipe_in:
0
goffi@necton2
parents:
diff changeset
124 #several jid
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
125 self.dest_jids = [arg.decode('utf-8') for arg in args]
0
goffi@necton2
parents:
diff changeset
126 else:
goffi@necton2
parents:
diff changeset
127 #one dest_jid, other args are files
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
128 self.dest_jid = JID(args[-1].decode('utf-8'))
0
goffi@necton2
parents:
diff changeset
129 self.files = args[:-1]
goffi@necton2
parents:
diff changeset
130
goffi@necton2
parents:
diff changeset
131 if not pbar_available and self.options.progress:
goffi@necton2
parents:
diff changeset
132 self.options.progress = False
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
133 error (_("Option progress is not available, deactivated."))
0
goffi@necton2
parents:
diff changeset
134
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
135 if self.options.progress or self.options.wait_file or self.options.connect or self.options.pipe_in:
0
goffi@necton2
parents:
diff changeset
136 self.start_loop = True #We have to use loop for these options
goffi@necton2
parents:
diff changeset
137 else:
goffi@necton2
parents:
diff changeset
138 self.start_loop = False
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
139
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
140
0
goffi@necton2
parents:
diff changeset
141 return args
goffi@necton2
parents:
diff changeset
142
goffi@necton2
parents:
diff changeset
143 def check_jabber_status(self):
goffi@necton2
parents:
diff changeset
144 """Check that jabber status is allright"""
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
145 def cantConnect():
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
146 error(_(u"Can't connect profile"))
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
147 exit(1)
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
148
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
149
110
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
150 self.profile = self.bridge.getProfileName(self.options.profile)
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
151 if not self.profile:
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
152 error(_("The profile asked doesn't exist"))
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
153 exit(1)
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
154
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
155 if self.options.connect: #if connection is asked, we connect the profile
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
156 self.bridge.asyncConnect(self.profile, self.connected, cantConnect)
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
157 return
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
158 elif not self.bridge.isConnected(self.profile):
493
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
159 error(_(u"Profile [%(profile)s] is not connected, please connect it before using jp, or use --connect option") % { "profile": self.profile })
0
goffi@necton2
parents:
diff changeset
160 exit(1)
goffi@necton2
parents:
diff changeset
161
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
162 self.connected()
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
163
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
164 def check_jids(self):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
165 """Check jids validity, transform roster name to corresponding jids"""
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
166 names2jid = {}
493
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
167 nodes2jid = {}
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
168
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
169 for contact in self.bridge.getContacts(self.options.profile):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
170 _jid, attr, groups = contact
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
171 if attr.has_key("name"):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
172 names2jid[attr["name"].lower()] = _jid
493
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
173 nodes2jid[JID(_jid).node.lower()] = _jid
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
174
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
175 def expandJid(jid):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
176 _jid = jid.lower()
493
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
177 if _jid in names2jid:
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
178 expanded = names2jid[_jid]
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
179 elif _jid in nodes2jid:
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
180 expanded = nodes2jid[_jid]
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
181 else:
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
182 expanded = jid
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
183 return unicode(expanded)
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
184
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
185 def check(jid):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
186 if not jid.is_valid:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
187 error (_("%s is not a valid JID !"), self.dest_jid)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
188 exit(1)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
189
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
190 try:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
191 self.dest_jid = expandJid(self.dest_jid)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
192 check(self.dest_jid)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
193 except AttributeError:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
194 pass
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
195 try:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
196 for i in range(len(self.dest_jids)):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
197 self.dest_jids[i] = expandJid(self.dest_jids[i])
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
198 check(self.dest_jids[i])
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
199 except AttributeError:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
200 pass
0
goffi@necton2
parents:
diff changeset
201
493
b7c4bb2c0668 jp: - better expandJid: roster's jids' nodes are used after names to expand jid
Goffi <goffi@goffi.org>
parents: 480
diff changeset
202
0
goffi@necton2
parents:
diff changeset
203 def send_stdin(self):
goffi@necton2
parents:
diff changeset
204 """Send incomming data on stdin to jabber contact"""
goffi@necton2
parents:
diff changeset
205 header = "\n" if self.options.new_line else ""
goffi@necton2
parents:
diff changeset
206
goffi@necton2
parents:
diff changeset
207 if self.options.separate: #we send stdin in several messages
goffi@necton2
parents:
diff changeset
208 if header:
110
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
209 self.bridge.sendMessage(self.dest_jid, header, profile_key=self.profile)
0
goffi@necton2
parents:
diff changeset
210 while (True):
601
a4f6f78f0620 jp, core: jp's clean_ustr moved to a new general utils module
Goffi <goffi@goffi.org>
parents: 588
diff changeset
211 line = clean_ustr(sys.stdin.readline().decode('utf-8','ignore'))
0
goffi@necton2
parents:
diff changeset
212 if not line:
goffi@necton2
parents:
diff changeset
213 break
110
cb904fa7de3c jp: profile management (new option: --profile)
Goffi <goffi@goffi.org>
parents: 70
diff changeset
214 self.bridge.sendMessage(self.dest_jid, line.replace("\n",""), profile_key=self.profile)
0
goffi@necton2
parents:
diff changeset
215 else:
601
a4f6f78f0620 jp, core: jp's clean_ustr moved to a new general utils module
Goffi <goffi@goffi.org>
parents: 588
diff changeset
216 self.bridge.sendMessage(self.dest_jid, header + clean_ustr(u"".join([stream.decode('utf-8','ignore') for stream in sys.stdin.readlines()])), profile_key=self.profile)
0
goffi@necton2
parents:
diff changeset
217
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
218
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
219 def pipe_out(self):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
220 """Create named pipe, and send stdin to it"""
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
221 tmp_dir = tempfile.mkdtemp()
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
222 fifopath = os.path.join(tmp_dir,"pipe_out")
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
223 os.mkfifo(fifopath)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
224 self.bridge.pipeOut(self._getFullJid(self.dest_jid), fifopath, {}, profile_key=self.profile)
402
f03688bdb858 jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents: 401
diff changeset
225 with open(fifopath, 'w') as f:
f03688bdb858 jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents: 401
diff changeset
226 shutil.copyfileobj(sys.stdin, f)
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
227 shutil.rmtree(tmp_dir)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
228
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
229
0
goffi@necton2
parents:
diff changeset
230 def send_files(self):
goffi@necton2
parents:
diff changeset
231 """Send files to jabber contact"""
goffi@necton2
parents:
diff changeset
232
goffi@necton2
parents:
diff changeset
233 for file in self.files:
goffi@necton2
parents:
diff changeset
234 if not os.path.exists(file):
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
235 error (_(u"File [%s] doesn't exist !") % file)
0
goffi@necton2
parents:
diff changeset
236 exit(1)
goffi@necton2
parents:
diff changeset
237 if not self.options.bz2 and os.path.isdir(file):
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
238 error (_("[%s] is a dir ! Please send files inside or use compression") % file)
0
goffi@necton2
parents:
diff changeset
239 exit(1)
goffi@necton2
parents:
diff changeset
240
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
241 full_dest_jid = self._getFullJid(self.dest_jid)
0
goffi@necton2
parents:
diff changeset
242 if self.options.bz2:
goffi@necton2
parents:
diff changeset
243 tmpfile = (basename(self.files[0]) or basename(dirname(self.files[0])) ) + '.tar.bz2' #FIXME: tmp, need an algorithm to find a good name/path
goffi@necton2
parents:
diff changeset
244 if os.path.exists(tmpfile):
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
245 error (_("tmp file (%s) already exists ! Please remove it"), tmpfile)
0
goffi@necton2
parents:
diff changeset
246 exit(1)
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
247 warning(_("bz2 is an experimental option at an early dev stage, use with caution"))
0
goffi@necton2
parents:
diff changeset
248 #FIXME: check free space, writting perm, tmp dir, filename (watch for OS used)
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
249 info(_("Starting compression, please wait..."))
0
goffi@necton2
parents:
diff changeset
250 sys.stdout.flush()
goffi@necton2
parents:
diff changeset
251 bz2=tarfile.open(tmpfile, "w:bz2")
goffi@necton2
parents:
diff changeset
252 for file in self.files:
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
253 info(_("Adding %s"), file)
0
goffi@necton2
parents:
diff changeset
254 bz2.add(file)
goffi@necton2
parents:
diff changeset
255 bz2.close()
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
256 info(_("OK !"))
0
goffi@necton2
parents:
diff changeset
257 path = abspath(tmpfile)
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
258 self.transfer_data = self.bridge.sendFile(full_dest_jid, path, {}, profile_key=self.profile)
0
goffi@necton2
parents:
diff changeset
259 else:
goffi@necton2
parents:
diff changeset
260 for file in self.files:
goffi@necton2
parents:
diff changeset
261 path = abspath(file)
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
262 self.transfer_data = self.bridge.sendFile(full_dest_jid, path, {}, profile_key=self.profile) #FIXME: show progress only for last transfer_id
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
263
0
goffi@necton2
parents:
diff changeset
264
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
265 def _getFullJid(self, param_jid):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
266 """Return the full jid if possible (add last resource when find a bare jid"""
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
267 _jid = JID(param_jid)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
268 if not _jid.resource:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
269 #if the resource is not given, we try to add the last known resource
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
270 last_resource = self.bridge.getLastResource(param_jid, self.options.profile)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
271 if last_resource:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
272 return "%s/%s" % (_jid.short, last_resource)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
273 return param_jid
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
274
0
goffi@necton2
parents:
diff changeset
275
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
276 def askConfirmation(self, confirm_id, confirm_type, data, profile):
391
c34fd9d6242e spelling
Goffi <goffi@goffi.org>
parents: 390
diff changeset
277 """CB used for file transfer, accept files depending on parameters"""
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
278 if profile != self.profile:
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
279 debug("Ask confirmation ignored: not our profile")
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
280 return
0
goffi@necton2
parents:
diff changeset
281 answer_data={}
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
282 if confirm_type == "FILE_TRANSFER":
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
283 if not self.options.wait_file:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
284 return
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
285 if self.dest_jids and not JID(data['from']).short in [JID(_jid).short for _jid in self.dest_jids]:
0
goffi@necton2
parents:
diff changeset
286 return #file is not sent by a filtered jid
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
287
0
goffi@necton2
parents:
diff changeset
288 answer_data["dest_path"] = os.getcwd()+'/'+data['filename']
goffi@necton2
parents:
diff changeset
289
goffi@necton2
parents:
diff changeset
290 if self.options.force or not os.path.exists(answer_data["dest_path"]):
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
291 self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile)
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
292 info(_("Accepted file [%(filename)s] from %(sender)s") % {'filename':data['filename'], 'sender':data['from']})
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
293 self.transfer_data = confirm_id
0
goffi@necton2
parents:
diff changeset
294 else:
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
295 self.bridge.confirmationAnswer(confirm_id, False, answer_data, profile)
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
296 warning(_("Refused file [%(filename)s] from %(sender)s: a file with the same name already exist") % {'filename':data['filename'], 'sender':data['from']})
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
297
0
goffi@necton2
parents:
diff changeset
298
goffi@necton2
parents:
diff changeset
299 if not self.options.multiple and not self.options.progress:
goffi@necton2
parents:
diff changeset
300 #we just accept one file
goffi@necton2
parents:
diff changeset
301 self.loop.quit()
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
302 elif confirm_type == "PIPE_TRANSFER":
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
303 if not self.options.pipe_in:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
304 return
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
305 if self.dest_jids and not JID(data['from']).short in [JID(_jid).short for _jid in self.dest_jids]:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
306 return #pipe stream is not sent by a filtered jid
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
307
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
308 tmp_dir = tempfile.mkdtemp()
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
309 fifopath = os.path.join(tmp_dir,"pipe_in")
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
310 answer_data["dest_path"] = fifopath
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
311 os.mkfifo(fifopath)
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
312 self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile)
402
f03688bdb858 jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents: 401
diff changeset
313 with open(fifopath, 'r') as f:
f03688bdb858 jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents: 401
diff changeset
314 shutil.copyfileobj(f, sys.stdout)
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
315 shutil.rmtree(tmp_dir)
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
316 self.loop.quit()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
317
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
318
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
319 def actionResult(self, action_type, action_id, data, profile):
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 0
diff changeset
320 #FIXME
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
321 info (_("FIXME: actionResult not implemented"))
0
goffi@necton2
parents:
diff changeset
322
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
323 def confirmation_reply(self):
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
324 """Auto reply to confirmations requests"""
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
325 #we register incoming confirmation
390
8e87af2e2d1f jp: fixed file reception
Goffi <goffi@goffi.org>
parents: 387
diff changeset
326 self.bridge.register("askConfirmation", self.askConfirmation)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
327
542
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
328 #and we ask those we have missed
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
329 for confirm_id, confirm_type, data in self.bridge.getWaitingConf(self.profile):
3eeb6c865e4d frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents: 538
diff changeset
330 self.askConfirmation(confirm_id, confirm_type, data, self.profile)
0
goffi@necton2
parents:
diff changeset
331
goffi@necton2
parents:
diff changeset
332 def progressCB(self):
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
333 if self.transfer_data:
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
334 transfer_id = self.transfer_data
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 493
diff changeset
335 data = self.bridge.getProgress(transfer_id, self.profile)
0
goffi@necton2
parents:
diff changeset
336 if data:
goffi@necton2
parents:
diff changeset
337 if not data['position']:
goffi@necton2
parents:
diff changeset
338 data['position'] = '0'
goffi@necton2
parents:
diff changeset
339 if not self.pbar:
goffi@necton2
parents:
diff changeset
340 #first answer, we must construct the bar
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
341 self.pbar = ProgressBar(int(data['size']),[_("Progress: "),Percentage()," ",Bar()," ",FileTransferSpeed()," ",ETA()])
0
goffi@necton2
parents:
diff changeset
342 self.pbar.start()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
343
0
goffi@necton2
parents:
diff changeset
344 self.pbar.update(int(data['position']))
goffi@necton2
parents:
diff changeset
345 elif self.pbar:
goffi@necton2
parents:
diff changeset
346 self.pbar.finish()
goffi@necton2
parents:
diff changeset
347 if not self.options.multiple:
goffi@necton2
parents:
diff changeset
348 self.loop.quit()
goffi@necton2
parents:
diff changeset
349 return False
goffi@necton2
parents:
diff changeset
350
goffi@necton2
parents:
diff changeset
351 return True
goffi@necton2
parents:
diff changeset
352
goffi@necton2
parents:
diff changeset
353 def go(self):
goffi@necton2
parents:
diff changeset
354 self.check_options()
goffi@necton2
parents:
diff changeset
355 self.check_jabber_status()
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
356 if self.start_loop:
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
357 self.loop = gobject.MainLoop()
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
358 try:
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
359 self.loop.run()
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
360 except KeyboardInterrupt:
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
361 info(_("User interruption: good bye"))
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
362
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
363 def connected(self):
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
364 """This is called when the profile is connected"""
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
365 self.check_jids()
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
366 if self.options.wait_file or self.options.pipe_in:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
367 self.confirmation_reply()
0
goffi@necton2
parents:
diff changeset
368 else:
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
369 if self.files:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
370 self.send_files()
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
371 elif self.options.pipe_out:
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
372 self.pipe_out()
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
373 else:
0
goffi@necton2
parents:
diff changeset
374 self.send_stdin()
goffi@necton2
parents:
diff changeset
375
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
376 if self.options.progress:
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
377 self.pbar = None
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
378 gobject.timeout_add(10, self.progressCB)
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
379
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
380 if self.start_loop and not self.options.progress and not self.options.wait_file and not self.options.pipe_in:
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
381 self.loop.quit()
0
goffi@necton2
parents:
diff changeset
382
goffi@necton2
parents:
diff changeset
383
goffi@necton2
parents:
diff changeset
384 if __name__ == "__main__":
goffi@necton2
parents:
diff changeset
385 jp = JP()
goffi@necton2
parents:
diff changeset
386 jp.go()