diff --git a/src/bitmessagekivy/identiconGeneration.py b/src/bitmessagekivy/identiconGeneration.py index a5dcf3d0..14a31403 100644 --- a/src/bitmessagekivy/identiconGeneration.py +++ b/src/bitmessagekivy/identiconGeneration.py @@ -46,13 +46,13 @@ def generate_hash(string): # make input case insensitive string = str.lower(string) hash_object = hashlib.md5(str.encode(string)) - print hash_object.hexdigest() + print(hash_object.hexdigest()) # returned object is a hex string return hash_object.hexdigest() except IndexError: - print "Error: Please enter a string as an argument." + print("Error: Please enter a string as an argument.") def random_color(hash_string): diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index be6f76e9..18f1ac6a 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -1,43 +1,38 @@ -#:import Toolbar kivymd.toolbar.Toolbar +#:import MDToolbar kivymd.uix.toolbar.MDToolbar #:import ThemeManager kivymd.theming.ThemeManager -#:import MDNavigationDrawer kivymd.navigationdrawer.MDNavigationDrawer -#:import NavigationLayout kivymd.navigationdrawer.NavigationLayout -#:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider -#:import NavigationDrawerToolbar kivymd.navigationdrawer.NavigationDrawerToolbar -#:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader -#:import MDCheckbox kivymd.selectioncontrols.MDCheckbox -#:import MDSwitch kivymd.selectioncontrols.MDSwitch -#:import MDList kivymd.list.MDList -#:import OneLineListItem kivymd.list.OneLineListItem -#:import TwoLineListItem kivymd.list.TwoLineListItem -#:import ThreeLineListItem kivymd.list.ThreeLineListItem -#:import OneLineAvatarListItem kivymd.list.OneLineAvatarListItem -#:import OneLineIconListItem kivymd.list.OneLineIconListItem -#:import OneLineAvatarIconListItem kivymd.list.OneLineAvatarIconListItem -#:import MDTextField kivymd.textfields.MDTextField -#:import MDSpinner kivymd.spinner.MDSpinner -#:import MDCard kivymd.card.MDCard -#:import MDSeparator kivymd.card.MDSeparator -#:import MDDropdownMenu kivymd.menu.MDDropdownMenu +#:import MDNavigationDrawer kivymd.uix.navigationdrawer.MDNavigationDrawer +#:import NavigationLayout kivymd.uix.navigationdrawer.NavigationLayout +#:import NavigationDrawerDivider kivymd.uix.navigationdrawer.NavigationDrawerDivider +#:import NavigationDrawerToolbar kivymd.uix.navigationdrawer.NavigationDrawerToolbar +#:import NavigationDrawerSubheader kivymd.uix.navigationdrawer.NavigationDrawerSubheader +#:import MDCheckbox kivymd.uix.selectioncontrol.MDCheckbox +#:import MDSwitch kivymd.uix.selectioncontrol.MDSwitch +#:import MDList kivymd.uix.list.MDList +#:import OneLineListItem kivymd.uix.list.OneLineListItem +#:import TwoLineListItem kivymd.uix.list.TwoLineListItem +#:import ThreeLineListItem kivymd.uix.list.ThreeLineListItem +#:import OneLineAvatarListItem kivymd.uix.list.OneLineAvatarListItem +#:import OneLineIconListItem kivymd.uix.list.OneLineIconListItem +#:import OneLineAvatarIconListItem kivymd.uix.list.OneLineAvatarIconListItem +#:import MDTextField kivymd.uix.textfield.MDTextField +#:import MDSpinner kivymd.uix.spinner.MDSpinner +#:import MDCard kivymd.uix.card.MDCard +#:import MDSeparator kivymd.uix.card.MDSeparator +#:import MDDropdownMenu kivymd.uix.menu.MDDropdownMenu #:import get_color_from_hex kivy.utils.get_color_from_hex #:import colors kivymd.color_definitions.colors -#:import SmartTile kivymd.grid.SmartTile -#:import MDSlider kivymd.slider.MDSlider -#:import MDTabbedPanel kivymd.tabs.MDTabbedPanel -#:import MDTab kivymd.tabs.MDTab -#:import MDProgressBar kivymd.progressbar.MDProgressBar -#:import MDAccordion kivymd.accordion.MDAccordion -#:import MDAccordionItem kivymd.accordion.MDAccordionItem -#:import MDAccordionSubItem kivymd.accordion.MDAccordionSubItem -#:import MDThemePicker kivymd.theme_picker.MDThemePicker -#:import MDBottomNavigation kivymd.tabs.MDBottomNavigation -#:import MDBottomNavigationItem kivymd.tabs.MDBottomNavigationItem -#:import MDFloatingActionButton kivymd.button.MDFloatingActionButton +#:import MDSlider kivymd.uix.slider.MDSlider +#:import MDTabs kivymd.uix.tab.MDTabs +#:import MDProgressBar kivymd.uix.progressbar.MDProgressBar +#:import MDAccordion kivymd.uix.accordion.MDAccordion +#:import MDAccordionItem kivymd.uix.accordion.MDAccordionItem +#:import MDAccordionSubItem kivymd.uix.accordion.MDAccordionSubItem +#:import MDFloatingActionButton kivymd.uix.button.MDFloatingActionButton #:import Factory kivy.factory.Factory -#:import MDTextButton kivymd.button.MDTextButton +#:import MDTextButton kivymd.uix.button.MDTextButton #:import FadeTransition kivy.uix.screenmanager.FadeTransition -#:import MDScrollViewRefreshLayout kivymd.refreshlayout.MDScrollViewRefreshLayout +#:import MDScrollViewRefreshLayout kivymd.uix.refreshlayout.MDScrollViewRefreshLayout #:set color_button (0.784, 0.443, 0.216, 1) # brown #:set color_button_pressed (0.659, 0.522, 0.431, 1) # darker brown @@ -176,7 +171,7 @@ NavigationLayout: BoxLayout: id: box_layout orientation: 'vertical' - Toolbar: + MDToolbar: id: toolbar title: app.current_address_label() opacity: 1 if app.addressexist() else 0 @@ -342,7 +337,7 @@ NavigationLayout: size_hint: .6, .35 height: dp(40) MDLabel: - font_style: 'Title' + font_style: 'H4' text: root.available_credits font_size: '13sp' color: (1,1,1,1) @@ -423,7 +418,7 @@ NavigationLayout: height: dp(40) on_press: root.reset_composer() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'reset' font_size: '13sp' color: (1,1,1,1) @@ -521,7 +516,7 @@ NavigationLayout: height: dp(40) on_press: app.root.ids.scr_mngr.current = 'random' MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'proceed' font_size: '13sp' color: (1,1,1,1) @@ -566,7 +561,7 @@ NavigationLayout: on_release: root.generateaddress(app) opposite_colors: True MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'next' font_size: '13sp' color: (1,1,1,1) @@ -594,7 +589,7 @@ NavigationLayout: size_hint: .6, .55 height: dp(40) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Server' font_size: '13sp' color: (1,1,1,1) @@ -607,7 +602,7 @@ NavigationLayout: size_hint: .6, .55 height: dp(40) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Import or export data' font_size: '13sp' color: (1,1,1,1) @@ -620,7 +615,7 @@ NavigationLayout: size_hint: .6, .55 height: dp(40) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Restart background service' font_size: '13sp' color: (1,1,1,1) @@ -698,20 +693,20 @@ NavigationLayout: size: self.size MDLabel: size_hint_y: None - font_style: 'Headline' + font_style: 'Subtitle1' theme_text_color: 'Primary' text: 'Platinum' halign: 'center' color: 1,1,1,1 MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: 'We provide subscriptions for proof of work calculation for first month. ' halign: 'center' color: 1,1,1,1 MDLabel: id: free_pak - font_style: 'Headline' + font_style: 'Subtitle1' theme_text_color: 'Primary' text: '€ 50.0' halign: 'center' @@ -727,7 +722,7 @@ NavigationLayout: height: dp(40) on_press: root.get_available_credits(self) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Get Free Credits' font_size: '13sp' color: (0,0,0,1) @@ -744,19 +739,19 @@ NavigationLayout: size: self.size MDLabel: size_hint_y: None - font_style: 'Headline' + font_style: 'Subtitle1' theme_text_color: 'Primary' text: 'Silver' halign: 'center' color: 1,1,1,1 MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: 'We provide for proof of work calculation for six month. ' halign: 'center' color: 1,1,1,1 MDLabel: - font_style: 'Headline' + font_style: 'Subtitle1' theme_text_color: 'Primary' text: '€ 100.0' halign: 'center' @@ -771,7 +766,7 @@ NavigationLayout: size_hint: 1, None height: dp(40) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Get Monthly Credits' font_size: '13sp' color: (0,0,0,1) @@ -788,19 +783,19 @@ NavigationLayout: size: self.size MDLabel: size_hint_y: None - font_style: 'Headline' + font_style: 'Subtitle1' theme_text_color: 'Primary' text: 'Gold' halign: 'center' color: 1,1,1,1 MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: 'We provide for proof of work calculation for 1years. ' halign: 'center' color: 1,1,1,1 MDLabel: - font_style: 'Headline' + font_style: 'Subtitle1' theme_text_color: 'Primary' text: '€ 500.0' halign: 'center' @@ -815,7 +810,7 @@ NavigationLayout: size_hint: 1, None height: dp(40) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Get Yearly Credits' font_size: '13sp' color: (0,0,0,1) @@ -862,7 +857,7 @@ NavigationLayout: on_release: root.savecontact() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Save' font_size: '13sp' color: (1,1,1,1) @@ -873,7 +868,7 @@ NavigationLayout: on_press: root.dismiss() on_press: root.close_pop() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Cancel' font_size: '13sp' color: (1,1,1,1) @@ -882,7 +877,7 @@ NavigationLayout: size_hint: 2, None height: dp(40) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Scan QR code' font_size: '13sp' color: (1,1,1,1) @@ -891,93 +886,8 @@ NavigationLayout: : name: 'networkstat' - MDTabbedPanel: - id: tab_panel - tab_display_mode:'text' - - MDTab: - name: 'connections' - text: "Total connections" - ScrollView: - do_scroll_x: False - MDList: - id: ml - size_hint_y: None - height: dp(200) - OneLineListItem: - text: "Total Connections" - BoxLayout: - AnchorLayout: - MDRaisedButton: - size_hint: .6, .35 - height: dp(40) - MDLabel: - font_style: 'Title' - text: root.text_variable_1 - font_size: '13sp' - color: (1,1,1,1) - halign: 'center' - MDTab: - name: 'processes' - text: 'Processes' - ScrollView: - do_scroll_x: False - MDList: - id: ml - size_hint_y: None - height: dp(500) - OneLineListItem: - text: "person-to-person" - BoxLayout: - AnchorLayout: - MDRaisedButton: - size_hint: .7, .6 - height: dp(40) - MDLabel: - font_style: 'Title' - text: root.text_variable_2 - font_size: '13sp' - color: (1,1,1,1) - halign: 'center' - OneLineListItem: - text: "Brodcast" - BoxLayout: - AnchorLayout: - MDRaisedButton: - size_hint: .7, .6 - height: dp(40) - MDLabel: - font_style: 'Title' - text: root.text_variable_3 - font_size: '13sp' - color: (1,1,1,1) - halign: 'center' - OneLineListItem: - text: "publickeys" - BoxLayout: - AnchorLayout: - MDRaisedButton: - size_hint: .7, .6 - height: dp(40) - MDLabel: - font_style: 'Title' - text: root.text_variable_4 - font_size: '13sp' - color: (1,1,1,1) - halign: 'center' - OneLineListItem: - text: "objects" - BoxLayout: - AnchorLayout: - MDRaisedButton: - size_hint: .7, .6 - height: dp(40) - MDLabel: - font_style: 'Title' - text: root.text_variable_5 - font_size: '13sp' - color: (1,1,1,1) - halign: 'center' + Label: + text:"surbhi" : name: 'mailDetail' @@ -989,31 +899,31 @@ NavigationLayout: height: dp(500) + self.minimum_height padding: dp(32) MDLabel: - font_style: 'Headline' + font_style: 'Subtitle1' theme_text_color: 'Primary' text: root.subject halign: 'left' font_size: '20sp' CopyTextBtn: MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: "From: " + root.from_addr halign: 'left' CopyTextBtn: MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: "To: " + root.to_addr halign: 'left' CopyTextBtn: MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: root.status halign: 'left' MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: root.message halign: 'left' @@ -1072,25 +982,25 @@ NavigationLayout: spacing:dp(25) MDLabel: id: myaddr_label - font_style: 'Title' + font_style: 'H4' theme_text_color: 'Primary' text: "Label" font_size: '17sp' halign: 'left' MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: root.address_label font_size: '15sp' halign: 'left' MDLabel: - font_style: 'Title' + font_style: 'H4' theme_text_color: 'Primary' text: "Address" font_size: '17sp' halign: 'left' MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: root.address font_size: '15sp' @@ -1104,7 +1014,7 @@ NavigationLayout: height: dp(40) on_press: root.send_message_from() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Send message from' font_size: '13sp' color: (1,1,1,1) @@ -1116,7 +1026,7 @@ NavigationLayout: on_press: app.root.ids.scr_mngr.current = 'showqrcode' on_press: app.root.ids.sc15.qrdisplay() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Show QR code' font_size: '13sp' color: (1,1,1,1) @@ -1127,7 +1037,7 @@ NavigationLayout: on_press: root.dismiss() on_press: root.close_pop() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Cancel' font_size: '13sp' color: (1,1,1,1) @@ -1151,14 +1061,14 @@ NavigationLayout: orientation: 'vertical' spacing:dp(20) MDLabel: - font_style: 'Title' + font_style: 'H4' theme_text_color: 'Primary' text: "Label" font_size: '17sp' halign: 'left' MDTextField: id: add_label - font_style: 'Subhead' + font_style: 'H4' font_size: '15sp' halign: 'left' text: root.address_label @@ -1166,13 +1076,13 @@ NavigationLayout: required: True helper_text_mode: "on_error" MDLabel: - font_style: 'Title' + font_style: 'H4' theme_text_color: 'Primary' text: "Address" font_size: '17sp' halign: 'left' MDLabel: - font_style: 'Subhead' + font_style: 'H4' theme_text_color: 'Primary' text: root.address font_size: '15sp' @@ -1186,7 +1096,7 @@ NavigationLayout: height: dp(40) on_press: root.send_message_to() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Send message to' font_size: '13sp' color: (1,1,1,1) @@ -1197,7 +1107,7 @@ NavigationLayout: font_size: '10sp' on_press: root.update_addbook_label(root.address) MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Save' font_size: '13sp' color: (1,1,1,1) @@ -1208,7 +1118,7 @@ NavigationLayout: on_press: root.dismiss() on_press: root.close_pop() MDLabel: - font_style: 'Title' + font_style: 'H4' text: 'Cancel' font_size: '13sp' color: (1,1,1,1) diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 70f51b29..6f7b1cc6 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -35,27 +35,31 @@ from kivy.uix.screenmanager import Screen from kivy.uix.spinner import Spinner from kivy.uix.textinput import TextInput from kivy.utils import platform -import kivy_helper_search -from kivymd.button import MDIconButton -from kivymd.dialog import MDDialog -from kivymd.label import MDLabel -from kivymd.list import ( +from bitmessagekivy import kivy_helper_search +from kivymd.uix.dialog import MDDialog +from kivymd.uix.button import MDIconButton +from kivymd.uix.label import MDLabel +from kivymd.uix.list import ( ILeftBody, ILeftBodyTouch, IRightBodyTouch, TwoLineAvatarIconListItem, TwoLineListItem) -from kivymd.navigationdrawer import ( +from kivymd.uix.navigationdrawer import ( MDNavigationDrawer, NavigationDrawerHeaderBase) -from kivymd.selectioncontrols import MDCheckbox +from kivymd.uix.selectioncontrol import MDCheckbox from kivymd.theming import ThemeManager import queues from semaphores import kivyuisignaler import state -from uikivysignaler import UIkivySignaler -import identiconGeneration +from bitmessagekivy.uikivysignaler import UIkivySignaler +# pylint: disable=unused-argument, too-few-public-methods, import-error + +from bitmessagekivy import identiconGeneration +import os +from kivy.core.clipboard import Clipboard # pylint: disable=unused-argument, too-few-public-methods @@ -89,7 +93,7 @@ class Inbox(Screen): def init_ui(self, dt=0): """Clock Schdule for method inbox accounts.""" self.inboxaccounts() - print dt + print (dt) def inboxaccounts(self): """Load inbox accounts.""" @@ -329,7 +333,7 @@ class AddressBook(Screen): def init_ui(self, dt=0): """Clock Schdule for method AddressBook.""" self.loadAddresslist(None, 'All', '') - print dt + print (dt) def loadAddresslist(self, account, where="", what=""): """Clock Schdule for method AddressBook.""" @@ -428,7 +432,7 @@ class SelectableLabel(RecycleDataViewBehavior, Label): """Respond to the selection of items in the view.""" self.selected = is_selected if is_selected: - print "selection changed to {0}".format(rv.data[index]) + 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']) @@ -455,7 +459,7 @@ class DropDownWidget(BoxLayout): subject = self.ids.subject.text.encode('utf-8').strip() message = self.ids.body.text.encode('utf-8').strip() encoding = 3 - print "message: ", self.ids.body.text + print ("message: ", self.ids.body.text) sendMessageToPeople = True if sendMessageToPeople: if toAddress != '' and subject and message: @@ -483,12 +487,12 @@ class DropDownWidget(BoxLayout): toAddress = addBMIfNotPresent(toAddress) statusIconColor = 'red' if addressVersionNumber > 4 or addressVersionNumber <= 1: - print "addressVersionNumber > 4 \ - or addressVersionNumber <= 1" + print("addressVersionNumber > 4 \ + or addressVersionNumber <= 1") if streamNumber > 1 or streamNumber == 0: - print "streamNumber > 1 or streamNumber == 0" + print("streamNumber > 1 or streamNumber == 0") if statusIconColor == 'red': - print "shared.statusIconColor == 'red'" + print("shared.statusIconColor == 'red'") stealthLevel = BMConfigParser().safeGetInt( 'bitmessagesettings', 'ackstealthlevel') from helper_ackPayload import genAckPayload @@ -523,7 +527,7 @@ class DropDownWidget(BoxLayout): toLabel = '' queues.workerQueue.put(('sendmessage', toAddress)) - print "sqlExecute successfully #######################" + print ("sqlExecute successfully #######################") self.parent.parent.current = 'inbox' state.in_composer = True navApp.back_press() @@ -718,7 +722,7 @@ class Sent(Screen): def init_ui(self, dt=0): """Clock Schdule for method sent accounts.""" self.sentaccounts() - print dt + print(dt) def sentaccounts(self): """Load sent accounts.""" @@ -1088,7 +1092,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods if not os.path.exists(directory): os.makedirs(directory) except OSError: - print 'Error: Creating directory. ' + directory + print('Error: Creating directory. ' + directory) @staticmethod def get_default_image(): @@ -1179,7 +1183,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods @staticmethod def on_stop(): """On stop methos is used for stoping the runing script.""" - print "*******************EXITING FROM APPLICATION*******************" + print("*******************EXITING FROM APPLICATION*******************") import shutdown shutdown.doCleanShutdown() @@ -1633,7 +1637,7 @@ class Draft(Screen): def init_ui(self, dt=0): """Clock Schdule for method draft accounts.""" self.sentaccounts() - print dt + print (dt) def sentaccounts(self): """Load draft accounts.""" @@ -1801,7 +1805,7 @@ class Allmails(Screen): def init_ui(self, dt=0): """Clock Schdule for method all mails.""" self.mailaccounts() - print dt + print (dt) def mailaccounts(self): """Load all mails for account.""" diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index e066dd06..6e8206ef 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -200,6 +200,7 @@ class Main: # pylint: disable=no-init, old-style-class from plugins.plugin import get_plugin try: proxyconfig_start = time.time() + import pdb;pdb.set_trace if not get_plugin('proxyconfig', name=proxy_type)(config): raise TypeError except TypeError: @@ -358,7 +359,7 @@ class Main: # pylint: disable=no-init, old-style-class # Not needed if objproc disabled if state.enableObjProc: shared.reloadMyAddressHashes() - shared.reloadBroadcastSendersForWhichImWatching() + # shared.reloadBroadcastSendersForWhichImWatching() # API is also objproc dependent if config.safeGetBoolean('bitmessagesettings', 'apienabled'): import api # pylint: disable=relative-import @@ -373,7 +374,7 @@ class Main: # pylint: disable=no-init, old-style-class asyncoreThread = BMNetworkThread() asyncoreThread.daemon = True asyncoreThread.start() - for i in range(config.getint('threads', 'receive')): + for i in range(config.safeGet('threads', 'receive')): receiveQueueThread = ReceiveQueueThread(i) receiveQueueThread.daemon = True receiveQueueThread.start() diff --git a/src/helper_startup.py b/src/helper_startup.py index 0d3523e3..f0457638 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -25,6 +25,7 @@ StoreConfigFilesInSameDirectoryAsProgramByDefault = False def _loadTrustedPeer(): + trustedPeer = '' try: trustedPeer = BMConfigParser().get('bitmessagesettings', 'trustedpeer') except configparser.Error: @@ -32,13 +33,15 @@ def _loadTrustedPeer(): # can just leave it as None return try: - host, port = trustedPeer.split(':') + # import pdb;pdb.set_trace() + if trustedPeer != None: + host, port = trustedPeer.split(':') + state.trustedPeer = state.Peer(host, int(port)) except ValueError: sys.exit( 'Bad trustedpeer config setting! It should be set as' ' trustedpeer=:' ) - state.trustedPeer = state.Peer(host, int(port)) def loadConfig(): diff --git a/src/highlevelcrypto.py b/src/highlevelcrypto.py index c235072c..648e11a7 100644 --- a/src/highlevelcrypto.py +++ b/src/highlevelcrypto.py @@ -16,8 +16,9 @@ def makeCryptor(privkey): # import pdb;pdb.set_trace() private_key = a.changebase(privkey, 16, 256, minlen=32) public_key = pointMult(private_key) - privkey_bin = '\x02\xca\x00\x20' + private_key - pubkey_bin = '\x02\xca\x00\x20' + public_key[1:-32].decode() + '\x00\x20' + public_key[-32:].decode() + privkey_bin = '\x02\xca\x00\x20'.encode('utf-8') + private_key + pubkey_bin = '\x02\xca\x00\x20'.encode('utf-8') + public_key[1:-32] + '\x00\x20'.encode('utf-8') + public_key[-32:] + import pdb;pdb.set_trace() cryptor = pyelliptic.ECC(curve='secp256k1', privkey=privkey_bin, pubkey=pubkey_bin) return cryptor diff --git a/src/knownnodes.py b/src/knownnodes.py index b30ca770..35d105bc 100644 --- a/src/knownnodes.py +++ b/src/knownnodes.py @@ -55,6 +55,7 @@ def json_deserialize_knownnodes(source): Read JSON from source and make knownnodes dict """ global knownNodesActual # pylint: disable=global-statement + # import pdb;pdb.set_trace() for node in json.load(source): peer = node['peer'] info = node['info'] @@ -107,7 +108,7 @@ def createDefaultKnownNodes(): def readKnownNodes(): try: - with open(state.appdata + 'knownnodes.dat', 'rb') as source: + with open(state.appdata + 'knownnodes.dat', 'r') as source: with knownNodesLock: try: json_deserialize_knownnodes(source) diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index a50d83b6..313f3924 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -274,10 +274,15 @@ class BMConnectionPool(object): continue self.lastSpawned = time.time() + + print('++++++++++++++++++++++++++++++++++++++++++') + print('self.inboundConnections.values()-{}'.format(self.inboundConnections.values())) + print('self.outboundConnections.values() -{}'.format(self.outboundConnections.values())) + print('+++++++++++++++++++++++++++++++++++++++++++') else: for i in ( - self.inboundConnections.values() + - self.outboundConnections.values() + list(self.inboundConnections.values()) + + list(self.outboundConnections.values()) ): # FIXME: rating will be increased after next connection i.handle_close() diff --git a/src/network/stats.py b/src/network/stats.py index 7b9a1e0d..31ffcbf3 100644 --- a/src/network/stats.py +++ b/src/network/stats.py @@ -4,7 +4,7 @@ src/network/stats.py """ import time -import asyncore_pollchoose as asyncore +from network import asyncore_pollchoose as asyncore from network.connectionpool import BMConnectionPool from network.objectracker import missingObjects @@ -20,8 +20,9 @@ currentSentSpeed = 0 def connectedHostsList(): """List of all the connected hosts""" retval = [] - for i in BMConnectionPool().inboundConnections.values() + \ - BMConnectionPool().outboundConnections.values(): + # import pdb;pdb.set_trace() + for i in list(BMConnectionPool().inboundConnections.values()) + \ + list(BMConnectionPool().outboundConnections.values()): if not i.fullyEstablished: continue try: diff --git a/src/pyelliptic/arithmetic.py b/src/pyelliptic/arithmetic.py index 43166006..7b7a477b 100644 --- a/src/pyelliptic/arithmetic.py +++ b/src/pyelliptic/arithmetic.py @@ -30,7 +30,9 @@ def get_code_string(base): elif base == 58: return "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" elif base == 256: - return ''.join([chr(x) for x in range(256)]) + '''raw_unicode_escape is used because in the python3 after range(161) its genreate the' + the speical character so avoiding that function we have used the raw_unicode method ''' + return ''.join([chr(x) for x in range(256)]).encode('raw_unicode_escape') else: raise ValueError("Invalid base!") @@ -38,9 +40,16 @@ def get_code_string(base): def encode(val, base, minlen=0): code_string = get_code_string(base) result = "" + result = str.encode(result) + count = 0 + # import pdb;pdb.set_trace() while val > 0: - result = code_string[round(val % base)] + result - val /= base + count += 1 + # import pdb;pdb.set_trace() + result = code_string[int(val) % base:int(val) % base + 1] + result + # print('the value of the result-{}'.format(result)) + val = int(val / base) + # import pdb;pdb.set_trace() if len(result) < minlen: result = code_string[0] * (minlen - len(result)) + result return result @@ -48,10 +57,12 @@ def encode(val, base, minlen=0): def decode(string, base): code_string = get_code_string(base) + string.decode() result = 0 if base == 16: string = string.lower() while string: + # import pdb;pdb.set_trace() result *= base result += code_string.find(string.decode()[0]) string = string[1:] @@ -59,6 +70,7 @@ def decode(string, base): def changebase(string, frm, to, minlen=0): + # import pdb;pdb.set_trace() return encode(decode(string, frm), to, minlen) diff --git a/src/pyelliptic/ecc.py b/src/pyelliptic/ecc.py index 14adca42..63748287 100644 --- a/src/pyelliptic/ecc.py +++ b/src/pyelliptic/ecc.py @@ -74,11 +74,13 @@ class ECC(object): if curve != curve2: raise Exception("Bad ECC keys ...") self.curve = curve + import pdb;pdb.set_trace() self._set_keys(pubkey_x, pubkey_y, raw_privkey) else: self.privkey, self.pubkey_x, self.pubkey_y = self._generate() def _set_keys(self, pubkey_x, pubkey_y, privkey): + import pdb;pdb.set_trace() if self.raw_check_key(privkey, pubkey_x, pubkey_y) < 0: self.pubkey_x = None self.pubkey_y = None @@ -114,7 +116,7 @@ class ECC(object): pack('!H', len(self.pubkey_x)), self.pubkey_x, pack('!H', len(self.pubkey_y)), - self.pubkey_y, + self.pubkey_y, )) def get_privkey(self): @@ -129,27 +131,37 @@ class ECC(object): )) @staticmethod - def _decode_pubkey( pubkey): - pubkey = pubkey.encode() + def _decode_pubkey(pubkey): + # pubkey = pubkey.encode() + import pdb;pdb.set_trace() i = 0 - curve = unpack('!H', pubkey[i:i + 2])[0] + # curve = unpack('!H', pubkey[i:i + 2])[0] + curve = pack('!s', pubkey[i:i + 1])[0] + i += 2 - tmplen = unpack('!H', pubkey[i:i + 2])[0] + # tmplen = unpack('!H', pubkey[i:i + 2])[0] + tmplen = pack('!s', pubkey[i:i + 1])[0] i += 2 pubkey_x = pubkey[i:i + tmplen] - i += tmplen - tmplen = unpack('!H', pubkey[i:i + 2])[0] - i += 2 + # i += tmplen + i += int(tmplen / 3) + # tmplen = unpack('!H', pubkey[i:i + 2])[0] + tmplen = pack('!s', pubkey[i:i + 1])[0] + # i += 2 pubkey_y = pubkey[i:i + tmplen] - i += tmplen - return curve, pubkey_x, pubkey_y, i + # i += tmplen + return curve, pubkey_x, pubkey_y, int(i) @staticmethod def _decode_privkey(privkey): i = 0 - curve = unpack('!H', privkey[i:i + 2])[0] + # import pdb;pdb.set_trace() + # curve = unpack('!H', privkey[i:i + 2])[0] + curve = pack('!s', privkey[i:i + 1])[0] + i += 2 - tmplen = unpack('!H', privkey[i:i + 2])[0] + # tmplen = unpack('!H', privkey[i:i + 2])[0] + tmplen = pack('!s', privkey[i:i + 1])[0] i += 2 privkey = privkey[i:i + tmplen] i += tmplen @@ -276,6 +288,7 @@ class ECC(object): return self.raw_check_key(raw_privkey, pubkey_x, pubkey_y, curve) def raw_check_key(self, privkey, pubkey_x, pubkey_y, curve=None): + import pdb;pdb.set_trace() """Check key validity, key is supplied as binary data""" # pylint: disable=too-many-branches if curve is None: diff --git a/src/storage/sqlite.py b/src/storage/sqlite.py index 54913830..03265fd1 100644 --- a/src/storage/sqlite.py +++ b/src/storage/sqlite.py @@ -8,7 +8,7 @@ from threading import RLock from helper_sql import sqlQuery, SqlBulkExecute, sqlExecute -from storage import InventoryStorage, InventoryItem +from storage.storage import InventoryStorage, InventoryItem class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors