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
This commit is contained in:
Dmitri Bogomolov 2017-03-28 17:38:05 +03:00
parent e832ea1689
commit e6f0b34f9b
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
3 changed files with 26 additions and 8 deletions

View File

@ -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'))

View File

@ -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

View File

@ -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