From b4a0d8ad37879ce7df5c765c659e7447087d12ff Mon Sep 17 00:00:00 2001 From: surbhi Date: Tue, 3 Jul 2018 15:36:20 +0530 Subject: [PATCH] fix codacy coding standards issue --- src/main.kv | 4 +-- src/main.py | 3 +- src/mpybit.py | 81 +++++++++++++++++++++++---------------------------- 3 files changed, 40 insertions(+), 48 deletions(-) diff --git a/src/main.kv b/src/main.kv index 9125608e..8ea56c6b 100644 --- a/src/main.kv +++ b/src/main.kv @@ -1,4 +1,4 @@ -: +: BoxLayout: AnchorLayout: TextInput: @@ -13,4 +13,4 @@ Button: id: btnExit text: "Exit" - on_press: root.say_exit() + on_press: root.sayexit() diff --git a/src/main.py b/src/main.py index 6fb9beda..673b1307 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,5 @@ -from bitmessagemain import main +from bitmessagemain import main # import main method to run first for thread start if __name__ == '__main__': + """python main will call for bitmessage main to start threads.""" main() diff --git a/src/mpybit.py b/src/mpybit.py index a6457b49..050e3013 100644 --- a/src/mpybit.py +++ b/src/mpybit.py @@ -1,45 +1,51 @@ -from kivy.app import App -from kivy.uix.boxlayout import BoxLayout -from kivy.core.window import Window -from os import environ +import threading -# environ['BITMESSAGE_HOME'] = '~/home/cis/Desktop/pybit' -# environ['HOME'] = '~/home/cis/Desktop/pybit' +import time + + +from addresses import addBMIfNotPresent, decodeAddress from bmconfigparser import BMConfigParser + from helper_ackPayload import genAckPayload -from addresses import decodeAddress, addBMIfNotPresent -from class_sqlThread import sqlThread -from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure -import time + + +from helper_sql import sqlExecute + + +from kivy.app import App +from kivy.core.window import Window +from kivy.uix.boxlayout import BoxLayout + import queues -import state -import threading + import shutdown -from inventory import Inventory statusIconColor = 'red' -class Login_Screen(BoxLayout): - +class LoginScreen(BoxLayout): + """This will use for sending message to recipents from mobile client.""" def send(self): - # print(len(Inventory()), "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") - # print(len(Inventory().unexpired_hashes_by_stream(1)), "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDdd") + """Send used for sending message with title and body.""" queues.apiAddressGeneratorReturnQueue.queue.clear() streamNumberForAddress = 1 label = "CisDevelper" eighteenByteRipe = False nonceTrialsPerByte = 1000 payloadLengthExtraBytes = 1000 - print("BREAK POINT STARTING @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") - queues.addressGeneratorQueue.put( ( - 'createRandomAddress', 4, streamNumberForAddress, label, 1, "", eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes ) + print("BREAK POINT STARTING") + queues.addressGeneratorQueue.put( + ( + 'createRandomAddress', 4, + streamNumberForAddress, label, 1, + "", eighteenByteRipe, nonceTrialsPerByte, + payloadLengthExtraBytes + ) ) print(BMConfigParser().sections(), "BMConfigParser().sections()") fromAddress = queues.apiAddressGeneratorReturnQueue.get() - print("BREAK POINT ENDING //////////////////////////////////////////////////////////////////") - # toAddress = "BM-NBqmcWH5XJMmXCVxD4HVTNPe3naGgHgE" + print("BREAK POINT ENDING") toAddress = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe" message = self.ids.user_input.text subject = 'Test' @@ -48,7 +54,8 @@ class Login_Screen(BoxLayout): sendMessageToPeople = True if sendMessageToPeople: if toAddress != '': - status, addressVersionNumber, streamNumber, ripe = decodeAddress(toAddress) + status, addressVersionNumber, streamNumber, ripe = decodeAddress( + toAddress) if status == 'success': toAddress = addBMIfNotPresent(toAddress) @@ -61,7 +68,6 @@ class Login_Screen(BoxLayout): stealthLevel = BMConfigParser().safeGetInt( 'bitmessagesettings', 'ackstealthlevel') ackdata = genAckPayload(streamNumber, stealthLevel) - t = () sqlExecute( '''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', '', @@ -79,34 +85,19 @@ class Login_Screen(BoxLayout): 'sent', encoding, BMConfigParser().getint('bitmessagesettings', 'ttl')) - toLabel = '' - # queryreturn = sqlQuery('''select status from sent''') - # if queryreturn != []: - # for row in queryreturn: - # print(row, "YZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZZYZYZYZYZYZYZYZYZY") - # toLabel, = row queues.workerQueue.put(('sendmessage', toAddress)) print("sqlExecute successfully ##### ##################") - - # App.get_running_app().stop() - # Window.close() - # shutdown.doCleanShutdown() - for i in threading.enumerate(): - print (i.name) - # from threading import Timer - # t = Timer(300.0, connectedHostsList()) - # t.start() - # print(connectedHostsList()) - print("calling connectios") + for i in threading.enumerate(): + print(i.name) return None - def say_exit(self): - print ("**************************EXITING FROM APPLICATION*****************************") + def sayexit(self): + print("**************************EXITING FROM APPLICATION*****************************") shutdown.doCleanShutdown() Window.close() + class MainApp(App): - def build(self): - return Login_Screen() + return LoginScreen()