Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
"visualstudioexptteam.vscodeintellicode"
],
"settings": {
"python.defaultInterpreterPath": "/usr/bin/python3",
"flake8.interpreter": ["/usr/bin/python3"],
"flake8.importStrategy": "fromEnvironment",
"flake8.args": ["--config=setup.cfg"],
"pylint.interpreter": ["/usr/bin/python3"],
"pylint.args": ["--rcfile=setup.cfg", "--init-hook", "import sys;sys.path.append('src')"],
"terminal.integrated.shell.linux": "/usr/bin/zsh",
"terminal.integrated.defaultProfile.linux": "zsh",
Expand Down
7 changes: 6 additions & 1 deletion .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh

pip3 install -r requirements.txt
pip3 install -r kivy-requirements.txt
pip3 install -r kivy-requirements.txt

# Linter tools needed by the VS Code extensions (ms-python.flake8,
# ms-python.pylint, nwgh.bandit). The apt-installed system packages
# are not visible to the VS Code Python interpreter.
pip3 install flake8 pylint bandit
29 changes: 23 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,35 @@ ignore = E722,F841,W503
# F841: pylint is preferred for unused-variable
# W503: deprecated: https://bugs.python.org/issue26763 - https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator

# pylint honours the [MESSAGES CONTROL] section
# as well as [MASTER] section
[MESSAGES CONTROL]
disable=
invalid-name,bare-except,broad-except,superfluous-parens,
bad-option-value
# -- pylint (modern, >= 2.14) -- pylint.*-prefixed sections for setup.cfg

[pylint.main]
init-hook = import sys;sys.path.append('src')
ignore = bitmessagekivy

[pylint.messages_control]
disable =
invalid-name,bare-except,broad-except,relative-import,
superfluous-parens,bad-option-value
# invalid-name: needs fixing during a large, project-wide refactor
# bare-except,broad-except: Need fixing once thorough testing is easier
# bad-option-value is for backward compatibility between python 2 and 3

[pylint.design]
max-args = 8
max-attributes = 8

# -- pylint (legacy, < 2.0 / python 2.7) -- old .pylintrc-style section names

[MASTER]
init-hook = import sys;sys.path.append('src')
ignore = bitmessagekivy

[MESSAGES CONTROL]
disable =
invalid-name,bare-except,broad-except,relative-import,
superfluous-parens,bad-option-value

[DESIGN]
max-args = 8
max-attributes = 8
2 changes: 1 addition & 1 deletion src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
For further examples please reference `.tests.test_api`.
"""

# pylint: disable=too-many-lines,relative-import
# pylint: disable=too-many-lines

import base64
import errno
Expand Down
5 changes: 2 additions & 3 deletions src/bitmessagecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# pylint: disable=too-many-lines,global-statement,too-many-branches,too-many-statements,inconsistent-return-statements
# pylint: disable=too-many-nested-blocks,too-many-locals,protected-access,too-many-arguments,too-many-function-args
# pylint: disable=no-member
# pylint: disable=no-member,superfluous-parens
"""
Created by Adam Melton (.dok) referenceing https://bitmessage.org/wiki/API_Reference for API documentation
Distributed under the MIT/X11 software license. See http://www.opensource.org/licenses/mit-license.php.
Expand All @@ -16,15 +16,14 @@
import datetime
import imghdr
import json
import ntpath
import os
import socket
import sys
import time

from six.moves import input as raw_input
from six.moves import xmlrpc_client as xmlrpclib

import ntpath
from bmconfigparser import config


Expand Down
9 changes: 4 additions & 5 deletions src/bitmessagemain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# yet contain logic to expand into further streams.

# flake8: noqa:402
# pylint: disable=superfluous-parens,relative-import
# pylint: disable=superfluous-parens
import os
import sys

Expand Down Expand Up @@ -212,7 +212,7 @@ def start(self):

# API is also objproc dependent
if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
import api # pylint: disable=relative-import
import api
singleAPIThread = api.singleAPI()
# close the main program even if there are threads left
singleAPIThread.daemon = True
Expand Down Expand Up @@ -256,14 +256,13 @@ def start(self):
while state.shutdown == 0:
time.sleep(1)
if (
state.testmode
and time.time() - state.last_api_response >= 30
state.testmode
and time.time() - state.last_api_response >= 30
):
self.stop()
elif not state.enableGUI:
state.enableGUI = True
try:
# pylint: disable=relative-import
from tests import core as test_core
except ImportError:
try:
Expand Down
2 changes: 1 addition & 1 deletion src/bitmessageqt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
PyQt based UI for bitmessage, the main module
"""
# pylint: disable=import-error,relative-import,too-many-lines
# pylint: disable=import-error,too-many-lines
import hashlib
import locale
import os
Expand Down
2 changes: 1 addition & 1 deletion src/bitmessageqt/address_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Dialogs that work with BM address.
"""
# pylint: disable=attribute-defined-outside-init,too-few-public-methods
# pylint: disable=relative-import,import-error
# pylint: disable=import-error

import hashlib

Expand Down
2 changes: 1 addition & 1 deletion src/bitmessageqt/addressvalidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Address validator module.
"""
# pylint: disable=too-many-branches,too-many-arguments
# pylint: disable=import-error,relative-import
# pylint: disable=import-error

from Queue import Empty

Expand Down
20 changes: 14 additions & 6 deletions src/bitmessageqt/newchandialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=================================

"""
# pylint: disable=import-error,relative-import,ungrouped-imports
# pylint: disable=import-error,ungrouped-imports,wrong-import-order
from PyQt4 import QtCore, QtGui

import widgets
Expand Down Expand Up @@ -67,20 +67,28 @@ def accept(self):
self.chanPassPhrase.text().toUtf8(),
True))
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address':
UISignalQueue.put(('updateStatusBar', _translate(
"newchandialog", "Successfully created / joined chan %1").arg(unicode(self.chanPassPhrase.text()))))
if addressGeneratorReturnValue \
and addressGeneratorReturnValue[0] \
!= 'chan name does not match address':
UISignalQueue.put(('updateStatusBar',
_translate("newchandialog",
"Successfully created / joined chan %1").
arg(unicode(self.chanPassPhrase.text())))) # pylint: disable=undefined-variable
self.parent.ui.tabWidget.setCurrentIndex(
self.parent.ui.tabWidget.indexOf(self.parent.ui.chans)
)
self.done(QtGui.QDialog.Accepted)
else:
UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Chan creation / joining failed")))
UISignalQueue.put(('updateStatusBar',
_translate("newchandialog",
"Chan creation / joining failed")))
self.done(QtGui.QDialog.Rejected)

def reject(self):
"""Cancel joining the chan"""
self.timer.stop()
self.hide()
UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Chan creation / joining cancelled")))
UISignalQueue.put(('updateStatusBar',
_translate("newchandialog",
"Chan creation / joining cancelled")))
self.done(QtGui.QDialog.Rejected)
3 changes: 1 addition & 2 deletions src/bitmessageqt/tests/addressbook.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
Test PyQt addressbook
"""
# pylint: disable=relative-import
import helper_addressbook
from bitmessageqt.support import createAddressIfNeeded

from main import TestBase
from main import TestBase # pylint: disable=no-name-in-module


class TestAddressbook(TestBase):
Expand Down
3 changes: 1 addition & 2 deletions src/bitmessageqt/tests/support.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""
PyQt4 test for support request dialog
"""
# pylint: disable=relative-import
# from PyQt4 import QtTest

import sys

from main import TestBase
from main import TestBase # pylint: disable=no-name-in-module
from shared import isAddressInMyAddressBook


Expand Down
2 changes: 1 addition & 1 deletion src/bmconfigparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from six.moves import configparser

try:
import state # pylint: disable=relative-import
import state
except ImportError:
from pybitmessage import state

Expand Down
18 changes: 9 additions & 9 deletions src/class_addressGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from binascii import hexlify

from six.moves import configparser, queue
# pylint: disable=import-error,relative-import
# pylint: disable=import-error
import defaults
import highlevelcrypto
import queues
Expand Down Expand Up @@ -221,8 +221,8 @@ def run(self):
))

elif command in (
'createDeterministicAddresses', 'createChan',
'getDeterministicAddress', 'joinChan'
'createDeterministicAddresses', 'createChan',
'getDeterministicAddress', 'joinChan'
):
if not deterministicPassphrase:
self.logger.warning(
Expand Down Expand Up @@ -268,8 +268,8 @@ def run(self):
ripe = highlevelcrypto.to_ripe(
potentialPubSigningKey, potentialPubEncryptionKey)
if (
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash]
== b'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash]
== b'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
):
break

Expand Down Expand Up @@ -303,9 +303,9 @@ def run(self):
saveAddressToDisk = False

