Fixed pylint & removed obsolete file

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-11-08 21:39:59 +05:30
parent 44d42c637d
commit d085d23577
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A
4 changed files with 25 additions and 51 deletions

View File

@ -52,15 +52,15 @@ for row in cur.fetchall():
# f.close() # f.close()
print "Item count: %i" % (itemcount) print("Item count: %i" % (itemcount))
print "Raw length: %i" % (rawlen) print("Raw length: %i" % (rawlen))
print "Bloom filter 1 length: %i, reduction to: %.2f%%" % \ print("Bloom filter 1 length: %i, reduction to: %.2f%%" %
(bf1.bitarray.buffer_info()[1], (bf1.bitarray.buffer_info()[1],
100.0 * bf1.bitarray.buffer_info()[1] / rawlen) 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 capacity: %i and error rate: %.3f%%" % (bf1.capacity, 100.0 * bf1.error_rate))
print "Bloom filter 1 took %.2fs" % (bf1time) print("Bloom filter 1 took %.2fs" % (bf1time))
print "Bloom filter 2 length: %i, reduction to: %.3f%%" % \ print("Bloom filter 2 length: %i, reduction to: %.3f%%" %
(bf2.num_bits / 8, (bf2.num_bits / 8,
100.0 * bf2.num_bits / 8 / rawlen) 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 capacity: %i and error rate: %.3f%%" % (bf2.capacity, 100.0 * bf2.error_rate))
print "Bloom filter 2 took %.2fs" % (bf2time) print("Bloom filter 2 took %.2fs" % (bf2time))

View File

@ -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())

View File

@ -11,7 +11,7 @@ shutdown = 0
def signal_handler(signal, frame): def signal_handler(signal, frame):
global shutdown 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": if current_process().name != "MainProcess":
raise StopIteration("Interrupted") raise StopIteration("Interrupted")
if current_thread().name != "PyBitmessage": if current_thread().name != "PyBitmessage":
@ -25,16 +25,16 @@ def _doCPoW(target, initialHash):
m = target m = target
out_h = ctypes.pointer(ctypes.create_string_buffer(h, 64)) out_h = ctypes.pointer(ctypes.create_string_buffer(h, 64))
out_m = ctypes.c_ulonglong(m) out_m = ctypes.c_ulonglong(m)
print "C PoW start" print("C PoW start")
for c in range(0, 200000): for c in range(0, 200000):
print "Iter: %i" % (c) print("Iter: %i" % (c))
nonce = bmpow(out_h, out_m) nonce = bmpow(out_h, out_m)
if shutdown: if shutdown:
break break
trialValue, = unpack('>Q', hashlib.sha512(hashlib.sha512(pack('>Q', nonce) + initialHash).digest()).digest()[0:8]) trialValue, = unpack('>Q', hashlib.sha512(hashlib.sha512(pack('>Q', nonce) + initialHash).digest()).digest()[0:8])
if shutdown != 0: if shutdown != 0:
raise StopIteration("Interrupted") raise StopIteration("Interrupted")
print "C PoW done" print("C PoW done")
return [trialValue, nonce] return [trialValue, nonce]

View File

@ -52,7 +52,8 @@ def sslHandshake(sock, server=False):
context.set_ecdh_curve("secp256k1") context.set_ecdh_curve("secp256k1")
context.check_hostname = False context.check_hostname = False
context.verify_mode = ssl.CERT_NONE 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) sslSock = context.wrap_socket(sock, server_side=server, do_handshake_on_connect=False)
else: else:
sslSock = ssl.wrap_socket(sock, keyfile=os.path.join('src', 'sslkeys', 'key.pem'), 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() sslSock.do_handshake()
break break
except ssl.SSLWantReadError: except ssl.SSLWantReadError:
print "Waiting for SSL socket handhake read" print("Waiting for SSL socket handhake read")
select.select([sslSock], [], [], 10) select.select([sslSock], [], [], 10)
except ssl.SSLWantWriteError: except ssl.SSLWantWriteError:
print "Waiting for SSL socket handhake write" print("Waiting for SSL socket handhake write")
select.select([], [sslSock], [], 10) select.select([], [sslSock], [], 10)
except Exception: except Exception:
print "SSL socket handhake failed, shutting down connection" print("SSL socket handhake failed, shutting down connection")
traceback.print_exc() traceback.print_exc()
return return
print "Success!" print("Success!")
return sslSock return sslSock
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) != 2: if len(sys.argv) != 2:
print "Usage: ssltest.py client|server" print("Usage: ssltest.py client|server")
sys.exit(0) sys.exit(0)
elif sys.argv[1] == "server": elif sys.argv[1] == "server":
serversock = listen() serversock = listen()
while True: while True:
print "Waiting for connection" print("Waiting for connection")
sock, addr = serversock.accept() 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) sslSock = sslHandshake(sock, True)
if sslSock: if sslSock:
sslSock.shutdown(socket.SHUT_RDWR) sslSock.shutdown(socket.SHUT_RDWR)
@ -99,5 +100,5 @@ if __name__ == "__main__":
sslSock.shutdown(socket.SHUT_RDWR) sslSock.shutdown(socket.SHUT_RDWR)
sslSock.close() sslSock.close()
else: else:
print "Usage: ssltest.py client|server" print("Usage: ssltest.py client|server")
sys.exit(0) sys.exit(0)