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,18 +96,20 @@ 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)}",
|
||||
text=str(ShowTimeHistoy(time)),
|
||||
halign='right',
|
||||
font_style='Caption',
|
||||
size=[65, 70])
|
||||
|
@ -173,7 +175,8 @@ class Inbox(Screen):
|
|||
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
|
||||
|
@ -332,6 +335,7 @@ class Inbox(Screen):
|
|||
|
||||
|
||||
class CustomTwoLineAvatarIconListItem(TwoLineAvatarIconListItem):
|
||||
"""Custom Two Line Avatar Icon List"""
|
||||
pass
|
||||
|
||||
|
||||
|
@ -406,7 +410,9 @@ 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),
|
||||
meny.add_widget(
|
||||
BadgeText(
|
||||
size_hint=(None, None),
|
||||
text='Active', halign='right',
|
||||
font_style='Body1', size=[50, 60],
|
||||
theme_text_color='Custom',
|
||||
|
@ -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')
|
||||
|
@ -888,20 +893,21 @@ 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'
|
||||
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'
|
||||
|
@ -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 == (
|
||||
|
@ -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):
|
||||
|
@ -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(
|
||||
|
@ -1976,7 +1982,7 @@ class NavigateApp(MDApp):
|
|||
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()
|
||||
|
@ -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')
|
||||
|
@ -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,6 +2930,7 @@ 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))
|
||||
|
@ -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
|
||||
|
|
|
@ -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) /
|
||||
(
|
||||
float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||
float(requiredPayloadLengthExtraBytes) /
|
||||
defaults.networkDefaultPayloadLengthExtraBytes)
|
||||
)
|
||||
defaults.networkDefaultPayloadLengthExtraBytes))
|
||||
|
||||
powStartTime = time.time()
|
||||
initialHash = hashlib.sha512(encryptedPayload).digest()
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -110,7 +110,6 @@ def _doFastPoW(target, initialHash):
|
|||
time.sleep(0.2)
|
||||
|
||||
|
||||
|
||||
def _doCPoW(target, initialHash):
|
||||
out_h = ctypes.pointer(ctypes.create_string_buffer(initialHash, 64))
|
||||
out_m = ctypes.c_ulonglong(target)
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in New Issue
Block a user