depends pylint fixes

This commit is contained in:
lakshyacis 2019-10-07 13:38:26 +05:30
parent 21faf52f2f
commit e97d02ed78
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
6 changed files with 24 additions and 19 deletions

View File

@ -113,6 +113,7 @@ PACKAGES = {
def detectOS(): def detectOS():
"""Finding out what Operating System is running"""
if detectOS.result is not None: if detectOS.result is not None:
return detectOS.result return detectOS.result
if sys.platform.startswith('openbsd'): if sys.platform.startswith('openbsd'):
@ -132,6 +133,7 @@ detectOS.result = None
def detectOSRelease(): def detectOSRelease():
"""Detecting the release of OS"""
with open("/etc/os-release", 'r') as osRelease: with open("/etc/os-release", 'r') as osRelease:
version = None version = None
for line in osRelease: for line in osRelease:
@ -148,6 +150,7 @@ def detectOSRelease():
def try_import(module, log_extra=False): def try_import(module, log_extra=False):
"""Try to import the non imported packages"""
try: try:
return import_module(module) return import_module(module)
except ImportError: except ImportError:
@ -208,10 +211,8 @@ def check_sqlite():
).fetchone()[0] ).fetchone()[0]
logger.info('SQLite Library Source ID: %s', sqlite_source_id) logger.info('SQLite Library Source ID: %s', sqlite_source_id)
if sqlite_version_number >= 3006023: if sqlite_version_number >= 3006023:
compile_options = ', '.join(map( compile_options = ', '.join(
lambda row: row[0], [row[0] for row in conn.execute('PRAGMA compile_options;')])
conn.execute('PRAGMA compile_options;')
))
logger.info( logger.info(
'SQLite Library Compile Options: %s', compile_options) 'SQLite Library Compile Options: %s', compile_options)
# There is no specific version requirement as yet, so we just # There is no specific version requirement as yet, so we just
@ -230,13 +231,13 @@ def check_sqlite():
conn.close() conn.close()
def check_openssl(): def check_openssl(): # pylint: disable=too-many-branches, too-many-return-statements
"""Do openssl dependency check. """Do openssl dependency check.
Here we are checking for openssl with its all dependent libraries Here we are checking for openssl with its all dependent libraries
and version checking. and version checking.
""" """
# pylint: disable=protected-access, redefined-outer-name
ctypes = try_import('ctypes') ctypes = try_import('ctypes')
if not ctypes: if not ctypes:
logger.error('Unable to check OpenSSL.') logger.error('Unable to check OpenSSL.')
@ -300,7 +301,7 @@ def check_openssl():
' ECDH, and ECDSA enabled.') ' ECDH, and ECDSA enabled.')
return False return False
matches = cflags_regex.findall(openssl_cflags) matches = cflags_regex.findall(openssl_cflags)
if len(matches) > 0: if matches:
logger.error( logger.error(
'This OpenSSL library is missing the following required' 'This OpenSSL library is missing the following required'
' features: %s. PyBitmessage requires OpenSSL 0.9.8b' ' features: %s. PyBitmessage requires OpenSSL 0.9.8b'
@ -311,13 +312,13 @@ def check_openssl():
return False return False
# TODO: The minimum versions of pythondialog and dialog need to be determined # ..todo:: The minimum versions of pythondialog and dialog need to be determined
def check_curses(): def check_curses():
"""Do curses dependency check. """Do curses dependency check.
Here we are checking for curses if available or not with check Here we are checking for curses if available or not with check as interface
as interface requires the pythondialog <https://pypi.org/project/pythondialog> requires the `pythondialog <https://pypi.org/project/pythondialog>`_ package
package and the dialog utility. and the dialog utility.
""" """
if sys.hexversion < 0x20600F0: if sys.hexversion < 0x20600F0:
logger.error( logger.error(

View File

@ -1,9 +1,11 @@
"""This module is for generating ack payload.""" """
This module is for generating ack payload
"""
from binascii import hexlify
from struct import pack
import highlevelcrypto import highlevelcrypto
import helper_random import helper_random
from binascii import hexlify
from struct import pack
from addresses import encodeVarint from addresses import encodeVarint
# This function generates payload objects for message acknowledgements # This function generates payload objects for message acknowledgements

View File

@ -3,6 +3,7 @@ from pyelliptic import arithmetic
# This function expects that pubkey begin with \x04 # This function expects that pubkey begin with \x04
def calculateBitcoinAddressFromPubkey(pubkey): def calculateBitcoinAddressFromPubkey(pubkey):
"""This function expects that pubkey begin's with the bitcoin prefix"""
if len(pubkey) != 65: if len(pubkey) != 65:
print 'Could not calculate Bitcoin address from pubkey because function was passed a pubkey that was', len(pubkey), 'bytes long rather than 65.' print 'Could not calculate Bitcoin address from pubkey because function was passed a pubkey that was', len(pubkey), 'bytes long rather than 65.'
return "error" return "error"

View File

@ -1,11 +1,11 @@
"""Helper Inbox performs inbox messages related operations.""" """Helper Inbox performs inbox messages related operations"""
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
import queues import queues
def insert(t): def insert(t):
"""Perform an insert into the "inbox" table""" """Perform an insert into the "inbox" table"""
sqlExecute('''INSERT INTO inbox VALUES (?,?,?,?,?,?,?,?,?,?)''', *t) sqlExecute('''INSERT INTO inbox VALUES (?,?,?,?,?,?,?,?,?,?)''', *t)
# shouldn't emit changedInboxUnread and displayNewInboxMessage # shouldn't emit changedInboxUnread and displayNewInboxMessage
# at the same time # at the same time

View File

@ -1,4 +1,6 @@
"""Convenience functions for random operations. Not suitable for security / cryptography operations.""" """
Convenience functions for random operations. Not suitable for security / cryptography operations
"""
import os import os
import random import random

View File

@ -2,11 +2,9 @@
SQL-related functions defined here are really pass the queries (or other SQL SQL-related functions defined here are really pass the queries (or other SQL
commands) to :class:`.threads.sqlThread` through `sqlSubmitQueue` queue and check commands) to :class:`.threads.sqlThread` through `sqlSubmitQueue` queue and check
or return the result got from `sqlReturnQueue`. or return the result got from `sqlReturnQueue`.
This is done that way because :mod:`sqlite3` is so thread-unsafe that they This is done that way because :mod:`sqlite3` is so thread-unsafe that they
won't even let you call it from different threads using your own locks. won't even let you call it from different threads using your own locks.
SQLite objects can only be used from one thread. SQLite objects can only be used from one thread.
.. note:: This actually only applies for certain deployments, and/or .. note:: This actually only applies for certain deployments, and/or
really old version of sqlite. I haven't actually seen it anywhere. really old version of sqlite. I haven't actually seen it anywhere.
Current versions do have support for threading and multiprocessing. Current versions do have support for threading and multiprocessing.
@ -50,6 +48,7 @@ def sqlQuery(sqlStatement, *args):
def sqlExecuteChunked(sqlStatement, idCount, *args): def sqlExecuteChunked(sqlStatement, idCount, *args):
"""Execute chunked SQL statement to avoid argument limit"""
# SQLITE_MAX_VARIABLE_NUMBER, # SQLITE_MAX_VARIABLE_NUMBER,
# unfortunately getting/setting isn't exposed to python # unfortunately getting/setting isn't exposed to python
sqlExecuteChunked.chunkSize = 999 sqlExecuteChunked.chunkSize = 999