From 8e6c2f3cfd80ebe438adde26ae17736c4e157246 Mon Sep 17 00:00:00 2001 From: lakshyacis Date: Sat, 18 Jan 2020 17:13:06 +0530 Subject: [PATCH] Kivy database and safegetint issues --- src/bitmessagekivy/mpybit.py | 6 +++--- src/class_addressGenerator.py | 9 ++------- src/knownnodes.py | 13 +++++++++---- src/network/bmproto.py | 2 +- src/network/connectionpool.py | 10 +++++----- src/shared.py | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 853302c3..865fc780 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -647,8 +647,8 @@ class DropDownWidget(BoxLayout): 0, 'sent', encoding, - int(BMConfigParser().safeGet( - 'bitmessagesettings', 'ttl'))) + BMConfigParser().safeGetInt( + 'bitmessagesettings', 'ttl')) state.check_sent_acc = fromAddress # state.msg_counter_objs = self.parent.parent.parent.parent\ # .parent.parent.children[2].children[0].ids @@ -2331,7 +2331,7 @@ class Draft(Screen): 0, 'draft', encoding, - int(BMConfigParser().safeGet('bitmessagesettings', 'ttl'))) + BMConfigParser().safeGetInt('bitmessagesettings', 'ttl')) state.msg_counter_objs = src_object.children[2].children[0].ids state.draft_count = str(int(state.draft_count) + 1) src_object.ids.sc16.clear_widgets() diff --git a/src/class_addressGenerator.py b/src/class_addressGenerator.py index 1f60e051..179ba349 100644 --- a/src/class_addressGenerator.py +++ b/src/class_addressGenerator.py @@ -116,9 +116,7 @@ class addressGenerator(StoppableThread): payloadLengthExtraBytes = \ defaults.networkDefaultPayloadLengthExtraBytes if command == 'createRandomAddress': - queues.UISignalQueue.put(( - 'updateStatusBar' - )) + queues.UISignalQueue.put(('updateStatusBar', None)) # This next section is a little bit strange. We're going # to generate keys over and over until we find one # that starts with either \x00 or \x00\x00. Then when @@ -192,10 +190,7 @@ class addressGenerator(StoppableThread): # The API and the join and create Chan functionality # both need information back from the address generator. queues.apiAddressGeneratorReturnQueue.put(address) - - queues.UISignalQueue.put(( - 'updateStatusBar' - )) + queues.UISignalQueue.put(('updateStatusBar', None)) queues.UISignalQueue.put(('writeNewAddressToTable', ( label, address, streamNumber))) shared.reloadMyAddressHashes() diff --git a/src/knownnodes.py b/src/knownnodes.py index c1d56ccc..f8007bb6 100644 --- a/src/knownnodes.py +++ b/src/knownnodes.py @@ -49,9 +49,14 @@ def json_serialize_knownnodes(output): for stream, peers in iter(knownNodes.items()): for peer, info in iter(peers.items()): info.update(rating=round(info.get('rating', 0), 2)) - _serialized.append({ - 'stream': stream, 'peer': peer._asdict(), 'info': info - }) + if type(peer[0]) != bytes: + _serialized.append({'stream': stream, 'peer': peer._asdict(), 'info': info}) + else: + from collections import OrderedDict + _serialized.append({ + 'stream': stream, + 'peer': OrderedDict({'host': str(peer[0].decode()), 'port': int(peer[1])}), + 'info': info}) json.dump(_serialized, output, indent=4) @@ -171,7 +176,7 @@ def decreaseRating(peer): def trimKnownNodes(recAddrStream=1): """Triming Knownnodes""" if len(knownNodes[recAddrStream]) < \ - int(BMConfigParser().safeGet("knownnodes", "maxnodes")): + BMConfigParser().safeGetInt("knownnodes", "maxnodes"): return with knownNodesLock: oldestList = sorted( diff --git a/src/network/bmproto.py b/src/network/bmproto.py index a5da6b86..5c57748a 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -480,7 +480,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): continue except KeyError: pass - if len(knownnodes.knownNodes[stream]) < int(BMConfigParser().safeGet("knownnodes", "maxnodes")): + if len(knownnodes.knownNodes[stream]) < BMConfigParser().safeGetInt("knownnodes", "maxnodes"): with knownnodes.knownNodesLock: try: knownnodes.knownNodes[stream][peer]["lastseen"] = \ diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index bbb09d7e..82bf20a5 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -192,7 +192,7 @@ class BMConnectionPool(object): if bind is None: "this return blank host" bind = self.getListeningIP() - port = int(BMConfigParser().safeGet("bitmessagesettings", "port")) + port = BMConfigParser().safeGetInt("bitmessagesettings", "port") # correct port even if it changed ls = TCPServer(host=bind, port=port) self.listeningSockets[ls.destination] = ls @@ -274,8 +274,8 @@ class BMConnectionPool(object): Proxy.proxy = ( BMConfigParser().safeGet( 'bitmessagesettings', 'sockshostname'), - int(BMConfigParser().safeGet( - 'bitmessagesettings', 'socksport')) + BMConfigParser().safeGetInt( + 'bitmessagesettings', 'socksport') ) # TODO AUTH # TODO reset based on GUI settings changes @@ -294,8 +294,8 @@ class BMConnectionPool(object): 1 for c in [outboundConnections for outboundConnections in self.outboundConnections.values()] if (c.connected and c.fullyEstablished)) pending = len(self.outboundConnections) - established - if established < int(BMConfigParser().safeGet( - 'bitmessagesettings', 'maxoutboundconnections')): + if established < BMConfigParser().safeGetInt( + 'bitmessagesettings', 'maxoutboundconnections'): for i in range( state.maximumNumberOfHalfOpenConnections - pending): try: diff --git a/src/shared.py b/src/shared.py index 98f47d19..b1a19c08 100644 --- a/src/shared.py +++ b/src/shared.py @@ -241,7 +241,7 @@ def checkSensitiveFilePermissions(filename): shell=True, stderr=subprocess.STDOUT ) - if 'fuseblk' in fstype: + if 'fuseblk'.encode() in fstype: logger.info( 'Skipping file permissions check for %s.' ' Filesystem fuseblk detected.', filename)