From e6f0b34f9b1574019623cb3b6ce8e4a0803a2a13 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 28 Mar 2017 17:38:05 +0300 Subject: [PATCH] Fixed some inconvenience on first run mainly in Ubuntu. - immediately return from initCL() if numpy or pyopencl is unevailable (no ImportError because of resetPoW() call) - use glob to find C extension even if it named like `bitmsghash.x86_64-linux-gnu.so` If user chooses to show the Settings dialog: - activate the "Network Settings" tab - remove option 'dontconnect' if settings have been saved --- src/bitmessageqt/__init__.py | 16 ++++++++++++---- src/openclpow.py | 7 ++++--- src/proofofwork.py | 11 ++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index e861f767..76f6e46d 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -1619,7 +1619,8 @@ class MyForm(settingsmixin.SMainWindow): self.connectDialogInstance = connectDialog(self) if self.connectDialogInstance.exec_(): if self.connectDialogInstance.ui.radioButtonConnectNow.isChecked(): - BMConfigParser().remove_option('bitmessagesettings', 'dontconnect') + BMConfigParser().remove_option( + 'bitmessagesettings', 'dontconnect') BMConfigParser().save() else: self.click_actionSettings() @@ -2349,7 +2350,12 @@ class MyForm(settingsmixin.SMainWindow): def click_actionSettings(self): self.settingsDialogInstance = settingsDialog(self) + if self._firstrun: + self.settingsDialogInstance.ui.tabWidgetSettings.setCurrentIndex(1) if self.settingsDialogInstance.exec_(): + if self._firstrun: + BMConfigParser().remove_option( + 'bitmessagesettings', 'dontconnect') BMConfigParser().set('bitmessagesettings', 'startonlogon', str( self.settingsDialogInstance.ui.checkBoxStartOnLogon.isChecked())) BMConfigParser().set('bitmessagesettings', 'minimizetotray', str( @@ -4517,9 +4523,11 @@ def run(): myapp.appIndicatorInit(app) myapp.ubuntuMessagingMenuInit() myapp.notifierInit() - if BMConfigParser().safeGetBoolean('bitmessagesettings', 'dontconnect'): - myapp.showConnectDialog() # ask the user if we may connect - + myapp._firstrun = BMConfigParser().safeGetBoolean( + 'bitmessagesettings', 'dontconnect') + if myapp._firstrun: + myapp.showConnectDialog() # ask the user if we may connect + # try: # if BMConfigParser().get('bitmessagesettings', 'mailchuck') < 1: # myapp.showMigrationWizard(BMConfigParser().get('bitmessagesettings', 'mailchuck')) diff --git a/src/openclpow.py b/src/openclpow.py index 59375329..ca40e634 100644 --- a/src/openclpow.py +++ b/src/openclpow.py @@ -26,7 +26,9 @@ except: libAvailable = False def initCL(): - global ctx, queue, program, hash_dt + global ctx, queue, program, hash_dt, libAvailable + if libAvailable is False: + return del enabledGpus[:] del vendors[:] del gpus[:] @@ -98,8 +100,7 @@ def do_opencl_pow(hash, target): # logger.debug("Took %d tries.", progress) return output[0][0] -if libAvailable: - initCL() +initCL() if __name__ == "__main__": target = 54227212183L diff --git a/src/proofofwork.py b/src/proofofwork.py index 493b8b0c..eb845c25 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -266,9 +266,18 @@ def init(): else: try: bso = ctypes.CDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib)) - logger.info("Loaded C PoW DLL %s", bitmsglib) + except OSError: + import glob + try: + bso = ctypes.CDLL(glob.glob(os.path.join( + paths.codePath(), "bitmsghash", "bitmsghash*.so" + ))[0]) + except (OSError, IndexError): + bso = None except: bso = None + else: + logger.info("Loaded C PoW DLL %s", bitmsglib) if bso: try: bmpow = bso.BitmessagePOW