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, ''
# after converting to hex, the string will be prepended
# with a 0x and appended with a L
# import pdb;pdb.set_trace()
hexdata = hex(integer)[2:]
if len(hexdata) % 2 != 0:

View File

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

View File

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

View File

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

View File

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

View File

@ -13,12 +13,10 @@ from pyelliptic import arithmetic as a
def makeCryptor(privkey):
"""Return a private pyelliptic.ECC() instance"""
# import pdb;pdb.set_trace()
private_key = a.changebase(privkey, 16, 256, minlen=32)
public_key = pointMult(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:]
import pdb;pdb.set_trace()
cryptor = pyelliptic.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin)
return cryptor

View File

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

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ class DownloadThread(StoppableThread):
"""Expire pending downloads eventually"""
deadline = time.time() - DownloadThread.requestExpires
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:
pass
else:
@ -46,7 +46,7 @@ class DownloadThread(StoppableThread):
# Choose downloading peers randomly
connections = [
x for x in
BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values()
list(BMConnectionPool().inboundConnections.values()) + list(BMConnectionPool().outboundConnections.values())
if x.fullyEstablished]
helper_random.randomshuffle(connections)
try:

View File

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

View File

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

View File

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

View File

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

View File

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