debugs fixes

This commit is contained in:
Volkan Şahin 2016-04-12 17:27:29 +03:00
parent 737c877894
commit 5816e91bea

View file

@ -15,7 +15,6 @@ from base.Scope import Scope
class Messager(slixmpp.ClientXMPP): class Messager(slixmpp.ClientXMPP):
global loop global loop
def __init__(self): def __init__(self):
@ -85,13 +84,12 @@ class Messager(slixmpp.ClientXMPP):
# TODO read conf file check file size if file size is bigger than max size, divide and send parts.after all send message about them # TODO read conf file check file size if file size is bigger than max size, divide and send parts.after all send message about them
self.logger.debug('[Messager] Sending file: ' + self.file.name) self.logger.debug('[Messager] Sending file: ' + self.file.name)
self.logger.debug('[MessageSender] Sending file: ' + self.file.name)
try: try:
self.logger.debug('[MessageSender] Handshaking for file transfering...') self.logger.debug('[Messager] Handshaking for file transfering...')
# Open the S5B stream in which to write to. # Open the S5B stream in which to write to.
proxy = yield from self['xep_0065'].handshake(self.receiver) proxy = yield from self['xep_0065'].handshake(self.receiver)
# Send the entire file. # Send the entire file.
self.logger.debug('[MessageSender] Started to streaming file...') self.logger.debug('[Messager] Started to streaming file...')
while True: while True:
data = self.file.read(1048576) data = self.file.read(1048576)
if not data: if not data:
@ -100,9 +98,9 @@ class Messager(slixmpp.ClientXMPP):
# And finally close the stream. # And finally close the stream.
proxy.transport.write_eof() proxy.transport.write_eof()
except (IqError, IqTimeout): except (IqError, IqTimeout):
self.logger.error('[MessageSender] File transfer errored') self.logger.error('[Messager] File transfer errored')
else: else:
self.logger.debug('[MessageSender] File transfer finished successfully') self.logger.debug('[Messager] File transfer finished successfully')
finally: finally:
self.file.close() self.file.close()
@ -132,7 +130,6 @@ class Messager(slixmpp.ClientXMPP):
self.logger.error('[Messager] Connection to server is failed! ' + e) self.logger.error('[Messager] Connection to server is failed! ' + e)
return False return False
def set_file_name_md5(self): def set_file_name_md5(self):
self.logger.debug('[Messager] Renaming file as md5 hash') self.logger.debug('[Messager] Renaming file as md5 hash')
md5_hash = self.execution_manager.get_md5_file(self.file.name) md5_hash = self.execution_manager.get_md5_file(self.file.name)
@ -146,10 +143,10 @@ class Messager(slixmpp.ClientXMPP):
self.register_plugin('xep_0065', {'auto_accept': True}) # SOCKS5 Bytestreams self.register_plugin('xep_0065', {'auto_accept': True}) # SOCKS5 Bytestreams
self.register_plugin('xep_0047', {'auto_accept': True}) # In-band Bytestreams self.register_plugin('xep_0047', {'auto_accept': True}) # In-band Bytestreams
self.logger.debug('Extension were registered: xep_0030,xep_0045,xep_0199,xep_0065,xep_0047') self.logger.debug('[Messager]Extension were registered: xep_0030,xep_0045,xep_0199,xep_0065,xep_0047')
return True return True
except Exception as e: except Exception as e:
self.logger.error('Extension registration is failed!(%s)\n' % (e.errno, e.strerror)) self.logger.error('[Messager]Extension registration is failed!(%s)\n' % (e.errno, e.strerror))
return False return False
''' '''