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

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):
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]

View File

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