comparison frontends/src/jp/jp @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents ca13633d3b6b
children beaf6bec2fcd
comparison
equal deleted inserted replaced
586:6a718ede8be1 587:952322b1d490
133 133
134 if self.options.progress or self.options.wait_file or self.options.connect or self.options.pipe_in: 134 if self.options.progress or self.options.wait_file or self.options.connect or self.options.pipe_in:
135 self.start_loop = True #We have to use loop for these options 135 self.start_loop = True #We have to use loop for these options
136 else: 136 else:
137 self.start_loop = False 137 self.start_loop = False
138 138
139 139
140 return args 140 return args
141 141
142 def check_jabber_status(self): 142 def check_jabber_status(self):
143 """Check that jabber status is allright""" 143 """Check that jabber status is allright"""
144 def cantConnect(): 144 def cantConnect():
145 error(_(u"Can't connect profile")) 145 error(_(u"Can't connect profile"))
146 exit(1) 146 exit(1)
147 147
148 148
149 self.profile = self.bridge.getProfileName(self.options.profile) 149 self.profile = self.bridge.getProfileName(self.options.profile)
150 if not self.profile: 150 if not self.profile:
151 error(_("The profile asked doesn't exist")) 151 error(_("The profile asked doesn't exist"))
152 exit(1) 152 exit(1)
153 153
291 if confirm_type == "FILE_TRANSFER": 291 if confirm_type == "FILE_TRANSFER":
292 if not self.options.wait_file: 292 if not self.options.wait_file:
293 return 293 return
294 if self.dest_jids and not JID(data['from']).short in [JID(_jid).short for _jid in self.dest_jids]: 294 if self.dest_jids and not JID(data['from']).short in [JID(_jid).short for _jid in self.dest_jids]:
295 return #file is not sent by a filtered jid 295 return #file is not sent by a filtered jid
296 296
297 answer_data["dest_path"] = os.getcwd()+'/'+data['filename'] 297 answer_data["dest_path"] = os.getcwd()+'/'+data['filename']
298 298
299 if self.options.force or not os.path.exists(answer_data["dest_path"]): 299 if self.options.force or not os.path.exists(answer_data["dest_path"]):
300 self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile) 300 self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile)
301 info(_("Accepted file [%(filename)s] from %(sender)s") % {'filename':data['filename'], 'sender':data['from']}) 301 info(_("Accepted file [%(filename)s] from %(sender)s") % {'filename':data['filename'], 'sender':data['from']})
302 self.transfer_data = confirm_id 302 self.transfer_data = confirm_id
303 else: 303 else:
304 self.bridge.confirmationAnswer(confirm_id, False, answer_data, profile) 304 self.bridge.confirmationAnswer(confirm_id, False, answer_data, profile)
305 warning(_("Refused file [%(filename)s] from %(sender)s: a file with the same name already exist") % {'filename':data['filename'], 'sender':data['from']}) 305 warning(_("Refused file [%(filename)s] from %(sender)s: a file with the same name already exist") % {'filename':data['filename'], 'sender':data['from']})
306 306
307 307
308 if not self.options.multiple and not self.options.progress: 308 if not self.options.multiple and not self.options.progress:
309 #we just accept one file 309 #we just accept one file
310 self.loop.quit() 310 self.loop.quit()
311 elif confirm_type == "PIPE_TRANSFER": 311 elif confirm_type == "PIPE_TRANSFER":
312 if not self.options.pipe_in: 312 if not self.options.pipe_in:
313 return 313 return
314 if self.dest_jids and not JID(data['from']).short in [JID(_jid).short for _jid in self.dest_jids]: 314 if self.dest_jids and not JID(data['from']).short in [JID(_jid).short for _jid in self.dest_jids]:
315 return #pipe stream is not sent by a filtered jid 315 return #pipe stream is not sent by a filtered jid
316 316
317 tmp_dir = tempfile.mkdtemp() 317 tmp_dir = tempfile.mkdtemp()
318 fifopath = os.path.join(tmp_dir,"pipe_in") 318 fifopath = os.path.join(tmp_dir,"pipe_in")
319 answer_data["dest_path"] = fifopath 319 answer_data["dest_path"] = fifopath
320 os.mkfifo(fifopath) 320 os.mkfifo(fifopath)
321 self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile) 321 self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile)
322 with open(fifopath, 'r') as f: 322 with open(fifopath, 'r') as f:
323 shutil.copyfileobj(f, sys.stdout) 323 shutil.copyfileobj(f, sys.stdout)
324 shutil.rmtree(tmp_dir) 324 shutil.rmtree(tmp_dir)
325 self.loop.quit() 325 self.loop.quit()
326 326
327 327
328 def actionResult(self, action_type, action_id, data, profile): 328 def actionResult(self, action_type, action_id, data, profile):
329 #FIXME 329 #FIXME
330 info (_("FIXME: actionResult not implemented")) 330 info (_("FIXME: actionResult not implemented"))
331 331
332 def confirmation_reply(self): 332 def confirmation_reply(self):
333 """Auto reply to confirmations requests""" 333 """Auto reply to confirmations requests"""
334 #we register incoming confirmation 334 #we register incoming confirmation
335 self.bridge.register("askConfirmation", self.askConfirmation) 335 self.bridge.register("askConfirmation", self.askConfirmation)
336 336
337 #and we ask those we have missed 337 #and we ask those we have missed
338 for confirm_id, confirm_type, data in self.bridge.getWaitingConf(self.profile): 338 for confirm_id, confirm_type, data in self.bridge.getWaitingConf(self.profile):
339 self.askConfirmation(confirm_id, confirm_type, data, self.profile) 339 self.askConfirmation(confirm_id, confirm_type, data, self.profile)
340 340
341 def progressCB(self): 341 def progressCB(self):
347 data['position'] = '0' 347 data['position'] = '0'
348 if not self.pbar: 348 if not self.pbar:
349 #first answer, we must construct the bar 349 #first answer, we must construct the bar
350 self.pbar = ProgressBar(int(data['size']),[_("Progress: "),Percentage()," ",Bar()," ",FileTransferSpeed()," ",ETA()]) 350 self.pbar = ProgressBar(int(data['size']),[_("Progress: "),Percentage()," ",Bar()," ",FileTransferSpeed()," ",ETA()])
351 self.pbar.start() 351 self.pbar.start()
352 352
353 self.pbar.update(int(data['position'])) 353 self.pbar.update(int(data['position']))
354 elif self.pbar: 354 elif self.pbar:
355 self.pbar.finish() 355 self.pbar.finish()
356 if not self.options.multiple: 356 if not self.options.multiple:
357 self.loop.quit() 357 self.loop.quit()