changeset 8c3e77b63eef in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=8c3e77b63eef
description: coding standards
diffstat:
src/common/xmpp/protocol.py | 14 +++++++-------
src/gui_interface.py | 22 ++++++++++++----------
2 files changed, 19 insertions(+), 17 deletions(-)
diffs (113 lines):
diff -r d342571e82e0 -r 8c3e77b63eef src/common/xmpp/protocol.py
--- a/src/common/xmpp/protocol.py Mon Jan 23 22:28:07 2012 -0500
+++ b/src/common/xmpp/protocol.py Tue Jan 24 07:28:40 2012 +0100
@@ -1066,7 +1066,7 @@
instead of doing it all over the place in Gajim.
"""
hl = None
- hash = None
+ hash_ = None
# file_string can be a string or a file
if type(file_string) == str: # if it is a string
if algo == 'md5':
@@ -1083,7 +1083,7 @@
raise Exception('Hash algorithm not supported')
else:
hl.update(file_string)
- hash = hl.hexdigest()
+ hash_ = hl.hexdigest()
else: # if it is a file
if algo == 'md5':
@@ -1101,25 +1101,25 @@
else:
for line in file_string:
hl.update(line)
- hash = hl.hexdigest()
+ hash_ = hl.hexdigest()
- return hash
+ return hash_
- def addHash(self, hash, algo):
+ def addHash(self, hash_, algo):
"""
More than one hash can be added. Although it is permitted, it should
not be done for big files because it could slow down Gajim.
"""
attrs = {}
attrs['algo'] = algo
- self.addChild('hash', attrs, [hash])
+ self.addChild('hash', attrs, [hash_])
class Acks(Node):
"""
Acknowledgement elements for Stream Management
"""
def __init__(self, nsp=NS_STREAM_MGMT):
- Node.__init__(self, None, {}, [], None, None,False, None)
+ Node.__init__(self, None, {}, [], None, None, False, None)
self.setNamespace(nsp)
def buildAnswer(self, handled):
diff -r d342571e82e0 -r 8c3e77b63eef src/gui_interface.py
--- a/src/gui_interface.py Mon Jan 23 22:28:07 2012 -0500
+++ b/src/gui_interface.py Tue Jan 24 07:28:40 2012 +0100
@@ -909,18 +909,20 @@
self.last_ftwindow_update = time.time()
self.instances['file_transfers'].set_progress(file_props['type'],
file_props['sid'], file_props['received-len'])
+
def __compare_hashes(self, account, file_props):
session = gajim.connections[account].get_jingle_session(jid=None,
- sid=file_props['session-sid'])
+ sid=file_props['session-sid'])
h = Hashes()
try:
- file = open(file_props['file-name'], 'r')
+ file_ = open(file_props['file-name'], 'r')
except:
return
- hash = h.calculateHash(session.hash_algo, file)
+ hash_ = h.calculateHash(session.hash_algo, file_)
+ file_.close()
# If the hash we received and the hash of the file are the same,
# then the file is not corrupt
- if session.file_hash == hash:
+ if session.file_hash == hash_:
print "they are te same"
# End jingle session
if session:
@@ -930,18 +932,18 @@
ft = self.instances['file_transfers']
if file_props['error'] == 0:
ft.set_progress(file_props['type'], file_props['sid'],
- file_props['received-len'])
+ file_props['received-len'])
else:
ft.set_status(file_props['type'], file_props['sid'], 'stop')
if 'stalled' in file_props and file_props['stalled'] or \
- 'paused' in file_props and file_props['paused']:
+ 'paused' in file_props and file_props['paused']:
return
-
+
if file_props['type'] == 'r': # we receive a file
jid = unicode(file_props['sender'])
# Compare hashes in a new thread
- self.hashThread = Thread(target=self.__compare_hashes,
- args=(account, file_props))
+ self.hashThread = Thread(target=self.__compare_hashes,
+ args=(account, file_props))
self.hashThread.start()
gajim.socks5queue.remove_receiver(file_props['sid'], True, True)
else: # we send a file
@@ -969,7 +971,7 @@
elif file_props['error'] in (-1, -6):
msg_type = 'file-stopped'
event_type = _('File Transfer Stopped')
-
+
if event_type == '':
# FIXME: ugly workaround (this can happen Gajim sent, Gaim recvs)
# this should never happen but it does. see process_result() in