From ea109bc21ee847936b150ac877777ec263472c86 Mon Sep 17 00:00:00 2001 From: coolguy-cell Date: Wed, 3 Jun 2020 15:36:23 +0530 Subject: [PATCH 01/13] fixed CQ for bitmessageqt.dialogs module --- src/bitmessageqt/dialogs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bitmessageqt/dialogs.py b/src/bitmessageqt/dialogs.py index 10701500..e76dd84e 100644 --- a/src/bitmessageqt/dialogs.py +++ b/src/bitmessageqt/dialogs.py @@ -1,8 +1,7 @@ """ -src/bitmessageqt/dialogs.py -=========================== +Custom dialog classes """ - +# pylint: disable=too-few-public-methods from PyQt4 import QtGui import paths From d6953eb4507f9430e478faa1981152d870a6f557 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 9 Jun 2020 17:14:26 +0300 Subject: [PATCH 02/13] New package: bitmessageqt.tests any test cases from it will be added to tests.core test suite if possible, e.g. PyQt is functional. TestSupport - minimal test case for support module to reproduce #1633. --- src/bitmessagemain.py | 5 +++-- src/bitmessageqt/tests/__init__.py | 6 ++++++ src/bitmessageqt/tests/main.py | 30 +++++++++++++++++++++++++++ src/bitmessageqt/tests/support.py | 33 ++++++++++++++++++++++++++++++ src/tests/core.py | 10 +++++++-- 5 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 src/bitmessageqt/tests/__init__.py create mode 100644 src/bitmessageqt/tests/main.py create mode 100644 src/bitmessageqt/tests/support.py diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 2a279aca..9fa9c475 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -363,11 +363,12 @@ class Main(object): 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 # pylint: disable=relative-import from tests import core as test_core test_core_result = test_core.run() diff --git a/src/bitmessageqt/tests/__init__.py b/src/bitmessageqt/tests/__init__.py new file mode 100644 index 00000000..3955a761 --- /dev/null +++ b/src/bitmessageqt/tests/__init__.py @@ -0,0 +1,6 @@ +"""bitmessageqt tests""" + +from main import TestMain +from support import TestSupport + +__all__ = ["TestMain", "TestSupport"] diff --git a/src/bitmessageqt/tests/main.py b/src/bitmessageqt/tests/main.py new file mode 100644 index 00000000..d2a64f83 --- /dev/null +++ b/src/bitmessageqt/tests/main.py @@ -0,0 +1,30 @@ +"""Common definitions for bitmessageqt tests""" + +import unittest + +from PyQt4 import QtCore, QtGui + +import bitmessageqt +from tr import _translate + + +class TestBase(unittest.TestCase): + """Base class for bitmessageqt test case""" + + def setUp(self): + self.app = QtGui.QApplication([]) + self.window = bitmessageqt.MyForm() + + def tearDown(self): + self.app.deleteLater() + + +class TestMain(unittest.TestCase): + """Test case for main window - basic features""" + + def test_translate(self): + """Check the results of _translate() with various args""" + self.assertIsInstance( + _translate("MainWindow", "Test"), + QtCore.QString + ) diff --git a/src/bitmessageqt/tests/support.py b/src/bitmessageqt/tests/support.py new file mode 100644 index 00000000..ba28b73a --- /dev/null +++ b/src/bitmessageqt/tests/support.py @@ -0,0 +1,33 @@ +# from PyQt4 import QtTest + +import sys + +from shared import isAddressInMyAddressBook + +from main import TestBase + + +class TestSupport(TestBase): + """A test case for support module""" + SUPPORT_ADDRESS = 'BM-2cUdgkDDAahwPAU6oD2A7DnjqZz3hgY832' + SUPPORT_SUBJECT = 'Support request' + + def test(self): + """trigger menu action "Contact Support" and check the result""" + ui = self.window.ui + self.assertEqual(ui.lineEditTo.text(), '') + self.assertEqual(ui.lineEditSubject.text(), '') + + ui.actionSupport.trigger() + + self.assertTrue( + isAddressInMyAddressBook(self.SUPPORT_ADDRESS)) + + self.assertEqual( + ui.tabWidget.currentIndex(), ui.tabWidget.indexOf(ui.send)) + self.assertEqual( + ui.lineEditTo.text(), self.SUPPORT_ADDRESS) + self.assertEqual( + ui.lineEditSubject.text(), self.SUPPORT_SUBJECT) + self.assertIn( + sys.version, ui.textEditMessage.toPlainText()) diff --git a/src/tests/core.py b/src/tests/core.py index 9132e668..d33b2117 100644 --- a/src/tests/core.py +++ b/src/tests/core.py @@ -30,7 +30,6 @@ try: except ImportError: stem_version = None - knownnodes_file = os.path.join(state.appdata, 'knownnodes.dat') @@ -245,7 +244,14 @@ class TestCore(unittest.TestCase): def run(): """Starts all tests defined in this module""" - loader = unittest.TestLoader() + loader = unittest.defaultTestLoader loader.sortTestMethodsUsing = None suite = loader.loadTestsFromTestCase(TestCore) + try: + import bitmessageqt.tests + except ImportError: + pass + else: + qt_tests = loader.loadTestsFromModule(bitmessageqt.tests) + suite.addTests(qt_tests) return unittest.TextTestRunner(verbosity=2).run(suite) From 731f75687e48a103ecd73a343a89b40b1821406f Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 9 Jun 2020 17:43:24 +0300 Subject: [PATCH 03/13] Install needed packages and try to run Qt tests --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7141188..274d14c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,14 @@ addons: packages: - build-essential - libcap-dev + - python-qt4 - tor + - xvfb install: - pip install -r requirements.txt - ln -s src pybitmessage # tests environment - python setup.py install script: - python checkdeps.py - - src/bitmessagemain.py -t + - xvfb-run src/bitmessagemain.py -t - python setup.py test From f03bdfb3291b19ca3cc11f1e3024cc0e1ed9ef1f Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 9 Jun 2020 18:33:03 +0300 Subject: [PATCH 04/13] Dirty quickfix for #1633 --- src/bitmessageqt/support.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmessageqt/support.py b/src/bitmessageqt/support.py index 4970beba..ac02e2ca 100644 --- a/src/bitmessageqt/support.py +++ b/src/bitmessageqt/support.py @@ -88,7 +88,7 @@ def createAddressIfNeeded(myapp): if not checkHasNormalAddress(): queues.addressGeneratorQueue.put(( 'createRandomAddress', 4, 1, - SUPPORT_MY_LABEL.toUtf8(), + str(SUPPORT_MY_LABEL.toUtf8()), 1, "", False, defaults.networkDefaultProofOfWorkNonceTrialsPerByte, defaults.networkDefaultPayloadLengthExtraBytes From f8cf931ddc3090d3a372b8ff1142fd7c88540387 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Wed, 10 Jun 2020 21:04:23 +0530 Subject: [PATCH 05/13] fixed CQ for bitmessagekivy.mpybit module part1 --- src/bitmessagekivy/mpybit.py | 112 ++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 47 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index b7b4b0ee..f2d5ef46 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -9,7 +9,7 @@ Bitmessage android(mobile) interface from sys import platform as _sys_platform from os import environ -''' +""" We need to check platform and set environ for KIVY_CAMERA, if requires, before importing kivy. We cannot use sys.platform directly because it returns 'linux' on android devices as well. @@ -17,57 +17,60 @@ We cannot use kivy.util.platform beacuse it imports kivy beforehand and thus set after that doesn't make any sense. So we needed to copy the `_get_platform` function from kivy.utils -''' +""" + def _get_platform(): # On Android sys.platform returns 'linux2', so prefer to check the # existence of environ variables set during Python initialization - kivy_build = environ.get('KIVY_BUILD', '') - if kivy_build in {'android', 'ios'}: + kivy_build = environ.get("KIVY_BUILD", "") + if kivy_build in {"android", "ios"}: return kivy_build - elif 'P4A_BOOTSTRAP' in environ: - return 'android' - elif 'ANDROID_ARGUMENT' in environ: + elif "P4A_BOOTSTRAP" in environ: + return "android" + elif "ANDROID_ARGUMENT" in environ: # We used to use this method to detect android platform, # leaving it here to be backwards compatible with `pydroid3` # and similar tools outside kivy's ecosystem - return 'android' - elif _sys_platform in ('win32', 'cygwin'): - return 'win' - elif _sys_platform == 'darwin': - return 'macosx' - elif _sys_platform.startswith('linux'): - return 'linux' - elif _sys_platform.startswith('freebsd'): - return 'linux' - return 'unknown' + return "android" + elif _sys_platform in ("win32", "cygwin"): + return "win" + elif _sys_platform == "darwin": + return "macosx" + elif _sys_platform.startswith("linux"): + return "linux" + elif _sys_platform.startswith("freebsd"): + return "linux" + return "unknown" -platform= _get_platform() -if platform=='android': +platform = _get_platform() + +if platform == "android": from jnius import autoclass, cast from android.runnable import run_on_ui_thread from android import python_act as PythonActivity - Toast= autoclass('android.widget.Toast') - String = autoclass('java.lang.String') - CharSequence= autoclass('java.lang.CharSequence') - context= PythonActivity.mActivity - + Toast = autoclass("android.widget.Toast") + String = autoclass("java.lang.String") + CharSequence = autoclass("java.lang.CharSequence") + context = PythonActivity.mActivity + @run_on_ui_thread def show_toast(text, length): - t= Toast.makeText(context, text, length) + t = Toast.makeText(context, text, length) t.show() + else: - ''' + """ After tweaking a little bit with opencv camera, it's possible to make camera go on and off as required while the app is still running. - + Other camera provider such as `gi` has some issue upon closing the camera. by setting KIVY_CAMERA environment variable before importing kivy, we are forcing it to use opencv camera provider. - ''' - environ['KIVY_CAMERA']='opencv' + """ + environ["KIVY_CAMERA"] = "opencv" import os import time @@ -117,17 +120,14 @@ from kivymd.uix.list import ( OneLineAvatarIconListItem, OneLineListItem ) + # from kivymd.uix.navigationdrawer import ( # MDNavigationDrawer, # NavigationDrawerHeaderBase # ) from kivymd.uix.selectioncontrol import MDCheckbox, MDSwitch from kivymd.uix.chip import MDChip -from kivy.uix.screenmanager import ( - RiseInTransition, - SlideTransition, - FallOutTransition -) +from kivy.uix.screenmanager import RiseInTransition, SlideTransition, FallOutTransition import queues from semaphores import kivyuisignaler @@ -142,17 +142,31 @@ from kivy.effects.dampedscroll import DampedScrollEffect from kivy_garden.zbarcam import ZBarCam from pyzbar.pyzbar import ZBarSymbol -if platform != 'android': +if platform != "android": from kivy.config import Config - Config.set('input', 'mouse', 'mouse,multitouch_on_demand') + + Config.set("input", "mouse", "mouse, multitouch_on_demand") # pylint: disable=too-few-public-methods,too-many-arguments,attribute-defined-outside-init KVFILES = [ - 'settings', 'popup', 'allmails', 'draft', - 'maildetail', 'common_widgets', 'addressbook', - 'myaddress', 'composer', 'payment', 'sent', - 'network', 'login', 'credits', 'trash', 'inbox', - 'chat_room', 'chat_list' + "settings", + "popup", + "allmails", + "draft", + "maildetail", + "common_widgets", + "addressbook", + "myaddress", + "composer", + "payment", + "sent", + "network", + "login", + "credits", + "trash", + "inbox", + "chat_room", + "chat_list" ] @@ -160,6 +174,7 @@ def toast(text): """Method will display the toast message""" # pylint: disable=redefined-outer-name from kivymd.toast.kivytoast import toast + toast(text) return @@ -175,9 +190,11 @@ def ShowTimeHistoy(act_time): crnt_date = datetime.now() duration = crnt_date - action_time display_data = ( - action_time.strftime('%d/%m/%Y') - if duration.days >= 365 else action_time.strftime('%I:%M %p').lstrip('0') - if duration.days == 0 and crnt_date.strftime('%d/%m/%Y') == action_time.strftime('%d/%m/%Y') + action_time.strftime("%d/%m/%Y") + if duration.days >= 365 + else action_time.strftime("%I:%M %p").lstrip("0") + if duration.days == 0 + and crnt_date.strftime("%d/%m/%Y") == action_time.strftime("%d/%m/%Y") else action_time.strftime("%d %b") ) return display_data @@ -187,9 +204,10 @@ def AddTimeWidget(time): # pylint: disable=redefined-outer-name """This method is used to create TimeWidget""" action_time = TimeTagRightSampleWidget( text=str(ShowTimeHistoy(time)), - font_style='Caption', - size=[120, 140] if platform == 'android' else [64, 80]) - action_time.font_size = '11sp' + font_style="Caption", + size=[120, 140] if platform == "android" else [64, 80], + ) + action_time.font_size = "11sp" return action_time From 539def1e6b058bd583d6186456d5e83261d56043 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Mon, 15 Jun 2020 15:00:31 +0530 Subject: [PATCH 06/13] fixed CQ for bitmessagekivy.mpybit module part2 --- src/bitmessagekivy/mpybit.py | 58 ++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index f2d5ef46..f06dc5de 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -215,10 +215,13 @@ def chipTag(text): """This method is used for showing chip tag""" obj = MDChip() # obj.size_hint = (None, None) - obj.size_hint = (.16 if platform == 'android' else .07, None) + obj.size_hint = (0.16 if platform == "android" else 0.07, None) obj.label = text - obj.icon = '' - obj.pos_hint = {'center_x': .91 if platform == 'android' else .94, 'center_y': .3} + obj.icon = "" + obj.pos_hint = { + "center_x": 0.91 if platform == "android" else 0.94, + "center_y": 0.3 + } obj.height = dp(18) obj.radius = 8 return obj @@ -239,7 +242,7 @@ class Inbox(Screen): @staticmethod def set_defaultAddress(): """This method set's default address""" - if state.association == '': + if state.association == "": if BMConfigParser().addresses(): state.association = BMConfigParser().addresses()[0] @@ -253,42 +256,51 @@ class Inbox(Screen): self.account = state.association if state.searcing_text: self.children[2].children[0].children[0].scroll_y = 1.0 - where = ['subject', 'message'] + where = ["subject", "message"] what = state.searcing_text - xAddress = 'toaddress' + xAddress = "toaddress" data = [] - self.ids.identi_tag.children[0].text = '' + self.ids.identi_tag.children[0].text = "" self.inboxDataQuery(xAddress, where, what) - self.ids.identi_tag.children[0].text = '' + self.ids.identi_tag.children[0].text = "" if self.queryreturn: - self.ids.identi_tag.children[0].text = 'Inbox' + self.ids.identi_tag.children[0].text = "Inbox" state.kivyapp.get_inbox_count() self.set_inboxCount(state.inbox_count) for mail in self.queryreturn: # third_text = mail[3].replace('\n', ' ') body = mail[3].decode() if isinstance(mail[3], bytes) else mail[3] subject = mail[5].decode() if isinstance(mail[5], bytes) else mail[5] - data.append({ - 'text': mail[4].strip(), - 'secondary_text': (subject[:50] + '........' if len( - subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace( - '\t', '').replace(' ', ''), - 'msgid': mail[1], 'received': mail[6]}) + data.append( + { + "text": mail[4].strip(), + "secondary_text": ( + subject[:50] + "........" + if len(subject) >= 50 + else (subject + "," + body)[0:50] + "........" + ) + .replace("\t", "") + .replace(" ", ""), + "msgid": mail[1], + "received": mail[6] + } + ) self.has_refreshed = True self.set_mdList(data) - self.children[2].children[0].children[0].bind( - scroll_y=self.check_scroll_y) + self.children[2].children[0].children[0].bind(scroll_y=self.check_scroll_y) else: - self.set_inboxCount('0') + self.set_inboxCount("0") content = MDLabel( - font_style='Caption', - theme_text_color='Primary', - text="No message found!" if state.searcing_text + font_style="Caption", + theme_text_color="Primary", + text="No message found!" + if state.searcing_text else "yet no message for this account!!!!!!!!!!!!!", - halign='center', + halign="center", size_hint_y=None, - valign='top') + valign="top" + ) self.ids.ml.add_widget(content) def set_inboxCount(self, msgCnt): # pylint: disable=no-self-use From 62703ab95c823cf1cc1c7559cf958bea1b9863eb Mon Sep 17 00:00:00 2001 From: surbhicis Date: Tue, 16 Jun 2020 19:54:10 +0530 Subject: [PATCH 07/13] fixed CQ for bitmessagekivy.mpybit module part3 --- src/bitmessagekivy/mpybit.py | 40 +++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index f06dc5de..25dca2df 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -311,33 +311,39 @@ class Inbox(Screen): def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20): """This method is used for retrieving inbox data""" self.queryreturn = kivy_helper_search.search_sql( - xAddress, self.account, "inbox", where, what, - False, start_indx, end_indx) + xAddress, self.account, "inbox", where, what, False, start_indx, end_indx + ) def set_mdList(self, data): """This method is used to create the mdList""" total_message = len(self.ids.ml.children) for item in data: meny = TwoLineAvatarIconListItem( - text=item['text'], secondary_text=item['secondary_text'], - theme_text_color='Custom', - text_color=NavigateApp().theme_cls.primary_color) + text=item["text"], + secondary_text=item["secondary_text"], + theme_text_color="Custom", + text_color=NavigateApp().theme_cls.primary_color + ) meny._txt_right_pad = dp(70) - meny.add_widget(AvatarSampleWidget( - source='./images/text_images/{}.png'.format( - avatarImageFirstLetter(item['secondary_text'].strip())))) - meny.bind(on_press=partial(self.inbox_detail, item['msgid'])) - meny.add_widget(AddTimeWidget(item['received'])) - carousel = Carousel(direction='right') + meny.add_widget( + AvatarSampleWidget( + source="./images/text_images/{}.png".format( + avatarImageFirstLetter(item["secondary_text"].strip()) + ) + ) + ) + meny.bind(on_press=partial(self.inbox_detail, item["msgid"])) + meny.add_widget(AddTimeWidget(item["received"])) + carousel = Carousel(direction="right") carousel.height = meny.height carousel.size_hint_y = None carousel.ignore_perpendicular_swipes = True carousel.data_index = 0 carousel.min_move = 0.2 - del_btn = Button(text='Delete') - del_btn.background_normal = '' + del_btn = Button(text="Delete") + del_btn.background_normal = "" del_btn.background_color = (1, 0, 0, 1) - del_btn.bind(on_press=partial(self.delete, item['msgid'])) + del_btn.bind(on_press=partial(self.delete, item["msgid"])) carousel.add_widget(del_btn) carousel.add_widget(meny) # ach_btn = Button(text='Achieve') @@ -351,8 +357,10 @@ class Inbox(Screen): def check_scroll_y(self, instance, somethingelse): """Loads data on scroll""" - if self.children[2].children[0].children[ - 0].scroll_y <= -0.0 and self.has_refreshed: + if ( + self.children[2].children[0].children[0].scroll_y <= -0.0 + and self.has_refreshed + ): self.children[2].children[0].children[0].scroll_y = 0.06 total_message = len(self.ids.ml.children) self.update_inbox_screen_on_scroll(total_message) From 3a96823129de3881161ca90e3cb0619e95331640 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Tue, 16 Jun 2020 20:13:59 +0530 Subject: [PATCH 08/13] fixed CQ for bitmessagekivy.mpybit module part4 --- src/bitmessagekivy/mpybit.py | 64 ++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 25dca2df..b332652b 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -371,24 +371,27 @@ class Inbox(Screen): """This method is used to load more data on scroll down""" data = [] if state.searcing_text: - where = ['subject', 'message'] + where = ["subject", "message"] what = state.searcing_text - self.inboxDataQuery('toaddress', where, what, total_message, 5) + self.inboxDataQuery("toaddress", where, what, total_message, 5) for mail in self.queryreturn: # third_text = mail[3].replace('\n', ' ') subject = mail[3].decode() if isinstance(mail[3], bytes) else mail[3] body = mail[5].decode() if isinstance(mail[5], bytes) else mail[5] - data.append({ - 'text': mail[4].strip(), - 'secondary_text': body[:50] + '........' if len( - body) >= 50 else (body + ',' + subject.replace( - '\n', ''))[0:50] + '........', - 'msgid': mail[1]}) + data.append( + { + "text": mail[4].strip(), + "secondary_text": body[:50] + "........" + if len(body) >= 50 + else (body + "," + subject.replace("\n", ""))[0:50] + "........", + "msgid": mail[1] + } + ) self.set_mdList(data) def inbox_detail(self, msg_id, *args): """Load inbox page details""" - state.detailPageType = 'inbox' + state.detailPageType = "inbox" state.mail_id = msg_id if self.manager: src_mng_obj = self.manager @@ -396,34 +399,34 @@ class Inbox(Screen): src_mng_obj = self.parent.parent src_mng_obj.screens[13].clear_widgets() src_mng_obj.screens[13].add_widget(MailDetail()) - src_mng_obj.current = 'mailDetail' + src_mng_obj.current = "mailDetail" def delete(self, data_index, instance, *args): """Delete inbox mail from inbox listing""" - sqlExecute( - "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index) + sqlExecute("UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index) msg_count_objs = self.parent.parent.ids.content_drawer.ids if int(state.inbox_count) > 0: - msg_count_objs.inbox_cnt.children[0].children[0].text = showLimitedCnt(int(state.inbox_count) - 1) - msg_count_objs.trash_cnt.children[0].children[0].text = showLimitedCnt(int(state.trash_count) + 1) - msg_count_objs.allmail_cnt.children[0].children[0].text = showLimitedCnt(int(state.all_count) - 1) - state.inbox_count = str( - int(state.inbox_count) - 1) - state.trash_count = str( - int(state.trash_count) + 1) - state.all_count = str( - int(state.all_count) - 1) + msg_count_objs.inbox_cnt.children[0].children[0].text = showLimitedCnt( + int(state.inbox_count) - 1 + ) + msg_count_objs.trash_cnt.children[0].children[0].text = showLimitedCnt( + int(state.trash_count) + 1 + ) + msg_count_objs.allmail_cnt.children[0].children[0].text = showLimitedCnt( + int(state.all_count) - 1 + ) + state.inbox_count = str(int(state.inbox_count) - 1) + state.trash_count = str(int(state.trash_count) + 1) + state.all_count = str(int(state.all_count) - 1) if int(state.inbox_count) <= 0: - self.ids.identi_tag.children[0].text = '' - self.ids.ml.remove_widget( - instance.parent.parent) - toast('Deleted') + self.ids.identi_tag.children[0].text = "" + self.ids.ml.remove_widget(instance.parent.parent) + toast("Deleted") self.update_trash() def archive(self, data_index, instance, *args): """Archive inbox mail from inbox listing""" - sqlExecute( - "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index) + sqlExecute("UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index) self.ids.ml.remove_widget(instance.parent.parent) self.update_trash() @@ -439,20 +442,23 @@ class Inbox(Screen): def refresh_callback(self, *args): """Method updates the state of application, While the spinner remains on the screen""" + def refresh_callback(interval): """Method used for loading the inbox screen data""" - state.searcing_text = '' - self.children[2].children[1].ids.search_field.text = '' + state.searcing_text = "" + self.children[2].children[1].ids.search_field.text = "" self.ids.ml.clear_widgets() self.loadMessagelist(state.association) self.has_refreshed = True self.ids.refresh_layout.refresh_done() self.tick = 0 + Clock.schedule_once(refresh_callback, 1) class CustomTwoLineAvatarIconListItem(TwoLineAvatarIconListItem): """Custom Two Line Avatar Icon List""" + pass From 277549cff1ccd5b2f6a9bcea62e374f5e42f9fb9 Mon Sep 17 00:00:00 2001 From: coolguy-cell Date: Tue, 9 Jun 2020 15:53:18 +0530 Subject: [PATCH 09/13] fixed CQ for bitmessageqt.sound module --- src/bitmessageqt/sound.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bitmessageqt/sound.py b/src/bitmessageqt/sound.py index 9c86a9a4..33b4c500 100644 --- a/src/bitmessageqt/sound.py +++ b/src/bitmessageqt/sound.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""Sound Module""" # sound type constants SOUND_NONE = 0 @@ -12,10 +13,12 @@ SOUND_CONNECTION_GREEN = 5 # returns true if the given sound category is a connection sound # rather than a received message sound def is_connection_sound(category): + """Check if sound type is related to connectivity""" return category in ( SOUND_CONNECTED, SOUND_DISCONNECTED, SOUND_CONNECTION_GREEN ) + extensions = ('wav', 'mp3', 'oga') From 217a5c0c5bbbb909bf88ebfba830e86d5180c255 Mon Sep 17 00:00:00 2001 From: coolguy-cell Date: Tue, 9 Jun 2020 15:47:45 +0530 Subject: [PATCH 10/13] fixed CQ for bitmessageqt.settings module --- src/bitmessageqt/settings.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index 8e4bf198..80295837 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -4,6 +4,7 @@ This module setting file is for settings import ConfigParser import os import sys +import tempfile from PyQt4 import QtCore, QtGui @@ -15,7 +16,6 @@ import openclpow import paths import queues import state -import tempfile import widgets from bmconfigparser import BMConfigParser from helper_sql import sqlExecute, sqlStoredProcedure @@ -30,7 +30,7 @@ def getSOCKSProxyType(config): result = ConfigParser.SafeConfigParser.get( config, 'bitmessagesettings', 'socksproxytype') except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): - return + return None else: if result.lower() in ('', 'none', 'false'): result = None @@ -429,15 +429,14 @@ class SettingsDialog(QtGui.QDialog): acceptableDifficultyChanged = False if ( - float(self.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 - or float(self.lineEditMaxAcceptableTotalDifficulty.text()) == 0 + float(self.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 + or float(self.lineEditMaxAcceptableTotalDifficulty.text()) == 0 ): if self.config.get( - 'bitmessagesettings', 'maxacceptablenoncetrialsperbyte' + 'bitmessagesettings', 'maxacceptablenoncetrialsperbyte' ) != str(int( float(self.lineEditMaxAcceptableTotalDifficulty.text()) - * defaults.networkDefaultProofOfWorkNonceTrialsPerByte) - ): + * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)): # the user changed the max acceptable total difficulty acceptableDifficultyChanged = True self.config.set( @@ -447,15 +446,14 @@ class SettingsDialog(QtGui.QDialog): * defaults.networkDefaultProofOfWorkNonceTrialsPerByte)) ) if ( - float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 - or float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0 + float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 + or float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0 ): if self.config.get( - 'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes' + 'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes' ) != str(int( float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) - * defaults.networkDefaultPayloadLengthExtraBytes) - ): + * defaults.networkDefaultPayloadLengthExtraBytes)): # the user changed the max acceptable small message difficulty acceptableDifficultyChanged = True self.config.set( @@ -540,8 +538,8 @@ class SettingsDialog(QtGui.QDialog): self.parent.updateStartOnLogon() if ( - state.appdata != paths.lookupExeFolder() - and self.checkBoxPortableMode.isChecked() + state.appdata != paths.lookupExeFolder() + and self.checkBoxPortableMode.isChecked() ): # If we are NOT using portable mode now but the user selected # that we should... @@ -563,8 +561,8 @@ class SettingsDialog(QtGui.QDialog): pass if ( - state.appdata == paths.lookupExeFolder() - and not self.checkBoxPortableMode.isChecked() + state.appdata == paths.lookupExeFolder() + and not self.checkBoxPortableMode.isChecked() ): # If we ARE using portable mode now but the user selected # that we shouldn't... From 65aa9ae39703ec2c7041ef5f82b9bcd6f61aa815 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Thu, 9 Jul 2020 16:58:54 +0530 Subject: [PATCH 11/13] fixed CQ for bitmessagekivy.mpybit module part5 --- src/bitmessagekivy/mpybit.py | 165 +++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 76 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index b332652b..b5bc4bf9 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -553,8 +553,9 @@ class MyAddress(Screen): my_addresses = len(self.ids.ml.children) if my_addresses != len(self.addresses_list): self.update_addressBook_on_scroll(my_addresses) - self.has_refreshed = True if my_addresses != len( - self.addresses_list) else False + self.has_refreshed = ( + True if my_addresses != len(self.addresses_list) else False + ) else: pass @@ -565,16 +566,19 @@ class MyAddress(Screen): # @staticmethod def myadd_detail(self, fromaddress, label, *args): """Load myaddresses details""" - if BMConfigParser().get(fromaddress, 'enabled') == 'true': + if BMConfigParser().get(fromaddress, "enabled") == "true": p = MyaddDetailPopup() p.open() p.set_address(fromaddress, label) else: - width = .8 if platform == 'android' else .55 + width = 0.8 if platform == "android" else 0.55 msg_dialog = MDDialog( - text='Address is not currently active. Please click on Toggle button to active it.', - title='', size_hint=(width, .25), text_button_ok='Ok', - events_callback=self.callback_for_menu_items) + text="Address is not currently active. Please click on Toggle button to active it.", + title="", + size_hint=(width, 0.25), + text_button_ok="Ok", + events_callback=self.callback_for_menu_items + ) msg_dialog.open() @staticmethod @@ -726,8 +730,9 @@ class AddressBook(Screen): exist_addresses = len(self.ids.ml.children) if exist_addresses != len(self.queryreturn): self.update_addressBook_on_scroll(exist_addresses) - self.has_refreshed = True if exist_addresses != len( - self.queryreturn) else False + self.has_refreshed = ( + True if exist_addresses != len(self.queryreturn) else False + ) else: pass @@ -754,14 +759,15 @@ class AddressBook(Screen): self.ids.ml.remove_widget(instance.parent.parent) # if len(self.ids.ml.children) == 0: if self.ids.ml.children is not None: - self.ids.identi_tag.children[0].text = '' - sqlExecute( - "DELETE FROM addressbook WHERE address = '{}';".format(address)) + self.ids.identi_tag.children[0].text = "" + sqlExecute("DELETE FROM addressbook WHERE address = '{}';".format(address)) class SelectableRecycleBoxLayout( - FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout): + FocusBehavior, LayoutSelectionBehavior, RecycleBoxLayout +): """Adds selection and focus behaviour to the view""" + # pylint: disable = duplicate-bases pass @@ -777,8 +783,7 @@ class SelectableLabel(RecycleDataViewBehavior, Label): def refresh_view_attrs(self, rv, index, data): """Catch and handle the view changes""" self.index = index - return super(SelectableLabel, self).refresh_view_attrs( - rv, index, data) + return super(SelectableLabel, self).refresh_view_attrs(rv, index, data) def on_touch_down(self, touch): # pylint: disable=inconsistent-return-statements """Add selection on touch down""" @@ -793,7 +798,8 @@ class SelectableLabel(RecycleDataViewBehavior, Label): if is_selected: print("selection changed to {0}".format(rv.data[index])) rv.parent.txt_input.text = rv.parent.txt_input.text.replace( - rv.parent.txt_input.text, rv.data[index]['text']) + rv.parent.txt_input.text, rv.data[index]["text"] + ) class RV(RecycleView): @@ -806,6 +812,7 @@ class RV(RecycleView): class DropDownWidget(BoxLayout): """Adding Dropdown Widget""" + # pylint: disable=too-many-statements txt_input = ObjectProperty() @@ -821,13 +828,13 @@ class DropDownWidget(BoxLayout): print("message: ", self.ids.body.text) sendMessageToPeople = True if sendMessageToPeople: - if toAddress != '' and subject and message: - status, addressVersionNumber, streamNumber, ripe = ( - decodeAddress(toAddress)) - if status == 'success': + if toAddress != "" and subject and message: + status, addressVersionNumber, streamNumber, ripe = decodeAddress( + toAddress + ) + if status == "success": navApp.root.ids.sc3.children[0].active = True - if state.detailPageType == 'draft' \ - and state.send_draft_mail: + if state.detailPageType == "draft" and state.send_draft_mail: sqlExecute( "UPDATE sent SET toaddress = ?" ", fromaddress = ? , subject = ?" @@ -912,15 +919,18 @@ class DropDownWidget(BoxLayout): state.kivyapp.root.ids.sc3.children[0].active = False state.in_sent_method = True state.kivyapp.back_press() - toast('sent') + toast("sent") def address_error_message(self, msg): """Generates error message""" - width = .8 if platform == 'android' else .55 + width = 0.8 if platform == "android" else 0.55 msg_dialog = MDDialog( text=msg, - title='', size_hint=(width, .25), text_button_ok='Ok', - events_callback=self.callback_for_menu_items) + title="", + size_hint=(width, 0.25), + text_button_ok="Ok", + events_callback=self.callback_for_menu_items + ) msg_dialog.open() @staticmethod @@ -930,11 +940,11 @@ class DropDownWidget(BoxLayout): def reset_composer(self): """Method will reset composer""" - self.ids.ti.text = '' - self.ids.btn.text = 'Select' - self.ids.txt_input.text = '' - self.ids.subject.text = '' - self.ids.body.text = '' + self.ids.ti.text = "" + self.ids.btn.text = "Select" + self.ids.txt_input.text = "" + self.ids.subject.text = "" + self.ids.body.text = "" toast("Reset message") def auto_fill_fromaddr(self): @@ -946,57 +956,60 @@ class DropDownWidget(BoxLayout): """This method is used for scanning Qr code""" pass + class ScanScreen(Screen): - def on_pre_enter(self): - ''' + def on_pre_enter(self): + """ on_pre_enter works little better on android It affects screen transition on linux - ''' - if not self.children: - tmp= Builder.load_file(os.path.join(os.path.dirname(__file__), "kv/{}.kv").format('scanner')) - self.add_widget(tmp) - if platform=='android': - Clock.schedule_once(self.start_camera, 0) - - def on_enter(self): - ''' + """ + if not self.children: + tmp = Builder.load_file( + os.path.join(os.path.dirname(__file__), "kv/{}.kv").format("scanner") + ) + self.add_widget(tmp) + if platform == "android": + Clock.schedule_once(self.start_camera, 0) + + def on_enter(self): + """ on_enter works better on linux It creates a black screen on android until camera gets loaded - ''' - #print(self.children) - if platform!='android': - #pass - Clock.schedule_once(self.start_camera, 0) - - def on_leave(self): - #pass + """ + # print(self.children) + if platform != "android": + # pass + Clock.schedule_once(self.start_camera, 0) + + def on_leave(self): + # pass + + Clock.schedule_once(self.stop_camera, 0) + + def start_camera(self, *args): + self.xcam = self.children[0].ids.zbarcam.ids.xcamera + # pass + # self.xxx= self.children[0].ids.zbarcam.ids.xcamera + # print(self.cam._device.isOpened()) + if platform == "android": + self.xcam.play = True + + else: + Clock.schedule_once(self.open_cam, 0) + + def stop_camera(self, *args): + # print(self.children[0].ids.zbarcam.ids.xcamera.play) + self.xcam.play = False + # self.xcam._camera.stop() + # self.children[0].ids.zbarcam.stop() + if platform != "android": + self.xcam._camera._device.release() + + def open_cam(self, *args): + if not self.xcam._camera._device.isOpened(): + self.xcam._camera._device.open(self.xcam._camera._index) + self.xcam.play = True - Clock.schedule_once(self.stop_camera, 0) - - def start_camera(self, *args): - self.xcam= self.children[0].ids.zbarcam.ids.xcamera - #pass - #self.xxx= self.children[0].ids.zbarcam.ids.xcamera - #print(self.cam._device.isOpened()) - if platform=='android': - self.xcam.play= True - - else: - Clock.schedule_once(self.open_cam, 0) - - - def stop_camera(self, *args): - #print(self.children[0].ids.zbarcam.ids.xcamera.play) - self.xcam.play= False - #self.xcam._camera.stop() - #self.children[0].ids.zbarcam.stop() - if platform != 'android': - self.xcam._camera._device.release() - - def open_cam(self, *args): - if not self.xcam._camera._device.isOpened(): - self.xcam._camera._device.open(self.xcam._camera._index) - self.xcam.play= True class MyTextInput(TextInput): """Takes the text input in the field""" From 57dcec9b2a2727715e153509c2a84b553e1e7470 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Thu, 9 Jul 2020 17:32:19 +0530 Subject: [PATCH 12/13] fixed CQ for bitmessagekivy.mpybit module part6 --- src/bitmessagekivy/mpybit.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index b5bc4bf9..7d643a77 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -1080,24 +1080,31 @@ class Payment(Screen): payloadLengthExtraBytes)) toast('hidden payment address Creating for buying subscription....') + class Category(BoxLayout, RectangularElevationBehavior): - elevation_normal= .01 + elevation_normal = .01 + class ProductLayout(BoxLayout, RectangularElevationBehavior): - elevation_normal= .01 + elevation_normal = .01 + class PaymentMethodLayout(BoxLayout): pass + class ListItemWithLabel(OneLineAvatarIconListItem): pass + class RightLabel(IRightBodyTouch, MDLabel): pass + class HomeScreen(Screen): pass + class Credits(Screen): """Credits Method""" @@ -2281,23 +2288,24 @@ class NavigateApp(MDApp): # self.root.ids.sc7.ids.add_random_bx.clear_widgets() def open_payment_layout(self, sku): - pml= PaymentMethodLayout() - self.product_id= sku - self.custom_sheet= MDCustomBottomSheet(screen= pml) + pml = PaymentMethodLayout() + self.product_id = sku + self.custom_sheet = MDCustomBottomSheet(screen=pml) self.custom_sheet.open() def initiate_purchase(self, method_name): - #self.custom_sheet.dismiss() + # self.custom_sheet.dismiss() print("Purchasing {} through {}".format(self.product_id, method_name)) def _after_scan(self, text): - if platform=='android': - text= cast(CharSequence, String(text)) - show_toast(text,Toast.LENGTH_SHORT) + if platform == 'android': + text = cast(CharSequence, String(text)) + show_toast(text, Toast.LENGTH_SHORT) else: self.root.ids.sc3.children[1].ids.txt_input.text = text self.root.ids.scr_mngr.current = 'create' + class GrashofPopup(Popup): """Moule for save contacts and error messages""" @@ -2412,9 +2420,11 @@ class GrashofPopup(Popup): text = "Some data encoded in the address is malformed." return text + class InfoLayout(BoxLayout, RectangularElevationBehavior): pass + class AvatarSampleWidget(ILeftBody, Image): """Avatar Sample Widget""" From 71a8fb8f46fda6734a70cb6cb3814fcc8cdba0d8 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Thu, 9 Jul 2020 17:48:07 +0530 Subject: [PATCH 13/13] fixed CQ for bitmessagekivy.mpybit module part7 --- src/bitmessagekivy/mpybit.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 7d643a77..f96423bc 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -193,8 +193,7 @@ def ShowTimeHistoy(act_time): action_time.strftime("%d/%m/%Y") if duration.days >= 365 else action_time.strftime("%I:%M %p").lstrip("0") - if duration.days == 0 - and crnt_date.strftime("%d/%m/%Y") == action_time.strftime("%d/%m/%Y") + if duration.days == 0 and crnt_date.strftime("%d/%m/%Y") == action_time.strftime("%d/%m/%Y") else action_time.strftime("%d %b") ) return display_data @@ -358,8 +357,7 @@ class Inbox(Screen): def check_scroll_y(self, instance, somethingelse): """Loads data on scroll""" if ( - self.children[2].children[0].children[0].scroll_y <= -0.0 - and self.has_refreshed + self.children[2].children[0].children[0].scroll_y <= -0.0 and self.has_refreshed ): self.children[2].children[0].children[0].scroll_y = 0.06 total_message = len(self.ids.ml.children) @@ -2589,8 +2587,7 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes # sender_name = BMConfigParser().get(data[0][1], 'label') sender_name = data[0][1] composer_obj.body.text = ( - '\n\n --------------On ' + time_tag + ', ' - + sender_name + ' wrote:--------------\n' + data[0][3]) + '\n\n --------------On ' + time_tag + ', ' + sender_name + ' wrote:--------------\n' + data[0][3]) composer_obj.body.focus = True composer_obj.body.cursor = (0, 0) state.kivyapp.root.ids.sc3.children[1].ids.rv.data = ''