if saveAddressToDisk and live and self.save_address(
addressVersionNumber, streamNumber, ripe, label,
potentialPrivSigningKey, potentialPrivEncryptionKey,
nonceTrialsPerByte, payloadLengthExtraBytes
addressVersionNumber, streamNumber, ripe, label,
potentialPrivSigningKey, potentialPrivEncryptionKey,
nonceTrialsPerByte, payloadLengthExtraBytes
):
if command in ('createChan', 'joinChan'):
config.set(address, 'chan', 'true')
Expand All @@ -326,7 +326,7 @@ def run(self):

# Done generating addresses.
if command in (
'createDeterministicAddresses', 'createChan', 'joinChan'
'createDeterministicAddresses', 'createChan', 'joinChan'
):
queues.apiAddressGeneratorReturnQueue.put(
listOfNewAddressesToSendOutThroughTheAPI)
Expand Down
9 changes: 5 additions & 4 deletions src/class_objectProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
# pylint: disable=too-many-locals,too-many-return-statements
# pylint: disable=too-many-branches,too-many-statements
# pylint: disable=too-many-lines
import hashlib
import logging
import os
Expand Down Expand Up @@ -718,10 +719,10 @@ def processmsg(self, data):
# Don't send ACK if invalid, blacklisted senders, invisible
# messages, disabled or chan
if (
self.ackDataHasAValidHeader(ackData) and not blockMessage
and messageEncodingType != 0
and not config.safeGetBoolean(toAddress, 'dontsendack')
and not config.safeGetBoolean(toAddress, 'chan')
self.ackDataHasAValidHeader(ackData) and not blockMessage
and messageEncodingType != 0
and not config.safeGetBoolean(toAddress, 'dontsendack')
and not config.safeGetBoolean(toAddress, 'chan')
):
ackPayload = ackData[24:]
objectType, toStreamNumber, expiresTime = \
Expand Down
10 changes: 5 additions & 5 deletions src/class_singleWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
# pylint: disable=protected-access,too-many-branches,too-many-statements
# pylint: disable=no-self-use,too-many-lines,too-many-locals
# pylint: disable=relative-import,import-error,redefined-builtin
# pylint: disable=import-error,redefined-builtin

from __future__ import division

Expand Down Expand Up @@ -492,7 +492,7 @@ def sendOutOrStoreMyV4Pubkey(self, myAddress):
def sendOnionPeerObj(self, peer=None):
"""Send onionpeer object representing peer"""
if not peer: # find own onionhostname
for peer in state.ownAddresses:
for peer in state.ownAddresses: # pylint: disable=redefined-argument-from-local
if peer.host.endswith('.onion'):
break
else:
Expand Down Expand Up @@ -772,9 +772,9 @@ def sendMsg(self):
if queryreturn != []:
# set the status of this msg to doingmsgpow
if not sqlExecute(
'''UPDATE sent SET status='doingmsgpow' '''
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
toaddress
'''UPDATE sent SET status='doingmsgpow' '''
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
toaddress
):
continue
status = 'doingmsgpow'
Expand Down
2 changes: 1 addition & 1 deletion src/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def try_import(module, log_extra=False):
def check_ripemd160():
"""Check availability of the RIPEMD160 hash function"""
try:
from fallback import RIPEMD160Hash # pylint: disable=relative-import
from fallback import RIPEMD160Hash
except ImportError:
return False
return RIPEMD160Hash is not None
Expand Down
3 changes: 1 addition & 2 deletions src/helper_sent.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def insert(msgid=None, toAddress='[Broadcast subscribers]', fromAddress=None, su

sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
return ackdata
else:
return None
return None


def delete(ack_data):
Expand Down
12 changes: 6 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"""Mock kivy app with mock threads."""

import os
from kivy.config import Config
from mockbm import multiqueue
import state
from kivy.config import Config # pylint: disable=import-error

from mockbm.class_addressGenerator import FakeAddressGenerator # noqa:E402
from bitmessagekivy.mpybit import NavigateApp # noqa:E402
from mockbm import network # noqa:E402
import pybitmessage.state as state
from pybitmessage.bitmessagekivy.mpybit import NavigateApp # noqa:E402
from pybitmessage.mockbm import multiqueue
from pybitmessage.mockbm.class_addressGenerator import FakeAddressGenerator # noqa:E402
from pybitmessage.mockbm import network # noqa:E402

stats = network.stats
objectracker = network.objectracker
Expand Down
3 changes: 3 additions & 0 deletions src/pathmagic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Hack to work around relative imports
"""
import os
import sys

Expand Down
Loading
Loading