mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-10 13:32:17 +03:00
file transfer via ssh
This commit is contained in:
parent
a8d8aafd46
commit
a2676abea4
1 changed files with 9 additions and 8 deletions
|
@ -25,11 +25,10 @@ class FileTransfer(slixmpp.ClientXMPP):
|
|||
self.my_jid = str(self.configuration_manager.get('CONNECTION', 'uid') + '@' + self.configuration_manager.get('CONNECTION', 'servicename') + '/sender')
|
||||
self.my_pass = str(self.configuration_manager.get('CONNECTION', 'password'))
|
||||
self.receiver = self.configuration_manager.get('CONNECTION', 'receiverjid') + '@' + self.configuration_manager.get('CONNECTION', 'servicename') + '/Smack'
|
||||
self.logger.debug('[FileTransfer] File transfer client was configured.')
|
||||
|
||||
try:
|
||||
slixmpp.ClientXMPP.__init__(self, self.my_jid, self.my_pass)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
self.logger.debug('[FileTransfer] XMPP Client was created for file transfer.')
|
||||
|
||||
self.register_plugin('xep_0030') # Service Discovery
|
||||
self.register_plugin('xep_0065')
|
||||
|
@ -38,7 +37,7 @@ class FileTransfer(slixmpp.ClientXMPP):
|
|||
|
||||
@asyncio.coroutine
|
||||
def start(self, event):
|
||||
print('sending...')
|
||||
self.logger.debug('[FileTransfer] Sending file ...')
|
||||
|
||||
try:
|
||||
# Open the S5B stream in which to write to.
|
||||
|
@ -49,7 +48,7 @@ class FileTransfer(slixmpp.ClientXMPP):
|
|||
while True:
|
||||
data = self.file.read(1000)
|
||||
i += 1
|
||||
print('-->'+str(i)+'--'+str(len(data)))
|
||||
print('-->' + str(i) + '--' + str(len(data)))
|
||||
if not data:
|
||||
break
|
||||
yield from proxy.write(data)
|
||||
|
@ -59,12 +58,14 @@ class FileTransfer(slixmpp.ClientXMPP):
|
|||
proxy.transport.write_eof()
|
||||
|
||||
except Exception as e:
|
||||
print('File transfer errored:' + str(e))
|
||||
self.logger.debug('[FileTransfer] A problem occurred while file transferring. Error Message: {}'.format(str(e)))
|
||||
else:
|
||||
print('File transfer finished')
|
||||
self.logger.debug('[FileTransfer] File transfer is finished.')
|
||||
finally:
|
||||
self.logger.debug('[FileTransfer] Disconnecting file transfer resource.')
|
||||
self.disconnect()
|
||||
self.file.close()
|
||||
self.logger.debug('[FileTransfer] Disconnected file transfer resource.')
|
||||
|
||||
@staticmethod
|
||||
def run(file_path):
|
||||
|
|
Loading…
Reference in a new issue