quality fixes after pull
This commit is contained in:
parent
ee6f8f0fa7
commit
6650876b57
35
src/api.py
35
src/api.py
|
@ -3,16 +3,9 @@ This is not what you run to run the Bitmessage API. Instead, enable the API
|
|||
( https://bitmessage.org/wiki/API ) and optionally enable daemon mode
|
||||
( https://bitmessage.org/wiki/Daemon ) then run bitmessagemain.py.
|
||||
"""
|
||||
<<<<<<< HEAD
|
||||
# Copyright (c) 2012-2016 Jonathan Warren
|
||||
# Copyright (c) 2012-2020 The Bitmessage developers
|
||||
# pylint: disable=too-many-lines,no-self-use,unused-variable,unused-argument
|
||||
=======
|
||||
# pylint: disable=too-many-locals,too-many-lines,no-self-use,unused-argument
|
||||
# pylint: disable=too-many-statements,too-many-public-methods,too-many-branches
|
||||
# Copyright (c) 2012-2016 Jonathan Warren
|
||||
# Copyright (c) 2012-2019 The Bitmessage developers
|
||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
||||
import base64
|
||||
import errno
|
||||
import hashlib
|
||||
|
@ -34,7 +27,6 @@ import queues
|
|||
import shared
|
||||
import shutdown
|
||||
import state
|
||||
<<<<<<< HEAD
|
||||
from addresses import (
|
||||
addBMIfNotPresent,
|
||||
calculateInventoryHash,
|
||||
|
@ -42,21 +34,13 @@ from addresses import (
|
|||
decodeVarint,
|
||||
varintDecodeError
|
||||
)
|
||||
=======
|
||||
|
||||
from addresses import addBMIfNotPresent, calculateInventoryHash, decodeAddress, decodeVarint, varintDecodeError
|
||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
||||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger
|
||||
from helper_ackPayload import genAckPayload
|
||||
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure
|
||||
from inventory import Inventory
|
||||
from network.threads import StoppableThread
|
||||
<<<<<<< HEAD
|
||||
from version import softwareVersion
|
||||
=======
|
||||
# pylint: disable=unused-variable
|
||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
||||
|
||||
str_chan = '[chan]'
|
||||
|
||||
|
@ -275,13 +259,9 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
raise APIError(9, 'Invalid characters in address: ' + address)
|
||||
if status == 'versiontoohigh':
|
||||
raise APIError(
|
||||
<<<<<<< HEAD
|
||||
10,
|
||||
'Address version number too high (or zero) in address: ' +
|
||||
address)
|
||||
=======
|
||||
10, 'Address version number too high (or zero) in address: ' + address)
|
||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
||||
if status == 'varintmalformed':
|
||||
raise APIError(26, 'Malformed varint in address: ' + address)
|
||||
raise APIError(
|
||||
|
@ -645,13 +625,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
label = str_chan + ' ' + passphrase
|
||||
except BaseException:
|
||||
label = str_chan + ' ' + repr(passphrase)
|
||||
<<<<<<< HEAD
|
||||
status, addressVersionNumber, streamNumber, toRipe = (
|
||||
self._verifyAddress(suppliedAddress))
|
||||
=======
|
||||
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress(
|
||||
suppliedAddress)
|
||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
||||
suppliedAddress = addBMIfNotPresent(suppliedAddress)
|
||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||
queues.addressGeneratorQueue.put((
|
||||
|
@ -674,13 +649,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
raise APIError(0, 'I need parameters.')
|
||||
elif len(params) == 1:
|
||||
address, = params
|
||||
<<<<<<< HEAD
|
||||
status, addressVersionNumber, streamNumber, toRipe = (
|
||||
self._verifyAddress(address))
|
||||
=======
|
||||
status, addressVersionNumber, streamNumber, toRipe = \
|
||||
self._verifyAddress(address)
|
||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
||||
address = addBMIfNotPresent(address)
|
||||
if not BMConfigParser().has_section(address):
|
||||
raise APIError(
|
||||
|
@ -701,13 +671,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
raise APIError(0, 'I need parameters.')
|
||||
elif len(params) == 1:
|
||||
address, = params
|
||||
<<<<<<< HEAD
|
||||
status, addressVersionNumber, streamNumber, toRipe = (
|
||||
self._verifyAddress(address))
|
||||
=======
|
||||
status, addressVersionNumber, streamNumber, toRipe = \
|
||||
self._verifyAddress(address)
|
||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
||||
address = addBMIfNotPresent(address)
|
||||
if not BMConfigParser().has_section(address):
|
||||
raise APIError(
|
||||
|
|
|
@ -96,33 +96,35 @@ def ShowTimeHistoy(act_time):
|
|||
action_time = datetime.fromtimestamp(int(act_time))
|
||||
crnt_date = datetime.now()
|
||||
duration = crnt_date - action_time
|
||||
display_data = (action_time.strftime('%d/%m/%Y')
|
||||
display_data = (
|
||||
action_time.strftime('%d/%m/%Y')
|
||||
if duration.days >= 365 else action_time.strftime('%I:%M %p').lstrip('0')
|
||||
if duration.days == 0 and crnt_date.strftime('%d/%m/%Y') == action_time.strftime('%d/%m/%Y')
|
||||
else action_time.strftime("%d %b"))
|
||||
else action_time.strftime("%d %b")
|
||||
)
|
||||
return display_data
|
||||
|
||||
|
||||
def AddTimeWidget(time):
|
||||
def AddTimeWidget(time): # pylint: disable=redefined-outer-name
|
||||
"""This method is used to create TimeWidget"""
|
||||
action_time = BadgeText(
|
||||
size_hint= (None, None),
|
||||
text= f"{ShowTimeHistoy(time)}",
|
||||
size_hint=(None, None),
|
||||
text=str(ShowTimeHistoy(time)),
|
||||
halign='right',
|
||||
font_style='Caption',
|
||||
size= [65,70])
|
||||
size=[65, 70])
|
||||
return action_time
|
||||
|
||||
|
||||
def chipTag(text):
|
||||
"""This method is used for showing chip tag"""
|
||||
obj = MDChip()
|
||||
obj.size_hint= (None, None)
|
||||
obj.label= text
|
||||
obj.icon= ''
|
||||
obj.pos_hint= {'center_x': .96, 'center_y': .2}
|
||||
obj.height= dp(18)
|
||||
obj.radius= 8
|
||||
obj.size_hint = (None, None)
|
||||
obj.label = text
|
||||
obj.icon = ''
|
||||
obj.pos_hint = {'center_x': .96, 'center_y': .2}
|
||||
obj.height = dp(18)
|
||||
obj.radius = 8
|
||||
return obj
|
||||
|
||||
|
||||
|
@ -168,12 +170,13 @@ class Inbox(Screen):
|
|||
self.set_inboxCount(state.inbox_count)
|
||||
for mail in self.queryreturn:
|
||||
# third_text = mail[3].replace('\n', ' ')
|
||||
body = mail[3].decode() if isinstance(mail[3],bytes) else mail[3]
|
||||
subject = mail[5].decode() if isinstance(mail[5],bytes) else mail[5]
|
||||
body = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
||||
subject = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
||||
data.append({
|
||||
'text': mail[4].strip(),
|
||||
'secondary_text': (subject[:50] + '........' if len(
|
||||
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
|
||||
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace(
|
||||
'\t', '').replace(' ', ''),
|
||||
'msgid': mail[1], 'received': mail[6]})
|
||||
|
||||
self.has_refreshed = True
|
||||
|
@ -256,12 +259,12 @@ class Inbox(Screen):
|
|||
self.inboxDataQuery('toaddress', where, what, total_message, 5)
|
||||
for mail in self.queryreturn:
|
||||
# third_text = mail[3].replace('\n', ' ')
|
||||
subject = mail[3].decode() if isinstance(mail[3],bytes) else mail[3]
|
||||
body = mail[5].decode() if isinstance(mail[5],bytes) else mail[5]
|
||||
subject = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
||||
body = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
||||
data.append({
|
||||
'text': mail[4].strip(),
|
||||
'secondary_text': body[:50] + '........' if len(
|
||||
body) >= 50 else (body + ',' +subject.replace(
|
||||
body) >= 50 else (body + ',' + subject.replace(
|
||||
'\n', ''))[0:50] + '........',
|
||||
'msgid': mail[1]})
|
||||
self.set_mdList(data)
|
||||
|
@ -332,6 +335,7 @@ class Inbox(Screen):
|
|||
|
||||
|
||||
class CustomTwoLineAvatarIconListItem(TwoLineAvatarIconListItem):
|
||||
"""Custom Two Line Avatar Icon List"""
|
||||
pass
|
||||
|
||||
|
||||
|
@ -406,13 +410,15 @@ class MyAddress(Screen):
|
|||
meny.bind(on_press=partial(
|
||||
self.myadd_detail, item['secondary_text'], item['text']))
|
||||
if state.association == item['secondary_text']:
|
||||
meny.add_widget(BadgeText(size_hint= (None, None),
|
||||
text='Active', halign='right',
|
||||
font_style='Body1', size= [50,60],
|
||||
theme_text_color='Custom',
|
||||
text_color=NavigateApp().theme_cls.primary_color))
|
||||
meny.add_widget(
|
||||
BadgeText(
|
||||
size_hint=(None, None),
|
||||
text='Active', halign='right',
|
||||
font_style='Body1', size=[50, 60],
|
||||
theme_text_color='Custom',
|
||||
text_color=NavigateApp().theme_cls.primary_color))
|
||||
else:
|
||||
meny.add_widget(ToggleBtn(active = True if is_enable == 'true' else False))
|
||||
meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False))
|
||||
# carousel = Carousel(direction='right')
|
||||
# carousel.height = meny.height
|
||||
# carousel.size_hint_y = None
|
||||
|
@ -495,7 +501,6 @@ class MyAddress(Screen):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
def disableAddress(self, address, instance):
|
||||
"""This method is use for disabling address"""
|
||||
BMConfigParser().set(str(address), 'enabled', 'false')
|
||||
|
@ -845,7 +850,7 @@ class MyTextInput(TextInput):
|
|||
def __init__(self, **kwargs):
|
||||
"""Getting Text Input."""
|
||||
super(MyTextInput, self).__init__(**kwargs)
|
||||
self.__lineBreak__=0
|
||||
self.__lineBreak__ = 0
|
||||
|
||||
def on_text(self, instance, value):
|
||||
"""Find all the occurrence of the word"""
|
||||
|
@ -888,24 +893,25 @@ class Payment(Screen):
|
|||
state.kivyapp.root.ids.sc18.ids.cred.text = '{0}'.format(
|
||||
state.availabe_credit)
|
||||
|
||||
def move_to_pay_option(self, amount):
|
||||
def move_to_pay_option(self, amount): # pylint: disable=no-self-use
|
||||
"""Option move to pay"""
|
||||
state.kivyapp.set_toolbar_for_QrCode()
|
||||
|
||||
|
||||
class Credits(Screen):
|
||||
"""Credits Method"""
|
||||
|
||||
available_credits = StringProperty(
|
||||
'{0}'.format('€ 0'))
|
||||
available_credits = StringProperty('{0}'.format('€ 0'))
|
||||
|
||||
|
||||
class Login(Screen):
|
||||
"""Login Screeen"""
|
||||
log_text1 = ('You may generate addresses by using either random numbers'
|
||||
' or by using a passphrase If you use a passphrase, the address'
|
||||
' is called a deterministic; address The Random Number option is'
|
||||
' selected by default but deterministic addresses have several pros'
|
||||
' and cons:')
|
||||
log_text1 = (
|
||||
'You may generate addresses by using either random numbers'
|
||||
' or by using a passphrase If you use a passphrase, the address'
|
||||
' is called a deterministic; address The Random Number option is'
|
||||
' selected by default but deterministic addresses have several pros'
|
||||
' and cons:')
|
||||
log_text2 = ('If talk about pros You can recreate your addresses on any computer'
|
||||
' from memory, You need-not worry about backing up your keys.dat file'
|
||||
' as long as you can remember your passphrase and aside talk about cons'
|
||||
|
@ -1058,7 +1064,8 @@ class Sent(Screen):
|
|||
data.append({
|
||||
'text': mail[1].strip(),
|
||||
'secondary_text': (mail[2][:50] + '........' if len(
|
||||
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace('\t', '').replace(' ', ''),
|
||||
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace(
|
||||
'\t', '').replace(' ', ''),
|
||||
'ackdata': mail[5], 'senttime': mail[6]},)
|
||||
self.set_mdlist(data, 0)
|
||||
self.has_refreshed = True
|
||||
|
@ -1094,8 +1101,7 @@ class Sent(Screen):
|
|||
meny = TwoLineAvatarIconListItem(
|
||||
text=item['text'], secondary_text=item['secondary_text'],
|
||||
theme_text_color='Custom',
|
||||
text_color=NavigateApp().theme_cls.primary_color
|
||||
)
|
||||
text_color=NavigateApp().theme_cls.primary_color)
|
||||
meny.add_widget(AvatarSampleWidget(
|
||||
source='./images/text_images/{}.png'.format(
|
||||
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
||||
|
@ -1147,7 +1153,8 @@ class Sent(Screen):
|
|||
data.append({
|
||||
'text': mail[1].strip(),
|
||||
'secondary_text': (mail[2][:50] + '........' if len(
|
||||
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace('\t', '').replace(' ', ''),
|
||||
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace(
|
||||
'\t', '').replace(' ', ''),
|
||||
'ackdata': mail[5], 'senttime': mail[6]})
|
||||
self.set_mdlist(data, total_sent - 1)
|
||||
if state.msg_counter_objs and state.association == (
|
||||
|
@ -1305,8 +1312,8 @@ class Trash(Screen):
|
|||
"""This method is used to create the mdlist"""
|
||||
total_trash_msg = len(self.ids.ml.children)
|
||||
for item in self.trash_messages:
|
||||
subject = item[2].decode() if isinstance(item[2],bytes) else item[2]
|
||||
body = item[3].decode() if isinstance(item[3],bytes) else item[3]
|
||||
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
||||
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
||||
meny = TwoLineAvatarIconListItem(
|
||||
text=item[1],
|
||||
secondary_text=(item[2][:50] + '........' if len(
|
||||
|
@ -1424,8 +1431,9 @@ class Setting(Screen):
|
|||
"""Setting the Screen components"""
|
||||
exp_text = "By default, if you send a message to someone and he is offline for more than two days, Bitmessage will\
|
||||
send the message again after an additional two days. This will be continued with exponential backoff\
|
||||
forever; messages will be resent after 5, 10, 20 days ect. until the receiver acknowledges them. Here you\
|
||||
may change that behavior by having Bitmessage give up after a certain number of days or months."
|
||||
forever; messages will be resent after 5, 10, 20 days ect. until the receiver acknowledges them.\
|
||||
Here you may change that behavior by having Bitmessage give up after a certain number of days \
|
||||
or months."
|
||||
|
||||
|
||||
class NavigateApp(MDApp):
|
||||
|
@ -1490,7 +1498,7 @@ class NavigateApp(MDApp):
|
|||
LoadingPopup().open()
|
||||
self.set_message_count()
|
||||
for nav_obj in self.root.ids.content_drawer.children[
|
||||
0].children[0].children[0].children:
|
||||
0].children[0].children[0].children:
|
||||
nav_obj.active = True if nav_obj.text == 'Inbox' else False
|
||||
Clock.schedule_once(self.setCurrentAccountData, 0.5)
|
||||
|
||||
|
@ -1544,7 +1552,7 @@ class NavigateApp(MDApp):
|
|||
BMConfigParser().addresses()[0], android_path))
|
||||
else:
|
||||
if not os.path.exists('./images/default_identicon/{}.png'.format(
|
||||
BMConfigParser().addresses()[0])):
|
||||
BMConfigParser().addresses()[0])):
|
||||
img.texture.save('./images/default_identicon/{}.png'.format(
|
||||
BMConfigParser().addresses()[0]))
|
||||
return BMConfigParser().addresses()[0]
|
||||
|
@ -1583,7 +1591,7 @@ class NavigateApp(MDApp):
|
|||
return False
|
||||
|
||||
def on_key(self, window, key, *args):
|
||||
# pylint: disable=inconsistent-return-statements
|
||||
# pylint: disable=inconsistent-return-statements, too-many-branches
|
||||
"""Method is used for going on previous screen"""
|
||||
if key == 27:
|
||||
if state.in_search_mode and self.root.ids.scr_mngr.current != (
|
||||
|
@ -1687,7 +1695,6 @@ class NavigateApp(MDApp):
|
|||
state.in_composer = True
|
||||
state.in_sent_method = False
|
||||
|
||||
|
||||
def set_navbar_for_composer(self):
|
||||
"""Clearing toolbar data when composer open"""
|
||||
self.root.ids.toolbar.left_action_items = [
|
||||
|
@ -1936,7 +1943,6 @@ class NavigateApp(MDApp):
|
|||
def file_manager_open(self):
|
||||
"""This method open the file manager of local system"""
|
||||
from kivymd.uix.filemanager import MDFileManager
|
||||
from kivymd.uix.dialog import MDDialog
|
||||
|
||||
self.manager = ModalView(size_hint=(1, 1), auto_dismiss=False)
|
||||
self.file_manager = MDFileManager(
|
||||
|
@ -1955,7 +1961,7 @@ class NavigateApp(MDApp):
|
|||
from PIL import Image as PilImage
|
||||
if not os.path.exists('./images/default_identicon/'):
|
||||
os.makedirs('./images/default_identicon/')
|
||||
newImg = PilImage.open(path).resize((300,300))
|
||||
newImg = PilImage.open(path).resize((300, 300))
|
||||
newImg.save('./images/default_identicon/{0}.png'.format(state.association))
|
||||
self.load_selected_Image(state.association)
|
||||
self.exit_manager()
|
||||
|
@ -1972,11 +1978,11 @@ class NavigateApp(MDApp):
|
|||
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
||||
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
||||
# spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
||||
top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
||||
top_box_obj.source = './images/default_identicon/{0}.png'.format(curerentAddr)
|
||||
top_box_obj.reload()
|
||||
# spinner_img_obj.reload()
|
||||
|
||||
def copy_composer_text(self, text):
|
||||
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
||||
"""Copy the data from mail detail page"""
|
||||
Clipboard.copy(text)
|
||||
toast('Copied')
|
||||
|
@ -2115,12 +2121,6 @@ class IconRightSampleWidget(IRightBodyTouch, MDIconButton):
|
|||
pass
|
||||
|
||||
|
||||
class IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
|
||||
"""Right icon sample widget"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class ToggleBtn(IRightBodyTouch, MDSwitch):
|
||||
"""Right toggle button widget"""
|
||||
pass
|
||||
|
@ -2132,7 +2132,7 @@ class CheckboxLeftSampleWidget(ILeftBodyTouch, MDCheckbox):
|
|||
pass
|
||||
|
||||
|
||||
class MailDetail(Screen):
|
||||
class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
|
||||
"""MailDetail Screen uses to show the detail of mails"""
|
||||
|
||||
to_addr = StringProperty()
|
||||
|
@ -2169,8 +2169,8 @@ class MailDetail(Screen):
|
|||
|
||||
def assign_mail_details(self, data):
|
||||
"""Assigning mail details"""
|
||||
subject = data[0][2].decode() if isinstance(data[0][2],bytes) else data[0][2]
|
||||
body = data[0][3].decode() if isinstance(data[0][2],bytes) else data[0][3]
|
||||
subject = data[0][2].decode() if isinstance(data[0][2], bytes) else data[0][2]
|
||||
body = data[0][3].decode() if isinstance(data[0][2], bytes) else data[0][3]
|
||||
self.to_addr = data[0][0] if len(data[0][0]) > 4 else ' '
|
||||
self.from_addr = data[0][1]
|
||||
|
||||
|
@ -2180,7 +2180,7 @@ class MailDetail(Screen):
|
|||
if len(data[0]) == 7:
|
||||
self.status = data[0][4]
|
||||
self.time_tag = ShowTimeHistoy(data[0][4]) if state.detailPageType == 'inbox' else ShowTimeHistoy(data[0][6])
|
||||
self.avatarImg= './images/avatar.png' if state.detailPageType == 'draft' else (
|
||||
self.avatarImg = './images/avatar.png' if state.detailPageType == 'draft' else (
|
||||
'./images/text_images/{0}.png'.format(avatarImageFirstLetter(self.subject.strip())))
|
||||
self.timeinseconds = data[0][4] if state.detailPageType == 'inbox' else data[0][6]
|
||||
|
||||
|
@ -2282,6 +2282,7 @@ class MailDetail(Screen):
|
|||
navApp.set_navbar_for_composer()
|
||||
|
||||
def detailedPopup(self):
|
||||
"""Detailed popup"""
|
||||
obj = SenderDetailPopup()
|
||||
obj.open()
|
||||
arg = (self.to_addr, self.from_addr, self.timeinseconds)
|
||||
|
@ -2313,7 +2314,7 @@ class MyaddDetailPopup(Popup):
|
|||
state.kivyapp.set_navbar_for_composer()
|
||||
try:
|
||||
window_obj = self.parent.children[2].ids
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
window_obj = self.parent.children[1].ids
|
||||
window_obj.sc3.children[1].ids.ti.text = self.address
|
||||
window_obj.sc3.children[1].ids.btn.text = self.address
|
||||
|
@ -2367,7 +2368,7 @@ class AddbookDetailPopup(Popup):
|
|||
state.kivyapp.set_navbar_for_composer()
|
||||
try:
|
||||
window_obj = self.parent.children[2].ids
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
window_obj = self.parent.children[1].ids
|
||||
window_obj.sc3.children[1].ids.txt_input.text = self.address
|
||||
window_obj.sc3.children[1].ids.ti.text = ''
|
||||
|
@ -2604,7 +2605,8 @@ class Draft(Screen):
|
|||
encoding,
|
||||
BMConfigParser().safeGetInt('bitmessagesettings', 'ttl'))
|
||||
state.msg_counter_objs = src_object.children[2].children[0].ids
|
||||
state.draft_count = str(int(state.draft_count) + 1) if state.association == fromAddress else state.draft_count
|
||||
state.draft_count = str(int(state.draft_count) + 1) \
|
||||
if state.association == fromAddress else state.draft_count
|
||||
src_object.ids.sc16.clear_widgets()
|
||||
src_object.ids.sc16.add_widget(Draft())
|
||||
toast('Save draft')
|
||||
|
@ -2688,12 +2690,12 @@ class Allmails(Screen):
|
|||
"""This method is used to create mdList for allmaills"""
|
||||
data_exist = len(self.ids.ml.children)
|
||||
for item in self.all_mails:
|
||||
body = item[3].decode() if isinstance(item[3],bytes) else item[3]
|
||||
subject = item[2].decode() if isinstance(item[2],bytes) else item[2]
|
||||
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
||||
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
||||
meny = TwoLineAvatarIconListItem(
|
||||
text=item[1],
|
||||
secondary_text=(subject[:50] + '........' if len(
|
||||
subject) >= 50 else (
|
||||
subject) >= 50 else (
|
||||
subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
|
||||
theme_text_color='Custom',
|
||||
text_color=NavigateApp().theme_cls.primary_color)
|
||||
|
@ -2864,6 +2866,7 @@ class NavigationItem(OneLineAvatarIconListItem):
|
|||
active = BooleanProperty(False)
|
||||
|
||||
def currentlyActive(self):
|
||||
"""Currenly active"""
|
||||
for nav_obj in self.parent.children:
|
||||
nav_obj.active = False
|
||||
self.active = True
|
||||
|
@ -2927,22 +2930,23 @@ class SenderDetailPopup(Popup):
|
|||
super(SenderDetailPopup, self).__init__(**kwargs)
|
||||
|
||||
def assignDetail(self, to_addr, from_addr, timeinseconds):
|
||||
"""Detailes assigned"""
|
||||
self.to_addr = to_addr
|
||||
self.from_addr = from_addr
|
||||
time_obj = datetime.fromtimestamp(int(timeinseconds))
|
||||
self.time_tag = time_obj.strftime("%d %b %Y, %I:%M %p")
|
||||
pop_height = 1.2*(self.ids.sd_label.height+self.ids.sd_btn.children[0].height)
|
||||
pop_height = 1.2 * (self.ids.sd_label.height + self.ids.sd_btn.children[0].height)
|
||||
if len(to_addr) > 3:
|
||||
self.height = 0
|
||||
self.height = pop_height
|
||||
self.ids.to_addId.size_hint_y = None
|
||||
self.ids.to_addId.height= 50
|
||||
self.ids.to_addId.height = 50
|
||||
frmaddbox = ToAddrBoxlayout()
|
||||
frmaddbox.set_toAddress(to_addr)
|
||||
self.ids.to_addId.add_widget(frmaddbox)
|
||||
else:
|
||||
self.height = 0
|
||||
self.height = pop_height/1.5
|
||||
self.height = pop_height / 1.5
|
||||
|
||||
|
||||
class OneLineListTitle(OneLineListItem):
|
||||
|
@ -2951,6 +2955,7 @@ class OneLineListTitle(OneLineListItem):
|
|||
long_press_time = NumericProperty(1)
|
||||
|
||||
def on_state(self, instance, value):
|
||||
"""On state"""
|
||||
if value == 'down':
|
||||
lpt = self.long_press_time
|
||||
self._clockev = Clock.schedule_once(self._do_long_press, lpt)
|
||||
|
@ -2958,9 +2963,11 @@ class OneLineListTitle(OneLineListItem):
|
|||
self._clockev.cancel()
|
||||
|
||||
def _do_long_press(self, dt):
|
||||
"""Do long press"""
|
||||
self.dispatch('on_long_press')
|
||||
|
||||
def on_long_press(self, *largs):
|
||||
"""On long press"""
|
||||
self.copymessageTitle(self.text)
|
||||
|
||||
def copymessageTitle(self, text):
|
||||
|
@ -2995,4 +3002,5 @@ class PaymentMethods(Screen):
|
|||
"""PaymentMethods Screen show widgets of page"""
|
||||
|
||||
def redirect_on_web(self, instance):
|
||||
"""Redirect on web"""
|
||||
pass
|
||||
|
|
|
@ -3,7 +3,6 @@ BMConfigParser class definition and default configuration settings
|
|||
"""
|
||||
# pylint: disable=no-self-use, arguments-differ
|
||||
import configparser
|
||||
import shutil
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
|
|
|
@ -439,8 +439,8 @@ class objectProcessor(threading.Thread):
|
|||
return
|
||||
|
||||
# Let us try to decrypt the pubkey
|
||||
toAddress, _ = state.neededPubkeys[bytes(tag)] #check with py2
|
||||
if protocol.decryptAndCheckPubkeyPayload(bytes(data), toAddress) == \
|
||||
toAddress, _ = state.neededPubkeys[bytes(tag)] # check with py2
|
||||
if protocol.decryptAndCheckPubkeyPayload(bytes(data), toAddress) == \
|
||||
'successful':
|
||||
# At this point we know that we have been waiting on this
|
||||
# pubkey. This function will command the workerThread
|
||||
|
|
|
@ -873,7 +873,7 @@ class singleWorker(StoppableThread):
|
|||
tr._translate(
|
||||
"MainWindow",
|
||||
"Looking up the receiver\'s public key"))
|
||||
))
|
||||
))
|
||||
self.logger.info('Sending a message.')
|
||||
# self.logger.debug(
|
||||
# 'First 150 characters of message: %s',
|
||||
|
@ -883,13 +883,13 @@ class singleWorker(StoppableThread):
|
|||
# Let us fetch the recipient's public key out of
|
||||
# our database. If the required proof of work difficulty
|
||||
# is too hard then we'll abort.
|
||||
|
||||
|
||||
queryreturn = sqlQuery(
|
||||
'SELECT transmitdata FROM pubkeys WHERE address=?',
|
||||
toaddress)
|
||||
for row in queryreturn: # pylint: disable=redefined-outer-name
|
||||
pubkeyPayload, = row
|
||||
|
||||
|
||||
# The pubkey message is stored with the following items
|
||||
# all appended:
|
||||
# -address version
|
||||
|
@ -913,7 +913,7 @@ class singleWorker(StoppableThread):
|
|||
|
||||
# if receiver is a mobile device who expects that their
|
||||
# address RIPE is included unencrypted on the front of
|
||||
# the message..
|
||||
# the message..
|
||||
if protocol.isBitSetWithinBitfield(behaviorBitfield, 30):
|
||||
# if we are Not willing to include the receiver's
|
||||
# RIPE hash on the message..
|
||||
|
@ -951,7 +951,7 @@ class singleWorker(StoppableThread):
|
|||
readPosition:readPosition + 64]
|
||||
readPosition += 64
|
||||
# Let us fetch the amount of work required by the recipient.
|
||||
if toAddressVersionNumber == 2:
|
||||
if toAddressVersionNumber == 2:
|
||||
requiredAverageProofOfWorkNonceTrialsPerByte = \
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||
requiredPayloadLengthExtraBytes = \
|
||||
|
@ -965,7 +965,7 @@ class singleWorker(StoppableThread):
|
|||
"There is no required difficulty for"
|
||||
" version 2 addresses like this."))
|
||||
))
|
||||
|
||||
|
||||
elif toAddressVersionNumber >= 3:
|
||||
requiredAverageProofOfWorkNonceTrialsPerByte, \
|
||||
varintLength = decodeVarint(
|
||||
|
@ -1158,7 +1158,7 @@ class singleWorker(StoppableThread):
|
|||
fullAckPayload = self.generateFullAckMessage(
|
||||
ackdata, toStreamNumber, TTL)
|
||||
payload += encodeVarint(len(fullAckPayload))
|
||||
payload += fullAckPayload if isinstance(fullAckPayload,bytes) else fullAckPayload.encode()
|
||||
payload += fullAckPayload if isinstance(fullAckPayload, bytes) else fullAckPayload.encode()
|
||||
dataToSign = pack('>Q', embeddedTime) + '\x00\x00\x00\x02'.encode() + \
|
||||
encodeVarint(1) + encodeVarint(toStreamNumber) + payload
|
||||
signature = highlevelcrypto.sign(dataToSign, privSigningKeyHex)
|
||||
|
@ -1201,11 +1201,11 @@ class singleWorker(StoppableThread):
|
|||
self.logger.info(
|
||||
'(For msg message) Doing proof of work. Total required'
|
||||
' difficulty: {}. Required small message difficulty: {}.'.format
|
||||
(float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||
float(requiredPayloadLengthExtraBytes) /
|
||||
defaults.networkDefaultPayloadLengthExtraBytes)
|
||||
)
|
||||
(
|
||||
float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||
float(requiredPayloadLengthExtraBytes) /
|
||||
defaults.networkDefaultPayloadLengthExtraBytes))
|
||||
|
||||
powStartTime = time.time()
|
||||
initialHash = hashlib.sha512(encryptedPayload).digest()
|
||||
|
@ -1332,9 +1332,9 @@ class singleWorker(StoppableThread):
|
|||
)
|
||||
return
|
||||
retryNumber = queryReturn[0][0]
|
||||
if addressVersionNumber <= 3:
|
||||
if addressVersionNumber <= 3:
|
||||
state.neededPubkeys[toAddress] = 0
|
||||
elif addressVersionNumber >= 4:
|
||||
elif addressVersionNumber >= 4:
|
||||
# If the user just clicked 'send' then the tag
|
||||
# (and other information) will already be in the
|
||||
# neededPubkeys dictionary. But if we are recovering
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
Message encoding end decoding functions
|
||||
"""
|
||||
|
||||
import string
|
||||
import zlib
|
||||
|
||||
import messagetypes
|
||||
|
|
|
@ -8,7 +8,7 @@ from singleton import Singleton
|
|||
|
||||
|
||||
@Singleton
|
||||
class Inventory():
|
||||
class Inventory(object):
|
||||
"""
|
||||
Inventory singleton class which uses storage backends
|
||||
to manage the inventory.
|
||||
|
|
|
@ -15,7 +15,7 @@ class Message(MsgBase):
|
|||
# UTF-8 and variable type validator
|
||||
if isinstance(data["subject"], str):
|
||||
# Unicode is depreciated
|
||||
self.subject =data["subject"]
|
||||
self.subject = data["subject"]
|
||||
else:
|
||||
# Unicode is depreciated
|
||||
self.subject = str(data["subject"])
|
||||
|
|
|
@ -114,6 +114,7 @@ class BMObject(object): # pylint: disable=too-many-instance-attributes
|
|||
or advertise it unnecessarily)
|
||||
"""
|
||||
# if it's a stem duplicate, pretend we don't have it
|
||||
# pylint: disable=protected-access
|
||||
if Dandelion().hasHash(self.inventoryHash):
|
||||
return
|
||||
if self.inventoryHash in Inventory():
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Bitmessage Protocol
|
||||
"""
|
||||
# pylint: disable=attribute-defined-outside-init, too-few-public-methods, logging-format-interpolation
|
||||
# pylint: disable=attribute-defined-outside-init,too-few-public-methods,logging-format-interpolation,protected-access
|
||||
import base64
|
||||
import hashlib
|
||||
import logging
|
||||
|
@ -31,7 +31,7 @@ from network.dandelion import Dandelion
|
|||
from network.proxy import ProxyError
|
||||
from network.objectracker import missingObjects, ObjectTracker
|
||||
from network.node import Node, Peer
|
||||
from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue
|
||||
from queues import objectProcessorQueue, portCheckerQueue, invQueue
|
||||
from network.randomtrackingdict import RandomTrackingDict
|
||||
|
||||
logger = logging.getLogger('default')
|
||||
|
@ -355,7 +355,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
|
||||
# ignore dinv if dandelion turned off
|
||||
if dandelion and not state.dandelion:
|
||||
return True
|
||||
return True
|
||||
for i in map(bytes, items):
|
||||
if i in Inventory() and not Dandelion().hasHash(i):
|
||||
continue
|
||||
|
@ -409,7 +409,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
try:
|
||||
self.object.checkObjectByType()
|
||||
objectProcessorQueue.put((
|
||||
self.object.objectType, memoryview(self.object.data)))
|
||||
self.object.objectType, memoryview(self.object.data)))
|
||||
except BMObjectInvalidError:
|
||||
BMProto.stopDownloadingObject(self.object.inventoryHash, True)
|
||||
else:
|
||||
|
@ -699,4 +699,4 @@ class BMStringParser(BMProto):
|
|||
except Exception as e:
|
||||
logger.debug(
|
||||
'Exception of type %s while sending ACK',
|
||||
type(e), exc_info=True)
|
||||
type(e), exc_info=True)
|
||||
|
|
|
@ -40,7 +40,7 @@ class DownloadThread(StoppableThread):
|
|||
del missingObjects[i]
|
||||
self.lastCleaned = time.time()
|
||||
|
||||
def run(self):
|
||||
def run(self): # pylint: disable=protected-access
|
||||
while not self._stopped:
|
||||
requested = 0
|
||||
connections = BMConnectionPool().establishedConnections()
|
||||
|
|
|
@ -92,13 +92,13 @@ class InvThread(StoppableThread):
|
|||
connection.append_write_buf(protocol.CreatePacket(
|
||||
'inv',
|
||||
addresses.encodeVarint(
|
||||
len(fluffs)) + ('').encode().join([x for x in fluffs]))) #compare result with python2
|
||||
len(fluffs)) + ('').encode().join([x for x in fluffs]))) # compare result with python2
|
||||
if stems:
|
||||
random.shuffle(stems)
|
||||
connection.append_write_buf(protocol.CreatePacket(
|
||||
'dinv',
|
||||
addresses.encodeVarint(
|
||||
len(stems)) + ('').encode().join([x for x in stems]))) #compare result with python2
|
||||
len(stems)) + ('').encode().join([x for x in stems]))) # compare result with python2
|
||||
|
||||
invQueue.iterate()
|
||||
for _ in range(len(chunk)):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
TCP protocol handler
|
||||
"""
|
||||
# pylint: disable=too-many-ancestors
|
||||
# pylint: disable=too-many-ancestors, protected-access
|
||||
import logging
|
||||
import math
|
||||
import random
|
||||
|
@ -428,4 +428,4 @@ class TCPServer(AdvancedDispatcher):
|
|||
connectionpool.BMConnectionPool().addConnection(
|
||||
TCPConnection(sock=sock))
|
||||
except socket.error:
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -108,7 +108,6 @@ def _doFastPoW(target, initialHash):
|
|||
logger.debug("Fast PoW done")
|
||||
return result[0], result[1]
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
|
||||
def _doCPoW(target, initialHash):
|
||||
|
|
|
@ -289,7 +289,7 @@ def isProofOfWorkSufficient(
|
|||
|
||||
def CreatePacket(command, payload=''):
|
||||
"""Construct and return a number of bytes from a payload"""
|
||||
payload = payload if type(payload) in [bytes, bytearray,memoryview] else payload.encode()
|
||||
payload = payload if type(payload) in [bytes, bytearray, memoryview] else payload.encode()
|
||||
payload_length = len(payload)
|
||||
checksum = hashlib.sha512(payload).digest()[0:4]
|
||||
byte = bytearray(Header.size + payload_length)
|
||||
|
|
|
@ -25,7 +25,6 @@ from addresses import decodeAddress, encodeVarint
|
|||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger
|
||||
from helper_sql import sqlQuery
|
||||
from pyelliptic import arithmetic
|
||||
# pylint: disable=logging-format-interpolation
|
||||
|
||||
verbose = 1
|
||||
|
|
|
@ -39,11 +39,11 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
|
|||
return False
|
||||
self._objects[hash_] = rows[0][0]
|
||||
return True
|
||||
|
||||
|
||||
def __getitem__(self, hash_):
|
||||
with self.lock:
|
||||
if isinstance(hash_,memoryview) and bytes(hash_) in self._inventory :
|
||||
return self._inventory[bytes(hash_)]
|
||||
if isinstance(hash_, memoryview) and bytes(hash_) in self._inventory:
|
||||
return self._inventory[bytes(hash_)]
|
||||
else:
|
||||
if hash_ in self._inventory:
|
||||
return self._inventory[hash_]
|
||||
|
@ -52,7 +52,7 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
|
|||
' FROM inventory WHERE hash=?', sqlite3.Binary(hash_))
|
||||
if not rows:
|
||||
raise KeyError(hash_)
|
||||
return InventoryItem(*rows[0])
|
||||
return InventoryItem(*rows[0])
|
||||
|
||||
def __setitem__(self, hash_, value):
|
||||
with self.lock:
|
||||
|
|
Reference in New Issue
Block a user