From d085d235770588589e15fe82caef1ff5de5dffdd Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Mon, 8 Nov 2021 21:39:59 +0530 Subject: [PATCH] Fixed pylint & removed obsolete file --- dev/bloomfiltertest.py | 20 ++++++++++---------- dev/msgtest.py | 27 --------------------------- dev/powinterrupttest.py | 10 +++++----- dev/ssltest.py | 19 ++++++++++--------- 4 files changed, 25 insertions(+), 51 deletions(-) delete mode 100644 dev/msgtest.py diff --git a/dev/bloomfiltertest.py b/dev/bloomfiltertest.py index 8f7b5f69..19c93c76 100644 --- a/dev/bloomfiltertest.py +++ b/dev/bloomfiltertest.py @@ -52,15 +52,15 @@ for row in cur.fetchall(): # f.close() -print "Item count: %i" % (itemcount) -print "Raw length: %i" % (rawlen) -print "Bloom filter 1 length: %i, reduction to: %.2f%%" % \ +print("Item count: %i" % (itemcount)) +print("Raw length: %i" % (rawlen)) +print("Bloom filter 1 length: %i, reduction to: %.2f%%" % (bf1.bitarray.buffer_info()[1], - 100.0 * bf1.bitarray.buffer_info()[1] / rawlen) -print "Bloom filter 1 capacity: %i and error rate: %.3f%%" % (bf1.capacity, 100.0 * bf1.error_rate) -print "Bloom filter 1 took %.2fs" % (bf1time) -print "Bloom filter 2 length: %i, reduction to: %.3f%%" % \ + 100.0 * bf1.bitarray.buffer_info()[1] / rawlen)) +print("Bloom filter 1 capacity: %i and error rate: %.3f%%" % (bf1.capacity, 100.0 * bf1.error_rate)) +print("Bloom filter 1 took %.2fs" % (bf1time)) +print("Bloom filter 2 length: %i, reduction to: %.3f%%" % (bf2.num_bits / 8, - 100.0 * bf2.num_bits / 8 / rawlen) -print "Bloom filter 2 capacity: %i and error rate: %.3f%%" % (bf2.capacity, 100.0 * bf2.error_rate) -print "Bloom filter 2 took %.2fs" % (bf2time) + 100.0 * bf2.num_bits / 8 / rawlen)) +print("Bloom filter 2 capacity: %i and error rate: %.3f%%" % (bf2.capacity, 100.0 * bf2.error_rate)) +print("Bloom filter 2 took %.2fs" % (bf2time)) diff --git a/dev/msgtest.py b/dev/msgtest.py deleted file mode 100644 index d5a8be8e..00000000 --- a/dev/msgtest.py +++ /dev/null @@ -1,27 +0,0 @@ -import importlib -from os import listdir, path -from pprint import pprint -import sys -import traceback - -data = {"": "message", "subject": "subject", "body": "body"} -#data = {"": "vote", "msgid": "msgid"} -#data = {"fsck": 1} - -import messagetypes - -if __name__ == '__main__': - try: - msgType = data[""] - except KeyError: - print "Message type missing" - sys.exit(1) - else: - print "Message type: %s" % (msgType) - msgObj = messagetypes.constructObject(data) - if msgObj is None: - sys.exit(1) - try: - msgObj.process() - except: - pprint(sys.exc_info()) diff --git a/dev/powinterrupttest.py b/dev/powinterrupttest.py index cc4c2197..bfb55d78 100644 --- a/dev/powinterrupttest.py +++ b/dev/powinterrupttest.py @@ -11,7 +11,7 @@ shutdown = 0 def signal_handler(signal, frame): global shutdown - print "Got signal %i in %s/%s" % (signal, current_process().name, current_thread().name) + print("Got signal %i in %s/%s" % (signal, current_process().name, current_thread().name)) if current_process().name != "MainProcess": raise StopIteration("Interrupted") if current_thread().name != "PyBitmessage": @@ -20,21 +20,21 @@ def signal_handler(signal, frame): def _doCPoW(target, initialHash): -# global shutdown + # global shutdown h = initialHash m = target out_h = ctypes.pointer(ctypes.create_string_buffer(h, 64)) out_m = ctypes.c_ulonglong(m) - print "C PoW start" + print("C PoW start") for c in range(0, 200000): - print "Iter: %i" % (c) + print("Iter: %i" % (c)) nonce = bmpow(out_h, out_m) if shutdown: break trialValue, = unpack('>Q', hashlib.sha512(hashlib.sha512(pack('>Q', nonce) + initialHash).digest()).digest()[0:8]) if shutdown != 0: raise StopIteration("Interrupted") - print "C PoW done" + print("C PoW done") return [trialValue, nonce] diff --git a/dev/ssltest.py b/dev/ssltest.py index a2f31d38..7268b65f 100644 --- a/dev/ssltest.py +++ b/dev/ssltest.py @@ -52,7 +52,8 @@ def sslHandshake(sock, server=False): context.set_ecdh_curve("secp256k1") context.check_hostname = False context.verify_mode = ssl.CERT_NONE - context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_SINGLE_ECDH_USE | ssl.OP_CIPHER_SERVER_PREFERENCE + context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3\ + | ssl.OP_SINGLE_ECDH_USE | ssl.OP_CIPHER_SERVER_PREFERENCE sslSock = context.wrap_socket(sock, server_side=server, do_handshake_on_connect=False) else: sslSock = ssl.wrap_socket(sock, keyfile=os.path.join('src', 'sslkeys', 'key.pem'), @@ -65,29 +66,29 @@ def sslHandshake(sock, server=False): sslSock.do_handshake() break except ssl.SSLWantReadError: - print "Waiting for SSL socket handhake read" + print("Waiting for SSL socket handhake read") select.select([sslSock], [], [], 10) except ssl.SSLWantWriteError: - print "Waiting for SSL socket handhake write" + print("Waiting for SSL socket handhake write") select.select([], [sslSock], [], 10) except Exception: - print "SSL socket handhake failed, shutting down connection" + print("SSL socket handhake failed, shutting down connection") traceback.print_exc() return - print "Success!" + print("Success!") return sslSock if __name__ == "__main__": if len(sys.argv) != 2: - print "Usage: ssltest.py client|server" + print("Usage: ssltest.py client|server") sys.exit(0) elif sys.argv[1] == "server": serversock = listen() while True: - print "Waiting for connection" + print("Waiting for connection") sock, addr = serversock.accept() - print "Got connection from %s:%i" % (addr[0], addr[1]) + print("Got connection from %s:%i" % (addr[0], addr[1])) sslSock = sslHandshake(sock, True) if sslSock: sslSock.shutdown(socket.SHUT_RDWR) @@ -99,5 +100,5 @@ if __name__ == "__main__": sslSock.shutdown(socket.SHUT_RDWR) sslSock.close() else: - print "Usage: ssltest.py client|server" + print("Usage: ssltest.py client|server") sys.exit(0)