From eb4af1cc2a42a07532902c416f3432230d587ffc Mon Sep 17 00:00:00 2001 From: "jai.s" Date: Thu, 20 Feb 2020 13:36:47 +0530 Subject: [PATCH] Solved python2 to python3 message receiving issue and removed unrequired prints --- src/class_objectProcessor.py | 4 ++-- src/fallback/umsgpack/umsgpack.py | 11 ++++++++--- src/highlevelcrypto.py | 1 - src/protocol.py | 3 --- src/storage/sqlite.py | 1 - 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index adb506d3..edfef77b 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -144,11 +144,11 @@ class objectProcessor(threading.Thread): sqlExecute( 'UPDATE sent SET status=?, lastactiontime=?' ' WHERE ackdata=?', - 'ackreceived', int(time.time()), data[readPosition:]) + 'ackreceived', int(time.time()), bytes(data[readPosition:])) queues.UISignalQueue.put(( 'updateSentItemStatusByAckdata', ( - data[readPosition:], + bytes(data[readPosition:]), tr._translate( "MainWindow", "Acknowledgement of the message received %1" diff --git a/src/fallback/umsgpack/umsgpack.py b/src/fallback/umsgpack/umsgpack.py index 34938614..38fc656d 100644 --- a/src/fallback/umsgpack/umsgpack.py +++ b/src/fallback/umsgpack/umsgpack.py @@ -687,9 +687,14 @@ def _unpack_binary(code, fp, options): length = struct.unpack(">I", _read_except(fp, 4))[0] else: raise Exception("logic error, not binary: 0x%02x" % ord(code)) - - return _read_except(fp, length) - + #Added Decode method for python3 + data = _read_except(fp, length) + try: + return bytes.decode(data, 'utf-8') + except UnicodeDecodeError: + if options.get("allow_invalid_utf8"): + return InvalidString(data) + raise InvalidStringException("unpacked string is invalid utf-8") def _unpack_ext(code, fp, options): if code == b'\xd4': diff --git a/src/highlevelcrypto.py b/src/highlevelcrypto.py index ad073e47..03e2d1d3 100644 --- a/src/highlevelcrypto.py +++ b/src/highlevelcrypto.py @@ -54,7 +54,6 @@ def encrypt(msg, hexPubkey): def decrypt(msg, hexPrivkey): - print("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS#################################################") """Decrypts message with hex private key""" return makeCryptor(hexPrivkey).decrypt(msg) diff --git a/src/protocol.py b/src/protocol.py index 80f5f615..9e2f0865 100644 --- a/src/protocol.py +++ b/src/protocol.py @@ -444,7 +444,6 @@ def decryptAndCheckPubkeyPayload(data, address): # That sort of address-malleability should have been caught # by the UI or API and an error given to the user. return 'failed' - print("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW#################################################") try: decryptedData = cryptorObject.decrypt(encryptedData) except: @@ -455,7 +454,6 @@ def decryptAndCheckPubkeyPayload(data, address): readPosition = 0 # bitfieldBehaviors = decryptedData[readPosition:readPosition + 4] readPosition += 4 - print("working fine till here#################################################################") publicSigningKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64] readPosition += 64 publicEncryptionKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64] @@ -503,7 +501,6 @@ def decryptAndCheckPubkeyPayload(data, address): ) t = (address, addressVersion, storedData, int(time.time()), 'yes') sqlExecute('''INSERT INTO pubkeys VALUES (?,?,?,?,?)''', *t) - print("successful Insertion of pubkey hurray#################################################") return 'successful' except varintDecodeError: logger.info( diff --git a/src/storage/sqlite.py b/src/storage/sqlite.py index 912caf0d..d3c8c9e1 100644 --- a/src/storage/sqlite.py +++ b/src/storage/sqlite.py @@ -91,7 +91,6 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors hashes += (payload for payload, in sqlQuery( 'SELECT hash FROM inventory WHERE streamnumber=?' ' AND expirestime>?', stream, t)) - # print('sqlllllllllllllllllllllllllllllllllll',hashes) return hashes def flush(self):