Merge pull request #31 from cis-navjot-g/codequalitykivy
Code Fixes 2 regarding PR#11
This commit is contained in:
commit
3bff3c5631
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
src/identiconGeneration
|
src/identiconGeneration.py
|
||||||
=================================
|
=================================
|
||||||
"""
|
"""
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
|
@ -5,6 +5,7 @@ src/bitmessagekivy/mpybit.py
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
import identiconGeneration
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from helper_sql import sqlExecute, sqlQuery
|
from helper_sql import sqlExecute, sqlQuery
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
|
@ -57,16 +58,12 @@ import state
|
||||||
from uikivysignaler import UIkivySignaler
|
from uikivysignaler import UIkivySignaler
|
||||||
# pylint: disable=unused-argument, too-few-public-methods, import-error
|
# pylint: disable=unused-argument, too-few-public-methods, import-error
|
||||||
|
|
||||||
import identiconGeneration
|
|
||||||
import os
|
|
||||||
from kivy.core.clipboard import Clipboard
|
|
||||||
# pylint: disable=unused-argument, too-few-public-methods
|
|
||||||
|
|
||||||
|
|
||||||
def toast(text):
|
def toast(text):
|
||||||
"""Method will display the toast message."""
|
"""Method will display the toast message."""
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
if platform == 'linux':
|
if platform == 'linux':
|
||||||
from kivymd.toast.kivytoast import toast # pylint: disable=redefined-outer-name
|
from kivymd.toast.kivytoast import toast
|
||||||
toast(text)
|
toast(text)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -104,7 +101,7 @@ class Inbox(Screen):
|
||||||
|
|
||||||
def loadMessagelist(self, account, where="", what=""):
|
def loadMessagelist(self, account, where="", what=""):
|
||||||
"""Load Inbox list for Inbox messages."""
|
"""Load Inbox list for Inbox messages."""
|
||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals, unused-variable
|
||||||
if state.searcing_text:
|
if state.searcing_text:
|
||||||
where = ['subject', 'message']
|
where = ['subject', 'message']
|
||||||
what = state.searcing_text
|
what = state.searcing_text
|
||||||
|
@ -1866,7 +1863,6 @@ class Draft(Screen):
|
||||||
'draft',
|
'draft',
|
||||||
encoding,
|
encoding,
|
||||||
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
BMConfigParser().getint('bitmessagesettings', 'ttl'))
|
||||||
|
|
||||||
state.msg_counter_objs = src_object.children[2].children[0].ids
|
state.msg_counter_objs = src_object.children[2].children[0].ids
|
||||||
state.draft_count = str(int(state.draft_count) + 1)
|
state.draft_count = str(int(state.draft_count) + 1)
|
||||||
src_object.ids.sc16.clear_widgets()
|
src_object.ids.sc16.clear_widgets()
|
||||||
|
|
|
@ -70,7 +70,7 @@ depends.check_dependencies()
|
||||||
|
|
||||||
|
|
||||||
def connectToStream(streamNumber):
|
def connectToStream(streamNumber):
|
||||||
"""Connecting to stream"""
|
"""Method helps us to connect with the stream"""
|
||||||
state.streamsInWhichIAmParticipating.append(streamNumber)
|
state.streamsInWhichIAmParticipating.append(streamNumber)
|
||||||
|
|
||||||
if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
|
if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections():
|
||||||
|
@ -111,7 +111,7 @@ def _fixSocket():
|
||||||
addressToString = ctypes.windll.ws2_32.WSAAddressToStringA
|
addressToString = ctypes.windll.ws2_32.WSAAddressToStringA
|
||||||
|
|
||||||
def inet_ntop(family, host):
|
def inet_ntop(family, host):
|
||||||
"""inet ntop"""
|
"""Method converts an IP address in packed binary format to string format"""
|
||||||
if family == socket.AF_INET:
|
if family == socket.AF_INET:
|
||||||
if len(host) != 4:
|
if len(host) != 4:
|
||||||
raise ValueError("invalid IPv4 host")
|
raise ValueError("invalid IPv4 host")
|
||||||
|
@ -133,7 +133,7 @@ def _fixSocket():
|
||||||
stringToAddress = ctypes.windll.ws2_32.WSAStringToAddressA
|
stringToAddress = ctypes.windll.ws2_32.WSAStringToAddressA
|
||||||
|
|
||||||
def inet_pton(family, host):
|
def inet_pton(family, host):
|
||||||
"""inet pton"""
|
"""Method converts an IP address in string format to a packed binary format"""
|
||||||
buf = "\0" * 28
|
buf = "\0" * 28
|
||||||
lengthBuf = pack("I", len(buf))
|
lengthBuf = pack("I", len(buf))
|
||||||
if stringToAddress(str(host),
|
if stringToAddress(str(host),
|
||||||
|
@ -189,7 +189,7 @@ def signal_handler(signum, frame):
|
||||||
|
|
||||||
|
|
||||||
class Main: # pylint: disable=no-init, old-style-class
|
class Main: # pylint: disable=no-init, old-style-class
|
||||||
"""Main Method"""
|
"""Method starts the proxy config plugin"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def start_proxyconfig(config):
|
def start_proxyconfig(config):
|
||||||
|
@ -213,7 +213,7 @@ class Main: # pylint: disable=no-init, old-style-class
|
||||||
proxy_type, time.time() - proxyconfig_start)
|
proxy_type, time.time() - proxyconfig_start)
|
||||||
|
|
||||||
def start(self): # pylint: disable=too-many-statements, too-many-branches, too-many-locals
|
def start(self): # pylint: disable=too-many-statements, too-many-branches, too-many-locals
|
||||||
"""Start the main method"""
|
"""This method helps to start the daemon"""
|
||||||
_fixSocket()
|
_fixSocket()
|
||||||
|
|
||||||
config = BMConfigParser()
|
config = BMConfigParser()
|
||||||
|
@ -276,7 +276,7 @@ class Main: # pylint: disable=no-init, old-style-class
|
||||||
# is the application already running? If yes then exit.
|
# is the application already running? If yes then exit.
|
||||||
try:
|
try:
|
||||||
shared.thisapp = singleinstance("", daemon)
|
shared.thisapp = singleinstance("", daemon)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if daemon:
|
if daemon:
|
||||||
|
@ -438,7 +438,7 @@ class Main: # pylint: disable=no-init, old-style-class
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def daemonize():
|
def daemonize():
|
||||||
"""Daemonize"""
|
"""Running as a daemon. Send signal in end."""
|
||||||
grandfatherPid = os.getpid()
|
grandfatherPid = os.getpid()
|
||||||
parentPid = None
|
parentPid = None
|
||||||
try:
|
try:
|
||||||
|
@ -491,14 +491,14 @@ class Main: # pylint: disable=no-init, old-style-class
|
||||||
os.kill(grandfatherPid, signal.SIGTERM)
|
os.kill(grandfatherPid, signal.SIGTERM)
|
||||||
|
|
||||||
def setSignalHandler(self): # pylint: disable=no-self-use
|
def setSignalHandler(self): # pylint: disable=no-self-use
|
||||||
"""Set Signal Handler"""
|
"""Setting the Signal Handler"""
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def usage():
|
def usage():
|
||||||
"""getting usages"""
|
"""After passing argument, method displays the usages"""
|
||||||
print 'Usage: ' + sys.argv[0] + ' [OPTIONS]'
|
print 'Usage: ' + sys.argv[0] + ' [OPTIONS]'
|
||||||
print '''
|
print '''
|
||||||
Options:
|
Options:
|
||||||
|
@ -511,14 +511,14 @@ All parameters are optional.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def stop(self): # pylint: disable=no-self-use
|
def stop(self): # pylint: disable=no-self-use
|
||||||
"""Stopping Bitmessage Deamon"""
|
"""Method helps to stop the Bitmessage Deamon"""
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print 'Stopping Bitmessage Deamon.'
|
print 'Stopping Bitmessage Deamon.'
|
||||||
shutdown.doCleanShutdown()
|
shutdown.doCleanShutdown()
|
||||||
|
|
||||||
# ..todo: nice function but no one is using this
|
# ..todo: nice function but no one is using this
|
||||||
def getApiAddress(self): # pylint: disable=no-self-use
|
def getApiAddress(self): # pylint: disable=no-self-use
|
||||||
"""Getting Api Addresses"""
|
"""This method returns the Api Addresses"""
|
||||||
if not BMConfigParser().safeGetBoolean(
|
if not BMConfigParser().safeGetBoolean(
|
||||||
'bitmessagesettings', 'apienabled'):
|
'bitmessagesettings', 'apienabled'):
|
||||||
return None
|
return None
|
||||||
|
@ -528,7 +528,7 @@ All parameters are optional.
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Start of main thread"""
|
"""Start of the main thread"""
|
||||||
mainprogram = Main()
|
mainprogram = Main()
|
||||||
mainprogram.start()
|
mainprogram.start()
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
src/pyelliptic/openssl.py
|
src/pyelliptic/openssl.py
|
||||||
=================================
|
=================================
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
from kivy.utils import platform
|
from kivy.utils import platform
|
||||||
|
@ -19,7 +18,8 @@ OpenSSL = None
|
||||||
|
|
||||||
|
|
||||||
class CipherName: # pylint: disable=old-style-class
|
class CipherName: # pylint: disable=old-style-class
|
||||||
"""Getting CipherName"""
|
"""Method helps to get pointers, name and blocksize"""
|
||||||
|
|
||||||
def __init__(self, name, pointer, blocksize):
|
def __init__(self, name, pointer, blocksize):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._pointer = pointer
|
self._pointer = pointer
|
||||||
|
@ -31,20 +31,20 @@ class CipherName: # pylint: disable=old-style-class
|
||||||
" | Function pointer : " + str(self._pointer)
|
" | Function pointer : " + str(self._pointer)
|
||||||
|
|
||||||
def get_pointer(self):
|
def get_pointer(self):
|
||||||
"""Getting pointer"""
|
"""Method returns the pointer"""
|
||||||
return self._pointer()
|
return self._pointer()
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
"""Getting Name"""
|
"""Method returns the name"""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
def get_blocksize(self):
|
def get_blocksize(self):
|
||||||
"""Getting blocksize"""
|
"""Method returns the blocksize"""
|
||||||
return self._blocksize
|
return self._blocksize
|
||||||
|
|
||||||
|
|
||||||
def get_version(library):
|
def get_version(library):
|
||||||
"""Getting versions"""
|
"""Method returns the version of the OpenSSL Library"""
|
||||||
version = None
|
version = None
|
||||||
hexversion = None
|
hexversion = None
|
||||||
cflags = None
|
cflags = None
|
||||||
|
@ -645,7 +645,7 @@ class _OpenSSL: # pylint: disable=too-many-instance-attributes, old-style-cl
|
||||||
|
|
||||||
|
|
||||||
def loadOpenSSL():
|
def loadOpenSSL():
|
||||||
"""Loading OpenSSL"""
|
"""Method find and load the OpenSSL library"""
|
||||||
# pylint: disable=global-statement, protected-access, too-many-branches
|
# pylint: disable=global-statement, protected-access, too-many-branches
|
||||||
global OpenSSL
|
global OpenSSL
|
||||||
from os import path, environ
|
from os import path, environ
|
||||||
|
|
Reference in New Issue
Block a user