Solved bmconfigparser python3 incompatibility issue and removed unrequired comment and line of code which are added during python3 plotting

This commit is contained in:
jai.s 2019-10-03 20:27:22 +05:30
parent 42ee9d910b
commit c813f679ae
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
16 changed files with 28 additions and 54 deletions

View File

@ -191,7 +191,6 @@ def decodeAddress(address):
return status, 0, 0, '' return status, 0, 0, ''
# after converting to hex, the string will be prepended # after converting to hex, the string will be prepended
# with a 0x and appended with a L # with a 0x and appended with a L
# import pdb;pdb.set_trace()
hexdata = hex(integer)[2:] hexdata = hex(integer)[2:]
if len(hexdata) % 2 != 0: if len(hexdata) % 2 != 0:

View File

@ -93,7 +93,7 @@ class Inbox(Screen):
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts.""" """Clock Schdule for method inbox accounts."""
self.inboxaccounts() self.inboxaccounts()
print (dt) print(dt)
def inboxaccounts(self): def inboxaccounts(self):
"""Load inbox accounts.""" """Load inbox accounts."""
@ -309,6 +309,7 @@ class MyAddress(Screen):
self.init_ui() self.init_ui()
self.ids.refresh_layout.refresh_done() self.ids.refresh_layout.refresh_done()
self.tick = 0 self.tick = 0
Clock.schedule_once(refresh_callback, 1) Clock.schedule_once(refresh_callback, 1)
@staticmethod @staticmethod

View File

@ -200,7 +200,6 @@ class Main: # pylint: disable=no-init, old-style-class
from plugins.plugin import get_plugin from plugins.plugin import get_plugin
try: try:
proxyconfig_start = time.time() proxyconfig_start = time.time()
import pdb;pdb.set_trace
if not get_plugin('proxyconfig', name=proxy_type)(config): if not get_plugin('proxyconfig', name=proxy_type)(config):
raise TypeError raise TypeError
except TypeError: except TypeError:

View File

@ -125,10 +125,12 @@ class BMConfigParser(configparser.ConfigParser):
try: try:
if not self.validate( if not self.validate(
section, option, section, option,
configparser.ConfigParser.get(self, section, option) self[section][option]
): ):
try: try:
newVal = BMConfigDefaults[section][option] newVal = BMConfigDefaults[section][option]
except configparser.NoSectionError:
continue
except KeyError: except KeyError:
continue continue
configparser.ConfigParser.set( configparser.ConfigParser.set(
@ -159,7 +161,7 @@ class BMConfigParser(configparser.ConfigParser):
def validate(self, section, option, value): def validate(self, section, option, value):
try: try:
return getattr(self, 'validate_%s_%s' % (section, option))(value) return getattr(self, 'validate_{}_{}'.format(section, option))(value)
except AttributeError: except AttributeError:
return True return True

View File

@ -33,7 +33,7 @@ def _loadTrustedPeer():
# can just leave it as None # can just leave it as None
return return
try: try:
# import pdb;pdb.set_trace()
if trustedPeer != None: if trustedPeer != None:
host, port = trustedPeer.split(':') host, port = trustedPeer.split(':')
state.trustedPeer = state.Peer(host, int(port)) state.trustedPeer = state.Peer(host, int(port))

View File

@ -13,12 +13,10 @@ from pyelliptic import arithmetic as a
def makeCryptor(privkey): def makeCryptor(privkey):
"""Return a private pyelliptic.ECC() instance""" """Return a private pyelliptic.ECC() instance"""
# import pdb;pdb.set_trace()
private_key = a.changebase(privkey, 16, 256, minlen=32) private_key = a.changebase(privkey, 16, 256, minlen=32)
public_key = pointMult(private_key) public_key = pointMult(private_key)
privkey_bin = '\x02\xca\x00\x20'.encode('utf-8') + private_key privkey_bin = '\x02\xca\x00\x20'.encode('utf-8') + private_key
pubkey_bin = '\x02\xca\x00\x20'.encode('utf-8') + public_key[1:-32] + '\x00\x20'.encode('utf-8') + public_key[-32:] pubkey_bin = '\x02\xca\x00\x20'.encode('utf-8') + public_key[1:-32] + '\x00\x20'.encode('utf-8') + public_key[-32:]
import pdb;pdb.set_trace()
cryptor = pyelliptic.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin) cryptor = pyelliptic.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin)
return cryptor return cryptor

View File

@ -46,7 +46,6 @@ def json_serialize_knownnodes(output):
_serialized.append({ _serialized.append({
'stream': stream, 'peer': peer._asdict(), 'info': info 'stream': stream, 'peer': peer._asdict(), 'info': info
}) })
# import pdb;pdb.set_trace()
json.dump(_serialized, output, indent=4) json.dump(_serialized, output, indent=4)
@ -55,7 +54,6 @@ def json_deserialize_knownnodes(source):
Read JSON from source and make knownnodes dict Read JSON from source and make knownnodes dict
""" """
global knownNodesActual # pylint: disable=global-statement global knownNodesActual # pylint: disable=global-statement
# import pdb;pdb.set_trace()
for node in json.load(source): for node in json.load(source):
peer = node['peer'] peer = node['peer']
info = node['info'] info = node['info']

View File

@ -767,7 +767,6 @@ class dispatcher:
# references to the underlying socket object. # references to the underlying socket object.
def __getattr__(self, attr): def __getattr__(self, attr):
try: try:
# import pdb;pdb.set_trace()
retattr = getattr(self.socket, attr) retattr = getattr(self.socket, attr)
except AttributeError: except AttributeError:
raise AttributeError("{} instance has no attribute {}" raise AttributeError("{} instance has no attribute {}"

View File

@ -236,7 +236,7 @@ class BMConnectionPool(object):
except ValueError: except ValueError:
Proxy.onion_proxy = None Proxy.onion_proxy = None
established = sum( established = sum(
1 for c in self.outboundConnections.values() 1 for c in list(self.outboundConnections.values())
if (c.connected and c.fullyEstablished)) if (c.connected and c.fullyEstablished))
pending = len(self.outboundConnections) - established pending = len(self.outboundConnections) - established
if established < BMConfigParser().safeGetInt( if established < BMConfigParser().safeGetInt(

View File

@ -99,12 +99,12 @@ class Dandelion(): # pylint: disable=old-style-class
with self.lock: with self.lock:
if len(self.stem) < MAX_STEMS: if len(self.stem) < MAX_STEMS:
self.stem.append(connection) self.stem.append(connection)
for k in (k for k, v in self.nodeMap.iteritems() if v is None): for k in (k for k, v in iter(self.nodeMap.items()) if v is None):
self.nodeMap[k] = connection self.nodeMap[k] = connection
for k, v in { for k, v in iter({
k: v for k, v in self.hashMap.iteritems() k: v for k, v in iter(self.hashMap.items())
if v.child is None if v.child is None
}.iteritems(): }).items():
self.hashMap[k] = Stem( self.hashMap[k] = Stem(
connection, v.stream, self.poissonTimeout()) connection, v.stream, self.poissonTimeout())
invQueue.put((v.stream, k, v.child)) invQueue.put((v.stream, k, v.child))
@ -120,13 +120,13 @@ class Dandelion(): # pylint: disable=old-style-class
self.stem.remove(connection) self.stem.remove(connection)
# active mappings to pointing to the removed node # active mappings to pointing to the removed node
for k in ( for k in (
k for k, v in self.nodeMap.iteritems() if v == connection k for k, v in iter(self.nodeMap.items()) if v == connection
): ):
self.nodeMap[k] = None self.nodeMap[k] = None
for k, v in { for k, v in iter({
k: v for k, v in self.hashMap.iteritems() k: v for k, v in iter(self.hashMap.items())
if v.child == connection if v.child == connection
}.iteritems(): }).items():
self.hashMap[k] = Stem( self.hashMap[k] = Stem(
None, v.stream, self.poissonTimeout()) None, v.stream, self.poissonTimeout())
@ -167,7 +167,7 @@ class Dandelion(): # pylint: disable=old-style-class
with self.lock: with self.lock:
deadline = time() deadline = time()
toDelete = [ toDelete = [
[v.stream, k, v.child] for k, v in self.hashMap.iteritems() [v.stream, k, v.child] for k, v in iter(self.hashMap.items())
if v.timeout < deadline if v.timeout < deadline
] ]

View File

@ -32,7 +32,7 @@ class DownloadThread(StoppableThread):
"""Expire pending downloads eventually""" """Expire pending downloads eventually"""
deadline = time.time() - DownloadThread.requestExpires deadline = time.time() - DownloadThread.requestExpires
try: try:
toDelete = [k for k, v in missingObjects.iteritems() if v < deadline] toDelete = [k for k, v in iter(missingObjects.items()) if v < deadline]
except RuntimeError: except RuntimeError:
pass pass
else: else:
@ -46,7 +46,7 @@ class DownloadThread(StoppableThread):
# Choose downloading peers randomly # Choose downloading peers randomly
connections = [ connections = [
x for x in x for x in
BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values() list(BMConnectionPool().inboundConnections.values()) + list(BMConnectionPool().outboundConnections.values())
if x.fullyEstablished] if x.fullyEstablished]
helper_random.randomshuffle(connections) helper_random.randomshuffle(connections)
try: try:

View File

@ -20,7 +20,6 @@ currentSentSpeed = 0
def connectedHostsList(): def connectedHostsList():
"""List of all the connected hosts""" """List of all the connected hosts"""
retval = [] retval = []
# import pdb;pdb.set_trace()
for i in list(BMConnectionPool().inboundConnections.values()) + \ for i in list(BMConnectionPool().inboundConnections.values()) + \
list(BMConnectionPool().outboundConnections.values()): list(BMConnectionPool().outboundConnections.values()):
if not i.fullyEstablished: if not i.fullyEstablished:

View File

@ -26,8 +26,8 @@ class UploadThread(StoppableThread):
while not self._stopped: while not self._stopped:
uploaded = 0 uploaded = 0
# Choose downloading peers randomly # Choose downloading peers randomly
connections = [x for x in BMConnectionPool().inboundConnections.values() + connections = [x for x in list(BMConnectionPool().inboundConnections.values()) +
BMConnectionPool().outboundConnections.values() if x.fullyEstablished] list(BMConnectionPool().outboundConnections.values()) if x.fullyEstablished]
helper_random.randomshuffle(connections) helper_random.randomshuffle(connections)
for i in connections: for i in connections:
now = time.time() now = time.time()

View File

@ -42,14 +42,10 @@ def encode(val, base, minlen=0):
result = "" result = ""
result = str.encode(result) result = str.encode(result)
count = 0 count = 0
# import pdb;pdb.set_trace()
while val > 0: while val > 0:
count += 1 count += 1
# import pdb;pdb.set_trace()
result = code_string[int(val) % base:int(val) % base + 1] + result result = code_string[int(val) % base:int(val) % base + 1] + result
# print('the value of the result-{}'.format(result))
val = int(val / base) val = int(val / base)
# import pdb;pdb.set_trace()
if len(result) < minlen: if len(result) < minlen:
result = code_string[0] * (minlen - len(result)) + result result = code_string[0] * (minlen - len(result)) + result
return result return result
@ -62,7 +58,6 @@ def decode(string, base):
if base == 16: if base == 16:
string = string.lower() string = string.lower()
while string: while string:
# import pdb;pdb.set_trace()
result *= base result *= base
result += code_string.find(string.decode()[0]) result += code_string.find(string.decode()[0])
string = string[1:] string = string[1:]
@ -70,7 +65,6 @@ def decode(string, base):
def changebase(string, frm, to, minlen=0): def changebase(string, frm, to, minlen=0):
# import pdb;pdb.set_trace()
return encode(decode(string, frm), to, minlen) return encode(decode(string, frm), to, minlen)

View File

@ -74,13 +74,11 @@ class ECC(object):
if curve != curve2: if curve != curve2:
raise Exception("Bad ECC keys ...") raise Exception("Bad ECC keys ...")
self.curve = curve self.curve = curve
import pdb;pdb.set_trace()
self._set_keys(pubkey_x, pubkey_y, raw_privkey) self._set_keys(pubkey_x, pubkey_y, raw_privkey)
else: else:
self.privkey, self.pubkey_x, self.pubkey_y = self._generate() self.privkey, self.pubkey_x, self.pubkey_y = self._generate()
def _set_keys(self, pubkey_x, pubkey_y, privkey): def _set_keys(self, pubkey_x, pubkey_y, privkey):
import pdb;pdb.set_trace()
if self.raw_check_key(privkey, pubkey_x, pubkey_y) < 0: if self.raw_check_key(privkey, pubkey_x, pubkey_y) < 0:
self.pubkey_x = None self.pubkey_x = None
self.pubkey_y = None self.pubkey_y = None
@ -132,35 +130,25 @@ class ECC(object):
@staticmethod @staticmethod
def _decode_pubkey(pubkey): def _decode_pubkey(pubkey):
# pubkey = pubkey.encode()
import pdb;pdb.set_trace()
i = 0 i = 0
# curve = unpack('!H', pubkey[i:i + 2])[0] curve = unpack('!H', pubkey[i:i + 2])[0]
curve = pack('!s', pubkey[i:i + 1])[0]
i += 2 i += 2
# tmplen = unpack('!H', pubkey[i:i + 2])[0] tmplen = unpack('!H', pubkey[i:i + 2])[0]
tmplen = pack('!s', pubkey[i:i + 1])[0]
i += 2 i += 2
pubkey_x = pubkey[i:i + tmplen] pubkey_x = pubkey[i:i + tmplen]
# i += tmplen i += tmplen
i += int(tmplen / 3) i += int(tmplen / 3)
# tmplen = unpack('!H', pubkey[i:i + 2])[0] tmplen = unpack('!H', pubkey[i:i + 2])[0]
tmplen = pack('!s', pubkey[i:i + 1])[0] i += 2
# i += 2
pubkey_y = pubkey[i:i + tmplen] pubkey_y = pubkey[i:i + tmplen]
# i += tmplen i += tmplen
return curve, pubkey_x, pubkey_y, int(i) return curve, pubkey_x, pubkey_y, int(i)
@staticmethod @staticmethod
def _decode_privkey(privkey): def _decode_privkey(privkey):
i = 0 i = 0
# import pdb;pdb.set_trace() curve = unpack('!H', privkey[i:i + 2])[0]
# curve = unpack('!H', privkey[i:i + 2])[0]
curve = pack('!s', privkey[i:i + 1])[0]
i += 2 i += 2
# tmplen = unpack('!H', privkey[i:i + 2])[0]
tmplen = pack('!s', privkey[i:i + 1])[0] tmplen = pack('!s', privkey[i:i + 1])[0]
i += 2 i += 2
privkey = privkey[i:i + tmplen] privkey = privkey[i:i + tmplen]
@ -288,7 +276,6 @@ class ECC(object):
return self.raw_check_key(raw_privkey, pubkey_x, pubkey_y, curve) return self.raw_check_key(raw_privkey, pubkey_x, pubkey_y, curve)
def raw_check_key(self, privkey, pubkey_x, pubkey_y, curve=None): def raw_check_key(self, privkey, pubkey_x, pubkey_y, curve=None):
import pdb;pdb.set_trace()
"""Check key validity, key is supplied as binary data""" """Check key validity, key is supplied as binary data"""
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
if curve is None: if curve is None:

View File

@ -174,11 +174,9 @@ def reloadBroadcastSendersForWhichImWatching():
# Now, for all addresses, even version 2 addresses, # Now, for all addresses, even version 2 addresses,
# we should create Cryptor objects in a dictionary which we will # we should create Cryptor objects in a dictionary which we will
# use to attempt to decrypt encrypted broadcast messages. # use to attempt to decrypt encrypted broadcast messages.
# import pdb;pdb.set_trace()
if addressVersionNumber <= 3: if addressVersionNumber <= 3:
privEncryptionKey = hashlib.sha512((encodeVarint(addressVersionNumber) \ privEncryptionKey = hashlib.sha512((encodeVarint(addressVersionNumber) \
+ encodeVarint(streamNumber) + hash)).digest()[:32] + encodeVarint(streamNumber) + hash)).digest()[:32]
# import pdb;pdb.set_trace()
MyECSubscriptionCryptorObjects[hash] = \ MyECSubscriptionCryptorObjects[hash] = \
highlevelcrypto.makeCryptor(hexlify(privEncryptionKey)) highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))
else: else: