Kivy database and safegetint issues

This commit is contained in:
lakshyacis 2020-01-18 17:13:06 +05:30
parent 946cfe4627
commit 8e6c2f3cfd
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
6 changed files with 21 additions and 21 deletions

View File

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

View File

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

View File

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

View File

@ -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"] = \

View File

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

View File

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