From fc50d7162555976bfc682d0a7d248fa5904e88ad Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Wed, 29 Dec 2021 20:49:53 +0530 Subject: [PATCH] Fixed changes on ui screens load --- src/shutdown.py | 1 + .../pybitmessage/baseclass/addressbook.py | 21 +++--- .../mock/pybitmessage/baseclass/allmail.py | 19 +++--- .../pybitmessage/baseclass/msg_composer.py | 66 +++++++++---------- .../mock/pybitmessage/baseclass/network.py | 59 +++++++++-------- .../mock/pybitmessage/baseclass/popup.py | 1 + .../pybitmessage/baseclass/scan_screen.py | 2 - .../mock/pybitmessage/class_singleCleaner.py | 54 +++++++-------- .../mock/pybitmessage/identiconGeneration.py | 2 +- .../mock/pybitmessage/kivy_helper_search.py | 2 +- src/tests/mock/pybitmessage/main.kv | 52 +++++++-------- 11 files changed, 142 insertions(+), 137 deletions(-) diff --git a/src/shutdown.py b/src/shutdown.py index e85b0803..8295e962 100644 --- a/src/shutdown.py +++ b/src/shutdown.py @@ -15,6 +15,7 @@ from queues import ( def doCleanShutdown(): + import pdb; pdb.set_trace() """ Used to tell all the treads to finish work and exit. """ diff --git a/src/tests/mock/pybitmessage/baseclass/addressbook.py b/src/tests/mock/pybitmessage/baseclass/addressbook.py index 20e1ed9e..a0a9f737 100644 --- a/src/tests/mock/pybitmessage/baseclass/addressbook.py +++ b/src/tests/mock/pybitmessage/baseclass/addressbook.py @@ -49,9 +49,9 @@ class AddressBook(Screen): what = state.searcing_text xAddress = '' self.ids.tag_label.text = '' - self.queryreturn = kivy_helper_search.search_sql( - xAddress, account, "addressbook", where, what, False) - self.queryreturn = [obj for obj in reversed(self.queryreturn)] + # self.queryreturn = kivy_helper_search.search_sql( + # xAddress, account, "addressbook", where, what, False) + # self.queryreturn = [obj for obj in reversed(self.queryreturn)] if self.queryreturn: self.ids.tag_label.text = 'Address Book' self.has_refreshed = True @@ -151,8 +151,8 @@ class AddressBook(Screen): # if len(self.ids.ml.children) == 0: if self.ids.ml.children is not None: self.ids.tag_label.text = '' - sqlExecute( - "DELETE FROM addressbook WHERE address = '{}';".format(address)) + # sqlExecute( + # "DELETE FROM addressbook WHERE address = '{}';".format(address)) toast('Address Deleted') def close_pop(self, instance): @@ -162,17 +162,18 @@ class AddressBook(Screen): def update_addbook_label(self, instance): """Updating the label of address book address""" - address_list = kivy_helper_search.search_sql(folder="addressbook") + # address_list = kivy_helper_search.search_sql(folder="addressbook") + address_list = [] stored_labels = [labels[0] for labels in address_list] add_dict = dict(address_list) label = str(self.addbook_popup.content_cls.ids.add_label.text) if label in stored_labels and self.address == add_dict[label]: stored_labels.remove(label) if label and label not in stored_labels: - sqlExecute( - "UPDATE addressbook SET label = '{}' WHERE" - " address = '{}';".format( - label, self.addbook_popup.content_cls.address)) + # sqlExecute( + # "UPDATE addressbook SET label = '{}' WHERE" + # " address = '{}';".format( + # label, self.addbook_popup.content_cls.address)) state.kivyapp.root.ids.sc11.ids.ml.clear_widgets() state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '') self.addbook_popup.dismiss() diff --git a/src/tests/mock/pybitmessage/baseclass/allmail.py b/src/tests/mock/pybitmessage/baseclass/allmail.py index 9e80f94e..8231c3d3 100644 --- a/src/tests/mock/pybitmessage/baseclass/allmail.py +++ b/src/tests/mock/pybitmessage/baseclass/allmail.py @@ -69,15 +69,16 @@ class Allmails(Screen): def allMessageQuery(self, start_indx, end_indx): """Retrieving data from inbox or sent both tables""" - self.all_mails = sqlQuery( - "SELECT toaddress, fromaddress, subject, message, folder, ackdata" - " As id, DATE(senttime) As actionTime, senttime as msgtime FROM sent WHERE" - " folder = 'sent' and fromaddress = '{0}'" - " UNION SELECT toaddress, fromaddress, subject, message, folder," - " msgid As id, DATE(received) As actionTime, received as msgtime FROM inbox" - " WHERE folder = 'inbox' and toaddress = '{0}'" - " ORDER BY actionTime DESC limit {1}, {2}".format( - self.account, start_indx, end_indx)) + self.all_mails = [] + # sqlQuery( + # "SELECT toaddress, fromaddress, subject, message, folder, ackdata" + # " As id, DATE(senttime) As actionTime, senttime as msgtime FROM sent WHERE" + # " folder = 'sent' and fromaddress = '{0}'" + # " UNION SELECT toaddress, fromaddress, subject, message, folder," + # " msgid As id, DATE(received) As actionTime, received as msgtime FROM inbox" + # " WHERE folder = 'inbox' and toaddress = '{0}'" + # " ORDER BY actionTime DESC limit {1}, {2}".format( + # self.account, start_indx, end_indx)) def set_AllmailCnt(self, Count): # pylint: disable=no-self-use """This method is used to set allmails message count""" diff --git a/src/tests/mock/pybitmessage/baseclass/msg_composer.py b/src/tests/mock/pybitmessage/baseclass/msg_composer.py index ad536eff..8abfb625 100644 --- a/src/tests/mock/pybitmessage/baseclass/msg_composer.py +++ b/src/tests/mock/pybitmessage/baseclass/msg_composer.py @@ -93,19 +93,19 @@ class DropDownWidget(BoxLayout): if status == "success": navApp.root.ids.sc3.children[0].active = True if state.detailPageType == "draft" and state.send_draft_mail: - sqlExecute( - "UPDATE sent SET toaddress = ?" - ", fromaddress = ? , subject = ?" - ", message = ?, folder = 'sent'" - ", senttime = ?, lastactiontime = ?" - " WHERE ackdata = ?;", - toAddress, - fromAddress, - subject, - message, - int(time.time()), - int(time.time()), - state.send_draft_mail) + # sqlExecute( + # "UPDATE sent SET toaddress = ?" + # ", fromaddress = ? , subject = ?" + # ", message = ?, folder = 'sent'" + # ", senttime = ?, lastactiontime = ?" + # " WHERE ackdata = ?;", + # toAddress, + # fromAddress, + # subject, + # message, + # int(time.time()), + # int(time.time()), + # state.send_draft_mail) self.parent.parent.screens[13].clear_widgets() self.parent.parent.screens[13].add_widget(Factory.Draft()) # state.detailPageType = '' @@ -121,28 +121,28 @@ class DropDownWidget(BoxLayout): print("streamNumber > 1 or streamNumber == 0") stealthLevel = BMConfigParser().safeGetInt( 'bitmessagesettings', 'ackstealthlevel') - from helper_ackPayload import genAckPayload + # from helper_ackPayload import genAckPayload # ackdata = genAckPayload(streamNumber, stealthLevel) # t = () - sqlExecute( - '''INSERT INTO sent VALUES - (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', - '', - addBMIfNotPresent(toAddress), - ripe, - fromAddress, - subject, - message, - genAckPayload(streamNumber, stealthLevel), #ackdata - int(time.time()), - int(time.time()), - 0, - 'msgqueued', - 0, - 'sent', - 3, #encoding - BMConfigParser().safeGetInt( - 'bitmessagesettings', 'ttl')) + # sqlExecute( + # '''INSERT INTO sent VALUES + # (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', + # '', + # addBMIfNotPresent(toAddress), + # ripe, + # fromAddress, + # subject, + # message, + # genAckPayload(streamNumber, stealthLevel), #ackdata + # int(time.time()), + # int(time.time()), + # 0, + # 'msgqueued', + # 0, + # 'sent', + # 3, #encoding + # BMConfigParser().safeGetInt( + # 'bitmessagesettings', 'ttl')) state.check_sent_acc = fromAddress # state.msg_counter_objs = self.parent.parent.parent.parent\ # .parent.parent.children[2].children[0].ids diff --git a/src/tests/mock/pybitmessage/baseclass/network.py b/src/tests/mock/pybitmessage/baseclass/network.py index 44f1cb10..7e2fd653 100644 --- a/src/tests/mock/pybitmessage/baseclass/network.py +++ b/src/tests/mock/pybitmessage/baseclass/network.py @@ -1,7 +1,7 @@ # from pybitmessage import state -# from kivy.clock import Clock -# from kivy.properties import StringProperty +from kivy.clock import Clock +from kivy.properties import StringProperty from kivy.uix.screenmanager import Screen # from pybitmessage.network import objectracker, stats @@ -10,32 +10,33 @@ from kivy.uix.screenmanager import Screen class NetworkStat(Screen): """NetworkStat class for kivy Ui""" - # text_variable_1 = StringProperty( - # '{0}::{1}'.format('Total Connections', '0')) - # text_variable_2 = StringProperty( - # 'Processed {0} per-to-per messages'.format('0')) - # text_variable_3 = StringProperty( - # 'Processed {0} brodcast messages'.format('0')) - # text_variable_4 = StringProperty( - # 'Processed {0} public keys'.format('0')) - # text_variable_5 = StringProperty( - # 'Processed {0} object to be synced'.format('0')) + text_variable_1 = StringProperty( + '{0}::{1}'.format('Total Connections', '0')) + text_variable_2 = StringProperty( + 'Processed {0} per-to-per messages'.format('0')) + text_variable_3 = StringProperty( + 'Processed {0} brodcast messages'.format('0')) + text_variable_4 = StringProperty( + 'Processed {0} public keys'.format('0')) + text_variable_5 = StringProperty( + 'Processed {0} object to be synced'.format('0')) - # def __init__(self, *args, **kwargs): - # """Init method for network stat""" - # super(NetworkStat, self).__init__(*args, **kwargs) - # Clock.schedule_interval(self.init_ui, 1) + def __init__(self, *args, **kwargs): + """Init method for network stat""" + super(NetworkStat, self).__init__(*args, **kwargs) + Clock.schedule_interval(self.init_ui, 1) - # def init_ui(self, dt=0): - # """Clock Schdule for method networkstat screen""" - # self.text_variable_1 = '{0} :: {1}'.format( - # 'Total Connections', str(len(stats.connectedHostsList()))) - # self.text_variable_2 = 'Processed {0} per-to-per messages'.format( - # str(state.numberOfMessagesProcessed)) - # self.text_variable_3 = 'Processed {0} brodcast messages'.format( - # str(state.numberOfBroadcastsProcessed)) - # self.text_variable_4 = 'Processed {0} public keys'.format( - # str(state.numberOfPubkeysProcessed)) - # self.text_variable_5 = '{0} object to be synced'.format( - # len(objectracker.missingObjects)) - pass + def init_ui(self, dt=0): + """Clock Schdule for method networkstat screen""" + pass + # self.text_variable_1 = '{0} :: {1}'.format( + # 'Total Connections', str(len(stats.connectedHostsList()))) + # self.text_variable_2 = 'Processed {0} per-to-per messages'.format( + # str(state.numberOfMessagesProcessed)) + # self.text_variable_3 = 'Processed {0} brodcast messages'.format( + # str(state.numberOfBroadcastsProcessed)) + # self.text_variable_4 = 'Processed {0} public keys'.format( + # str(state.numberOfPubkeysProcessed)) + # self.text_variable_5 = '{0} object to be synced'.format( + # len(objectracker.missingObjects)) + diff --git a/src/tests/mock/pybitmessage/baseclass/popup.py b/src/tests/mock/pybitmessage/baseclass/popup.py index 0aab78ca..0988f18a 100644 --- a/src/tests/mock/pybitmessage/baseclass/popup.py +++ b/src/tests/mock/pybitmessage/baseclass/popup.py @@ -179,6 +179,7 @@ class AppClosingPopup(Popup): """Action on closing window""" if text == 'Yes': print("*******************EXITING FROM APPLICATION*******************") + import pdb; pdb.set_trace() import shutdown shutdown.doCleanShutdown() else: diff --git a/src/tests/mock/pybitmessage/baseclass/scan_screen.py b/src/tests/mock/pybitmessage/baseclass/scan_screen.py index 664f4557..142ae73f 100644 --- a/src/tests/mock/pybitmessage/baseclass/scan_screen.py +++ b/src/tests/mock/pybitmessage/baseclass/scan_screen.py @@ -45,13 +45,11 @@ class ScanScreen(Screen): def __init__(self, *args, **kwargs): """Getting AddressBook Details""" - import pdb;pdb.set_trace() super(ScanScreen, self).__init__(*args, **kwargs) self.check_camera() def check_camera(self): """This method is used for checking camera avaibility""" - import pdb;pdb.set_trace() if platform != "android": import cv2 cap = cv2.VideoCapture(0) diff --git a/src/tests/mock/pybitmessage/class_singleCleaner.py b/src/tests/mock/pybitmessage/class_singleCleaner.py index d9f87604..419f419e 100644 --- a/src/tests/mock/pybitmessage/class_singleCleaner.py +++ b/src/tests/mock/pybitmessage/class_singleCleaner.py @@ -75,35 +75,37 @@ class singleCleaner(StoppableThread): 'updateStatusBar', 'Doing housekeeping (Flushing inventory in memory to disk...)' )) - Inventory().flush() + # Inventory().flush() queues.UISignalQueue.put(('updateStatusBar', '')) # If we are running as a daemon then we are going to fill up the UI # queue which will never be handled by a UI. We should clear it to # save memory. # FIXME redundant? - if state.thisapp.daemon or not state.enableGUI: - queues.UISignalQueue.queue.clear() + # if state.thisapp.daemon or not state.enableGUI: + # queues.UISignalQueue.queue.clear() if timeWeLastClearedInventoryAndPubkeysTables < \ int(time.time()) - 7380: timeWeLastClearedInventoryAndPubkeysTables = int(time.time()) - Inventory().clean() + import pdb;pdb.set_trace() + # Inventory().clean() queues.workerQueue.put(('sendOnionPeerObj', '')) # pubkeys - sqlExecute( - "DELETE FROM pubkeys WHERE time?)", - int(time.time()), int(time.time()) - - state.maximumLengthOfTimeToBotherResendingMessages - ) + queryreturn = [] + # sqlQuery( + # "SELECT toaddress, ackdata, status FROM sent" + # " WHERE ((status='awaitingpubkey' OR status='msgsent')" + # " AND folder='sent' AND sleeptill?)", + # int(time.time()), int(time.time()) + # - state.maximumLengthOfTimeToBotherResendingMessages + # ) for row in queryreturn: if len(row) < 2: self.logger.error( @@ -183,9 +185,9 @@ class singleCleaner(StoppableThread): 'updateStatusBar', 'Doing work necessary to again attempt to request a public key...' )) - sqlExecute( - '''UPDATE sent SET status='msgqueued' WHERE toaddress=?''', - address) + # sqlExecute( + # '''UPDATE sent SET status='msgqueued' WHERE toaddress=?''', + # address) queues.workerQueue.put(('sendmessage', '')) def resendMsg(self, ackdata): @@ -194,9 +196,9 @@ class singleCleaner(StoppableThread): 'It has been a long time and we haven\'t heard an acknowledgement' ' to our msg. Sending again.' ) - sqlExecute( - '''UPDATE sent SET status='msgqueued' WHERE ackdata=?''', - ackdata) + # sqlExecute( + # '''UPDATE sent SET status='msgqueued' WHERE ackdata=?''', + # ackdata) queues.workerQueue.put(('sendmessage', '')) queues.UISignalQueue.put(( 'updateStatusBar', @@ -208,10 +210,10 @@ def deleteTrashMsgPermonantly(): """This method is used to delete old messages""" ndays_before_time = datetime.now() - timedelta(days=30) old_messages = time.mktime(ndays_before_time.timetuple()) - sqlExecute( - "delete from sent where folder = 'trash' and lastactiontime <= ?;", - int(old_messages)) - sqlExecute( - "delete from inbox where folder = 'trash' and received <= ?;", - int(old_messages)) + # sqlExecute( + # "delete from sent where folder = 'trash' and lastactiontime <= ?;", + # int(old_messages)) + # sqlExecute( + # "delete from inbox where folder = 'trash' and received <= ?;", + # int(old_messages)) return diff --git a/src/tests/mock/pybitmessage/identiconGeneration.py b/src/tests/mock/pybitmessage/identiconGeneration.py index 8fdc0e3b..46180a99 100644 --- a/src/tests/mock/pybitmessage/identiconGeneration.py +++ b/src/tests/mock/pybitmessage/identiconGeneration.py @@ -25,7 +25,7 @@ def generate(Generate_string=None): # image = Image.new(MODE, V_RESOLUTION, BACKGROUND_COLOR) # image = generate_image(image, color, hash_string) image = open("/home/cis/Downloads/1.png") - image = image.resize(RESOLUTION, 0) + # image = image.resize(RESOLUTION, 0) data = BytesIO() image.save(data, format='png') data.seek(0) diff --git a/src/tests/mock/pybitmessage/kivy_helper_search.py b/src/tests/mock/pybitmessage/kivy_helper_search.py index e5a48637..82e9bdd6 100644 --- a/src/tests/mock/pybitmessage/kivy_helper_search.py +++ b/src/tests/mock/pybitmessage/kivy_helper_search.py @@ -71,4 +71,4 @@ def search_sql( start_indx, end_indx) # elif folder == "addressbook": # sqlStatementBase += " limit {0}, {1}".format(start_indx, end_indx) - return sqlQuery(sqlStatementBase, sqlArguments) + return []#sqlQuery(sqlStatementBase, sqlArguments) diff --git a/src/tests/mock/pybitmessage/main.kv b/src/tests/mock/pybitmessage/main.kv index 18334ea2..40adbe70 100644 --- a/src/tests/mock/pybitmessage/main.kv +++ b/src/tests/mock/pybitmessage/main.kv @@ -262,32 +262,32 @@ MDNavigationLayout: id:sc9 MyAddress: id:sc10 - # AddressBook: - # id:sc11 -# Payment: -# id:sc12 -# NetworkStat: -# id:sc13 -# MailDetail: -# id:sc14 -# ShowQRCode: -# id:sc15 -# Draft: -# id:sc16 -# Allmails: -# id:sc17 -# # Credits: -# # id:sc18 -# # Starred: -# # id:sc19 -# # Archieve: -# # id:sc20 -# # ChatRoom: -# # id:sc21 -# # ChatList: -# # id:sc22 -# ScanScreen: -# id:sc23 + AddressBook: + id:sc11 + Payment: + id:sc12 + NetworkStat: + id:sc13 + MailDetail: + id:sc14 + ShowQRCode: + id:sc15 + Draft: + id:sc16 + Allmails: + id:sc17 + # Credits: + # id:sc18 + # Starred: + # id:sc19 + # Archieve: + # id:sc20 + # ChatRoom: + # id:sc21 + # ChatList: + # id:sc22 + ScanScreen: + id:sc23 MDNavigationDrawer: id: nav_drawer