From 5ec55981774d9a7db91538cc629d1c10e36ad815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Wed, 13 Apr 2016 23:00:34 +0300 Subject: [PATCH] bug fixes --- etc/ahenk/ahenk.conf | 2 +- opt/ahenk/base/messaging/FileTransfer.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/etc/ahenk/ahenk.conf b/etc/ahenk/ahenk.conf index bb3a272..1c7b97a 100644 --- a/etc/ahenk/ahenk.conf +++ b/etc/ahenk/ahenk.conf @@ -9,7 +9,7 @@ mainmodulename = main [CONNECTION] uid = password= -host = localhost +host = im.mys.pardus.org.tr port = 5222 receiverjid = lider_sunucu servicename = im.mys.pardus.org.tr diff --git a/opt/ahenk/base/messaging/FileTransfer.py b/opt/ahenk/base/messaging/FileTransfer.py index 901b065..0fece28 100644 --- a/opt/ahenk/base/messaging/FileTransfer.py +++ b/opt/ahenk/base/messaging/FileTransfer.py @@ -5,6 +5,7 @@ import asyncio import slixmpp +import time from slixmpp.exceptions import IqError, IqTimeout from base.Scope import Scope @@ -45,21 +46,26 @@ class FileTransfer(slixmpp.ClientXMPP): proxy = yield from self['xep_0065'].handshake(self.receiver) # Send the entire file. + i = 0 while True: - data = self.file.read(1048576) + data = self.file.read(1000) + i += 1 + print('-->'+str(i)+'--'+str(len(data))) if not data: break yield from proxy.write(data) + time.sleep(10) # And finally close the stream. proxy.transport.write_eof() - except (IqError, IqTimeout) as e: - print('File transfer errored' + str(e)) + + except Exception as e: + print('File transfer errored:' + str(e)) else: print('File transfer finished') finally: - self.file.close() self.disconnect() + self.file.close() @staticmethod def run(file_path):