Refactord the uuid creation code and placed it in helper_sent.insert method
refactored on the bases of comments Fixed CQ of src.helper_sent module fixed CQ for helper_sent module
This commit is contained in:
parent
881351033f
commit
e60d12ddbf
|
@ -19,6 +19,7 @@ from textwrap import fill
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
|
|
||||||
from dialog import Dialog
|
from dialog import Dialog
|
||||||
|
import helper_sent
|
||||||
import l10n
|
import l10n
|
||||||
import network.stats
|
import network.stats
|
||||||
import queues
|
import queues
|
||||||
|
@ -32,8 +33,6 @@ from helper_ackPayload import genAckPayload
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from inventory import Inventory
|
from inventory import Inventory
|
||||||
|
|
||||||
import uuid
|
|
||||||
import helper_sent
|
|
||||||
# pylint: disable=global-statement
|
# pylint: disable=global-statement
|
||||||
|
|
||||||
|
|
||||||
|
@ -969,9 +968,8 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
scrollbox(d, unicode("Because you are not currently connected to the network, "))
|
scrollbox(d, unicode("Because you are not currently connected to the network, "))
|
||||||
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
|
||||||
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
|
ackdata = genAckPayload(decodeAddress(addr)[2], stealthLevel)
|
||||||
msgid = uuid.uuid4().bytes
|
|
||||||
t = (
|
t = (
|
||||||
msgid,
|
'',
|
||||||
addr,
|
addr,
|
||||||
ripe,
|
ripe,
|
||||||
sender,
|
sender,
|
||||||
|
@ -985,7 +983,7 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
0, # retryNumber
|
0, # retryNumber
|
||||||
"sent",
|
"sent",
|
||||||
2, # encodingType
|
2, # encodingType
|
||||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
0
|
||||||
)
|
)
|
||||||
helper_sent.insert(t)
|
helper_sent.insert(t)
|
||||||
queues.workerQueue.put(("sendmessage", addr))
|
queues.workerQueue.put(("sendmessage", addr))
|
||||||
|
@ -998,9 +996,8 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
|
ackdata = genAckPayload(decodeAddress(addr)[2], 0)
|
||||||
recv = BROADCAST_STR
|
recv = BROADCAST_STR
|
||||||
ripe = ""
|
ripe = ""
|
||||||
msgid = uuid.uuid4().bytes
|
|
||||||
t = (
|
t = (
|
||||||
msgid,
|
'',
|
||||||
recv,
|
recv,
|
||||||
ripe,
|
ripe,
|
||||||
sender,
|
sender,
|
||||||
|
@ -1014,7 +1011,7 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
|
||||||
0, # retryNumber
|
0, # retryNumber
|
||||||
"sent", # folder
|
"sent", # folder
|
||||||
2, # encodingType
|
2, # encodingType
|
||||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
0
|
||||||
)
|
)
|
||||||
helper_sent.insert(t)
|
helper_sent.insert(t)
|
||||||
queues.workerQueue.put(('sendbroadcast', ''))
|
queues.workerQueue.put(('sendbroadcast', ''))
|
||||||
|
|
|
@ -54,7 +54,6 @@ from statusbar import BMStatusBar
|
||||||
import sound
|
import sound
|
||||||
# This is needed for tray icon
|
# This is needed for tray icon
|
||||||
import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
|
import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
|
||||||
import uuid
|
|
||||||
import helper_sent
|
import helper_sent
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -2167,9 +2166,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
stealthLevel = BMConfigParser().safeGetInt(
|
stealthLevel = BMConfigParser().safeGetInt(
|
||||||
'bitmessagesettings', 'ackstealthlevel')
|
'bitmessagesettings', 'ackstealthlevel')
|
||||||
ackdata = genAckPayload(streamNumber, stealthLevel)
|
ackdata = genAckPayload(streamNumber, stealthLevel)
|
||||||
msgid = uuid.uuid4().bytes
|
|
||||||
t = (
|
t = (
|
||||||
msgid,
|
'',
|
||||||
toAddress,
|
toAddress,
|
||||||
ripe,
|
ripe,
|
||||||
fromAddress,
|
fromAddress,
|
||||||
|
@ -2183,7 +2181,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
0, # retryNumber
|
0, # retryNumber
|
||||||
'sent', # folder
|
'sent', # folder
|
||||||
encoding, # encodingtype
|
encoding, # encodingtype
|
||||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
0
|
||||||
)
|
)
|
||||||
helper_sent.insert(t)
|
helper_sent.insert(t)
|
||||||
toLabel = ''
|
toLabel = ''
|
||||||
|
@ -2223,8 +2221,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
ackdata = genAckPayload(streamNumber, 0)
|
ackdata = genAckPayload(streamNumber, 0)
|
||||||
toAddress = str_broadcast_subscribers
|
toAddress = str_broadcast_subscribers
|
||||||
ripe = ''
|
ripe = ''
|
||||||
msgid = uuid.uuid4().bytes
|
t = ('', # msgid. We don't know what this will be until the POW is done.
|
||||||
t = (msgid, # msgid. We don't know what this will be until the POW is done.
|
|
||||||
toAddress,
|
toAddress,
|
||||||
ripe,
|
ripe,
|
||||||
fromAddress,
|
fromAddress,
|
||||||
|
@ -2238,7 +2235,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
0, # retryNumber
|
0, # retryNumber
|
||||||
'sent', # folder
|
'sent', # folder
|
||||||
encoding, # encoding type
|
encoding, # encoding type
|
||||||
BMConfigParser().getint('bitmessagesettings', 'ttl')
|
0
|
||||||
)
|
)
|
||||||
helper_sent.insert(t)
|
helper_sent.insert(t)
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,20 @@
|
||||||
Insert values into sent table
|
Insert values into sent table
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
from bmconfigparser import BMConfigParser
|
||||||
from helper_sql import sqlExecute
|
from helper_sql import sqlExecute
|
||||||
|
|
||||||
|
|
||||||
def insert(t):
|
def insert(t):
|
||||||
"""Perform an insert into the `sent` table"""
|
"""Perform an insert into the `sent` table"""
|
||||||
|
if not t[0] or not t[-1]:
|
||||||
|
temp = list(t)
|
||||||
|
if not t[0]:
|
||||||
|
print('zero index is not available')
|
||||||
|
temp[0] = uuid.uuid4().bytes # if msgid is empty the put uuid
|
||||||
|
if not t[-1]:
|
||||||
|
print('Lasr index is not available')
|
||||||
|
temp[-1] = BMConfigParser().getint('bitmessagesettings', 'ttl')
|
||||||
|
t = tuple(temp)
|
||||||
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
||||||
|
|
Reference in New Issue
Block a user