Update winbuild.sh #1933
|
@ -134,13 +134,13 @@ function build_dll(){
|
||||||
cd src/bitmsghash || exit 1
|
cd src/bitmsghash || exit 1
|
||||||
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
|
||||||
echo "Create dll"
|
echo "Create dll"
|
||||||
x86_64-w64-mingw32-g++ -D_WIN32 -Wall -O3 -march=native \
|
x86_64-w64-mingw32-g++ -D_WIN32 -Wall -O3 -march=x86-64 \
|
||||||
"-I$HOME/.wine64/drive_c/OpenSSL-Win64/include" \
|
"-I$HOME/.wine64/drive_c/OpenSSL-Win64/include" \
|
||||||
|
|||||||
-I/usr/x86_64-w64-mingw32/include \
|
-I/usr/x86_64-w64-mingw32/include \
|
||||||
"-L$HOME/.wine64/drive_c/OpenSSL-Win64/lib" \
|
"-L$HOME/.wine64/drive_c/OpenSSL-Win64/lib" \
|
||||||
-c bitmsghash.cpp
|
-c bitmsghash.cpp
|
||||||
x86_64-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
|
x86_64-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
|
||||||
-D_WIN32 -O3 -march=native \
|
-D_WIN32 -O3 -march=x86-64 \
|
||||||
"-I$HOME/.wine64/drive_c/OpenSSL-Win64/include" \
|
"-I$HOME/.wine64/drive_c/OpenSSL-Win64/include" \
|
||||||
"-L$HOME/.wine64/drive_c/OpenSSL-Win64" \
|
"-L$HOME/.wine64/drive_c/OpenSSL-Win64" \
|
||||||
-L/usr/lib/x86_64-linux-gnu/wine \
|
-L/usr/lib/x86_64-linux-gnu/wine \
|
||||||
|
@ -148,13 +148,13 @@ function build_dll(){
|
||||||
-o bitmsghash64.dll -Wl,--out-implib,bitmsghash.a
|
-o bitmsghash64.dll -Wl,--out-implib,bitmsghash.a
|
||||||
else
|
else
|
||||||
echo "Create dll"
|
echo "Create dll"
|
||||||
i686-w64-mingw32-g++ -D_WIN32 -Wall -m32 -O3 -march=native \
|
i686-w64-mingw32-g++ -D_WIN32 -Wall -m32 -O3 -march=i686 \
|
||||||
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
|
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
|
||||||
-I/usr/i686-w64-mingw32/include \
|
-I/usr/i686-w64-mingw32/include \
|
||||||
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib" \
|
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib" \
|
||||||
-c bitmsghash.cpp
|
-c bitmsghash.cpp
|
||||||
i686-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
|
i686-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
|
||||||
-D_WIN32 -O3 -march=native \
|
-D_WIN32 -O3 -march=i686 \
|
||||||
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
|
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
|
||||||
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib/MinGW" \
|
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib/MinGW" \
|
||||||
-fPIC -shared -lcrypt32 -leay32 -lwsock32 \
|
-fPIC -shared -lcrypt32 -leay32 -lwsock32 \
|
||||||
|
|
31
src/bitmessagekivy/get_platform.py
Normal file
31
src/bitmessagekivy/get_platform.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# pylint: disable=no-else-return, too-many-return-statements
|
||||||
|
|
||||||
|
"""To check the platform"""
|
||||||
|
|
||||||
|
from sys import platform as _sys_platform
|
||||||
|
from os import environ
|
||||||
|
|
||||||
|
|
||||||
|
def _get_platform():
|
||||||
|
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:
|
||||||
|
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 not in ("android", "unknown"):
|
||||||
|
environ["KIVY_CAMERA"] = "opencv"
|
|
@ -16,7 +16,7 @@ import paths
|
||||||
import queues
|
import queues
|
||||||
import state
|
import state
|
||||||
import widgets
|
import widgets
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config as config_obj
|
||||||
from helper_sql import sqlExecute, sqlStoredProcedure
|
from helper_sql import sqlExecute, sqlStoredProcedure
|
||||||
from helper_startup import start_proxyconfig
|
from helper_startup import start_proxyconfig
|
||||||
from network import knownnodes, AnnounceThread
|
from network import knownnodes, AnnounceThread
|
||||||
|
@ -24,11 +24,11 @@ from network.asyncore_pollchoose import set_rates
|
||||||
from tr import _translate
|
from tr import _translate
|
||||||
|
|
||||||
|
|
||||||
def getSOCKSProxyType(config_):
|
def getSOCKSProxyType(config):
|
||||||
"""Get user socksproxytype setting from *config*"""
|
"""Get user socksproxytype setting from *config*"""
|
||||||
try:
|
try:
|
||||||
result = ConfigParser.SafeConfigParser.get(
|
result = ConfigParser.SafeConfigParser.get(
|
||||||
config_, 'bitmessagesettings', 'socksproxytype')
|
config, 'bitmessagesettings', 'socksproxytype')
|
||||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
|
@ -45,7 +45,7 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.firstrun = firstrun
|
self.firstrun = firstrun
|
||||||
self.config = config
|
self.config = config_obj
|
||||||
self.net_restart_needed = False
|
self.net_restart_needed = False
|
||||||
self.timer = QtCore.QTimer()
|
self.timer = QtCore.QTimer()
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
)
|
)
|
||||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||||
|
|
||||||
def adjust_from_config(self, config_):
|
def adjust_from_config(self, config):
|
||||||
"""Adjust all widgets state according to config settings"""
|
"""Adjust all widgets state according to config settings"""
|
||||||
# pylint: disable=too-many-branches,too-many-statements
|
# pylint: disable=too-many-branches,too-many-statements
|
||||||
if not self.parent.tray.isSystemTrayAvailable():
|
if not self.parent.tray.isSystemTrayAvailable():
|
||||||
|
@ -89,31 +89,31 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
"MainWindow", "Tray (not available in your system)"))
|
"MainWindow", "Tray (not available in your system)"))
|
||||||
for setting in (
|
for setting in (
|
||||||
'minimizetotray', 'trayonclose', 'startintray'):
|
'minimizetotray', 'trayonclose', 'startintray'):
|
||||||
config_.set('bitmessagesettings', setting, 'false')
|
config.set('bitmessagesettings', setting, 'false')
|
||||||
else:
|
else:
|
||||||
self.checkBoxMinimizeToTray.setChecked(
|
self.checkBoxMinimizeToTray.setChecked(
|
||||||
config_.getboolean('bitmessagesettings', 'minimizetotray'))
|
config.getboolean('bitmessagesettings', 'minimizetotray'))
|
||||||
self.checkBoxTrayOnClose.setChecked(
|
self.checkBoxTrayOnClose.setChecked(
|
||||||
config_.safeGetBoolean('bitmessagesettings', 'trayonclose'))
|
config.safeGetBoolean('bitmessagesettings', 'trayonclose'))
|
||||||
self.checkBoxStartInTray.setChecked(
|
self.checkBoxStartInTray.setChecked(
|
||||||
config_.getboolean('bitmessagesettings', 'startintray'))
|
config.getboolean('bitmessagesettings', 'startintray'))
|
||||||
|
|
||||||
self.checkBoxHideTrayConnectionNotifications.setChecked(
|
self.checkBoxHideTrayConnectionNotifications.setChecked(
|
||||||
config_.getboolean(
|
config.getboolean(
|
||||||
'bitmessagesettings', 'hidetrayconnectionnotifications'))
|
'bitmessagesettings', 'hidetrayconnectionnotifications'))
|
||||||
self.checkBoxShowTrayNotifications.setChecked(
|
self.checkBoxShowTrayNotifications.setChecked(
|
||||||
config_.getboolean('bitmessagesettings', 'showtraynotifications'))
|
config.getboolean('bitmessagesettings', 'showtraynotifications'))
|
||||||
|
|
||||||
self.checkBoxStartOnLogon.setChecked(
|
self.checkBoxStartOnLogon.setChecked(
|
||||||
config_.getboolean('bitmessagesettings', 'startonlogon'))
|
config.getboolean('bitmessagesettings', 'startonlogon'))
|
||||||
|
|
||||||
self.checkBoxWillinglySendToMobile.setChecked(
|
self.checkBoxWillinglySendToMobile.setChecked(
|
||||||
config_.safeGetBoolean(
|
config.safeGetBoolean(
|
||||||
'bitmessagesettings', 'willinglysendtomobile'))
|
'bitmessagesettings', 'willinglysendtomobile'))
|
||||||
self.checkBoxUseIdenticons.setChecked(
|
self.checkBoxUseIdenticons.setChecked(
|
||||||
config_.safeGetBoolean('bitmessagesettings', 'useidenticons'))
|
config.safeGetBoolean('bitmessagesettings', 'useidenticons'))
|
||||||
self.checkBoxReplyBelow.setChecked(
|
self.checkBoxReplyBelow.setChecked(
|
||||||
config_.safeGetBoolean('bitmessagesettings', 'replybelow'))
|
config.safeGetBoolean('bitmessagesettings', 'replybelow'))
|
||||||
|
|
||||||
if state.appdata == paths.lookupExeFolder():
|
if state.appdata == paths.lookupExeFolder():
|
||||||
self.checkBoxPortableMode.setChecked(True)
|
self.checkBoxPortableMode.setChecked(True)
|
||||||
|
@ -142,57 +142,57 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
|
|
||||||
# On the Network settings tab:
|
# On the Network settings tab:
|
||||||
self.lineEditTCPPort.setText(str(
|
self.lineEditTCPPort.setText(str(
|
||||||
config_.get('bitmessagesettings', 'port')))
|
config.get('bitmessagesettings', 'port')))
|
||||||
self.checkBoxUPnP.setChecked(
|
self.checkBoxUPnP.setChecked(
|
||||||
config_.safeGetBoolean('bitmessagesettings', 'upnp'))
|
config.safeGetBoolean('bitmessagesettings', 'upnp'))
|
||||||
self.checkBoxUDP.setChecked(
|
self.checkBoxUDP.setChecked(
|
||||||
config_.safeGetBoolean('bitmessagesettings', 'udp'))
|
config.safeGetBoolean('bitmessagesettings', 'udp'))
|
||||||
self.checkBoxAuthentication.setChecked(
|
self.checkBoxAuthentication.setChecked(
|
||||||
config_.getboolean('bitmessagesettings', 'socksauthentication'))
|
config.getboolean('bitmessagesettings', 'socksauthentication'))
|
||||||
self.checkBoxSocksListen.setChecked(
|
self.checkBoxSocksListen.setChecked(
|
||||||
config_.getboolean('bitmessagesettings', 'sockslisten'))
|
config.getboolean('bitmessagesettings', 'sockslisten'))
|
||||||
self.checkBoxOnionOnly.setChecked(
|
self.checkBoxOnionOnly.setChecked(
|
||||||
config_.safeGetBoolean('bitmessagesettings', 'onionservicesonly'))
|
config.safeGetBoolean('bitmessagesettings', 'onionservicesonly'))
|
||||||
|
|
||||||
self._proxy_type = getSOCKSProxyType(config_)
|
self._proxy_type = getSOCKSProxyType(config)
|
||||||
self.comboBoxProxyType.setCurrentIndex(
|
self.comboBoxProxyType.setCurrentIndex(
|
||||||
0 if not self._proxy_type
|
0 if not self._proxy_type
|
||||||
else self.comboBoxProxyType.findText(self._proxy_type))
|
else self.comboBoxProxyType.findText(self._proxy_type))
|
||||||
self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex())
|
self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex())
|
||||||
|
|
||||||
self.lineEditSocksHostname.setText(
|
self.lineEditSocksHostname.setText(
|
||||||
config_.get('bitmessagesettings', 'sockshostname'))
|
config.get('bitmessagesettings', 'sockshostname'))
|
||||||
self.lineEditSocksPort.setText(str(
|
self.lineEditSocksPort.setText(str(
|
||||||
config_.get('bitmessagesettings', 'socksport')))
|
config.get('bitmessagesettings', 'socksport')))
|
||||||
self.lineEditSocksUsername.setText(
|
self.lineEditSocksUsername.setText(
|
||||||
config_.get('bitmessagesettings', 'socksusername'))
|
config.get('bitmessagesettings', 'socksusername'))
|
||||||
self.lineEditSocksPassword.setText(
|
self.lineEditSocksPassword.setText(
|
||||||
config_.get('bitmessagesettings', 'sockspassword'))
|
config.get('bitmessagesettings', 'sockspassword'))
|
||||||
|
|
||||||
self.lineEditMaxDownloadRate.setText(str(
|
self.lineEditMaxDownloadRate.setText(str(
|
||||||
config_.get('bitmessagesettings', 'maxdownloadrate')))
|
config.get('bitmessagesettings', 'maxdownloadrate')))
|
||||||
self.lineEditMaxUploadRate.setText(str(
|
self.lineEditMaxUploadRate.setText(str(
|
||||||
config_.get('bitmessagesettings', 'maxuploadrate')))
|
config.get('bitmessagesettings', 'maxuploadrate')))
|
||||||
self.lineEditMaxOutboundConnections.setText(str(
|
self.lineEditMaxOutboundConnections.setText(str(
|
||||||
config_.get('bitmessagesettings', 'maxoutboundconnections')))
|
config.get('bitmessagesettings', 'maxoutboundconnections')))
|
||||||
|
|
||||||
# Demanded difficulty tab
|
# Demanded difficulty tab
|
||||||
self.lineEditTotalDifficulty.setText(str((float(
|
self.lineEditTotalDifficulty.setText(str((float(
|
||||||
config_.getint(
|
config.getint(
|
||||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||||
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||||
self.lineEditSmallMessageDifficulty.setText(str((float(
|
self.lineEditSmallMessageDifficulty.setText(str((float(
|
||||||
config_.getint(
|
config.getint(
|
||||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||||
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||||
|
|
||||||
# Max acceptable difficulty tab
|
# Max acceptable difficulty tab
|
||||||
self.lineEditMaxAcceptableTotalDifficulty.setText(str((float(
|
self.lineEditMaxAcceptableTotalDifficulty.setText(str((float(
|
||||||
config_.getint(
|
config.getint(
|
||||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')
|
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')
|
||||||
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||||
self.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(
|
self.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(
|
||||||
config_.getint(
|
config.getint(
|
||||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')
|
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')
|
||||||
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||||
|
|
||||||
|
@ -203,21 +203,21 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.comboBoxOpenCL.addItems(openclpow.vendors)
|
self.comboBoxOpenCL.addItems(openclpow.vendors)
|
||||||
self.comboBoxOpenCL.setCurrentIndex(0)
|
self.comboBoxOpenCL.setCurrentIndex(0)
|
||||||
for i in range(self.comboBoxOpenCL.count()):
|
for i in range(self.comboBoxOpenCL.count()):
|
||||||
if self.comboBoxOpenCL.itemText(i) == config_.safeGet(
|
if self.comboBoxOpenCL.itemText(i) == config.safeGet(
|
||||||
'bitmessagesettings', 'opencl'):
|
'bitmessagesettings', 'opencl'):
|
||||||
self.comboBoxOpenCL.setCurrentIndex(i)
|
self.comboBoxOpenCL.setCurrentIndex(i)
|
||||||
break
|
break
|
||||||
|
|
||||||
# Namecoin integration tab
|
# Namecoin integration tab
|
||||||
nmctype = config_.get('bitmessagesettings', 'namecoinrpctype')
|
nmctype = config.get('bitmessagesettings', 'namecoinrpctype')
|
||||||
self.lineEditNamecoinHost.setText(
|
self.lineEditNamecoinHost.setText(
|
||||||
config_.get('bitmessagesettings', 'namecoinrpchost'))
|
config.get('bitmessagesettings', 'namecoinrpchost'))
|
||||||
self.lineEditNamecoinPort.setText(str(
|
self.lineEditNamecoinPort.setText(str(
|
||||||
config_.get('bitmessagesettings', 'namecoinrpcport')))
|
config.get('bitmessagesettings', 'namecoinrpcport')))
|
||||||
self.lineEditNamecoinUser.setText(
|
self.lineEditNamecoinUser.setText(
|
||||||
config_.get('bitmessagesettings', 'namecoinrpcuser'))
|
config.get('bitmessagesettings', 'namecoinrpcuser'))
|
||||||
self.lineEditNamecoinPassword.setText(
|
self.lineEditNamecoinPassword.setText(
|
||||||
config_.get('bitmessagesettings', 'namecoinrpcpassword'))
|
config.get('bitmessagesettings', 'namecoinrpcpassword'))
|
||||||
|
|
||||||
if nmctype == "namecoind":
|
if nmctype == "namecoind":
|
||||||
self.radioButtonNamecoinNamecoind.setChecked(True)
|
self.radioButtonNamecoinNamecoind.setChecked(True)
|
||||||
|
@ -232,9 +232,9 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
|
|
||||||
# Message Resend tab
|
# Message Resend tab
|
||||||
self.lineEditDays.setText(str(
|
self.lineEditDays.setText(str(
|
||||||
config_.get('bitmessagesettings', 'stopresendingafterxdays')))
|
config.get('bitmessagesettings', 'stopresendingafterxdays')))
|
||||||
self.lineEditMonths.setText(str(
|
self.lineEditMonths.setText(str(
|
||||||
config_.get('bitmessagesettings', 'stopresendingafterxmonths')))
|
config.get('bitmessagesettings', 'stopresendingafterxmonths')))
|
||||||
|
|
||||||
def comboBoxProxyTypeChanged(self, comboBoxIndex):
|
def comboBoxProxyTypeChanged(self, comboBoxIndex):
|
||||||
"""A callback for currentIndexChanged event of comboBoxProxyType"""
|
"""A callback for currentIndexChanged event of comboBoxProxyType"""
|
||||||
|
|
|
@ -4,7 +4,6 @@ BMConfigParser class definition and default configuration settings
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys # FIXME: bad style! write more generally
|
|
||||||
from threading import Event
|
from threading import Event
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -36,6 +35,15 @@ class BMConfigParser(SafeConfigParser):
|
||||||
raise ValueError("Invalid value %s" % value)
|
raise ValueError("Invalid value %s" % value)
|
||||||
return SafeConfigParser.set(self, section, option, value)
|
return SafeConfigParser.set(self, section, option, value)
|
||||||
|
|
||||||
|
def get(self, section, option, **kwargs):
|
||||||
|
"""Try returning temporary value before using parent get()"""
|
||||||
|
try:
|
||||||
|
return self._temp[section][option]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
return SafeConfigParser.get(
|
||||||
|
self, section, option, **kwargs)
|
||||||
|
|
||||||
def setTemp(self, section, option, value=None):
|
def setTemp(self, section, option, value=None):
|
||||||
"""Temporary set option to value, not saving."""
|
"""Temporary set option to value, not saving."""
|
||||||
try:
|
try:
|
||||||
|
@ -43,41 +51,36 @@ class BMConfigParser(SafeConfigParser):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self._temp[section] = {option: value}
|
self._temp[section] = {option: value}
|
||||||
|
|
||||||
def safeGetBoolean(self, section, field):
|
def safeGetBoolean(self, section, option):
|
||||||
"""Return value as boolean, False on exceptions"""
|
"""Return value as boolean, False on exceptions"""
|
||||||
try:
|
try:
|
||||||
# Used in the python2.7
|
return self.getboolean(section, option)
|
||||||
# return self.getboolean(section, field)
|
|
||||||
# Used in the python3.5.2
|
|
||||||
# print(config, section, field)
|
|
||||||
return self.getboolean(section, field)
|
|
||||||
except (configparser.NoSectionError, configparser.NoOptionError,
|
except (configparser.NoSectionError, configparser.NoOptionError,
|
||||||
ValueError, AttributeError):
|
ValueError, AttributeError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def safeGetInt(self, section, field, default=0):
|
def safeGetInt(self, section, option, default=0):
|
||||||
"""Return value as integer, default on exceptions,
|
"""Return value as integer, default on exceptions,
|
||||||
0 if default missing"""
|
0 if default missing"""
|
||||||
try:
|
try:
|
||||||
# Used in the python2.7
|
return int(self.get(section, option))
|
||||||
# return self.getint(section, field)
|
|
||||||
# Used in the python3.7.0
|
|
||||||
return int(self.get(section, field))
|
|
||||||
except (configparser.NoSectionError, configparser.NoOptionError,
|
except (configparser.NoSectionError, configparser.NoOptionError,
|
||||||
ValueError, AttributeError):
|
ValueError, AttributeError):
|
||||||
return default
|
return default
|
||||||
|
|
||||||
def safeGetFloat(self, section, field, default=0.0):
|
def safeGetFloat(self, section, option, default=0.0):
|
||||||
"""Return value as float, default on exceptions,
|
"""Return value as float, default on exceptions,
|
||||||
0.0 if default missing"""
|
0.0 if default missing"""
|
||||||
try:
|
try:
|
||||||
return self.getfloat(section, field)
|
return self.getfloat(section, option)
|
||||||
except (configparser.NoSectionError, configparser.NoOptionError,
|
except (configparser.NoSectionError, configparser.NoOptionError,
|
||||||
ValueError, AttributeError):
|
ValueError, AttributeError):
|
||||||
return default
|
return default
|
||||||
|
|
||||||
def safeGet(self, section, option, default=None):
|
def safeGet(self, section, option, default=None):
|
||||||
"""Return value as is, default on exceptions, None if default missing"""
|
"""
|
||||||
|
Return value as is, default on exceptions, None if default missing
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.get(section, option)
|
return self.get(section, option)
|
||||||
except (configparser.NoSectionError, configparser.NoOptionError,
|
except (configparser.NoSectionError, configparser.NoOptionError,
|
||||||
|
@ -91,34 +94,25 @@ class BMConfigParser(SafeConfigParser):
|
||||||
return SafeConfigParser.items(self, section, True, variables)
|
return SafeConfigParser.items(self, section, True, variables)
|
||||||
|
|
||||||
def _reset(self):
|
def _reset(self):
|
||||||
"""Reset current config. There doesn't appear to be a built in
|
"""
|
||||||
method for this"""
|
Reset current config.
|
||||||
|
There doesn't appear to be a built in method for this.
|
||||||
|
"""
|
||||||
|
self._temp = {}
|
||||||
sections = self.sections()
|
sections = self.sections()
|
||||||
for x in sections:
|
for x in sections:
|
||||||
self.remove_section(x)
|
self.remove_section(x)
|
||||||
|
|
||||||
def read(self, filenames=None):
|
def read(self, filenames=None):
|
||||||
self._reset()
|
self._reset()
|
||||||
SafeConfigParser.read(self, os.path.join(os.path.dirname(__file__), 'default.ini'))
|
SafeConfigParser.read(
|
||||||
|
self, os.path.join(os.path.dirname(__file__), 'default.ini'))
|
||||||
if filenames:
|
if filenames:
|
||||||
SafeConfigParser.read(self, filenames)
|
SafeConfigParser.read(self, filenames)
|
||||||
|
|
||||||
if sys.version_info[0] == 3:
|
def addresses(self):
|
||||||
@staticmethod
|
|
||||||
def addresses(hidden=False):
|
|
||||||
"""Return a list of local bitmessage addresses (from section labels)"""
|
"""Return a list of local bitmessage addresses (from section labels)"""
|
||||||
return [x for x in config.sections() if x.startswith('BM-') and (
|
return [x for x in self.sections() if x.startswith('BM-')]
|
||||||
hidden or not config.safeGetBoolean(x, 'hidden'))]
|
|
||||||
|
|
||||||
def readfp(self, fp, filename=None):
|
|
||||||
# pylint: disable=no-member
|
|
||||||
SafeConfigParser.read_file(self, fp)
|
|
||||||
else:
|
|
||||||
@staticmethod
|
|
||||||
def addresses():
|
|
||||||
"""Return a list of local bitmessage addresses (from section labels)"""
|
|
||||||
return [
|
|
||||||
x for x in config.sections() if x.startswith('BM-')]
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Save the runtime config onto the filesystem"""
|
"""Save the runtime config onto the filesystem"""
|
||||||
|
@ -161,4 +155,7 @@ class BMConfigParser(SafeConfigParser):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
config = BMConfigParser()
|
if not getattr(BMConfigParser, 'read_file', False):
|
||||||
|
BMConfigParser.read_file = BMConfigParser.readfp
|
||||||
|
|
||||||
|
config = BMConfigParser() # TODO: remove this crutch
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# pylint: disable=no-member, no-self-use
|
|
||||||
"""
|
"""
|
||||||
Various tests for config
|
Various tests for config
|
||||||
"""
|
"""
|
||||||
|
@ -36,63 +35,72 @@ maxnodes = 15000
|
||||||
maxsize = 1048576"""
|
maxsize = 1048576"""
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=protected-access
|
||||||
class TestConfig(unittest.TestCase):
|
class TestConfig(unittest.TestCase):
|
||||||
"""A test case for bmconfigparser"""
|
"""A test case for bmconfigparser"""
|
||||||
configfile = StringIO('')
|
|
||||||
|
def setUp(self):
|
||||||
|
self.config = BMConfigParser()
|
||||||
|
self.config.add_section('bitmessagesettings')
|
||||||
|
|
||||||
def test_safeGet(self):
|
def test_safeGet(self):
|
||||||
"""safeGet retuns provided default for nonexistent option or None"""
|
"""safeGet retuns provided default for nonexistent option or None"""
|
||||||
config = BMConfigParser()
|
|
||||||
self.assertIs(
|
self.assertIs(
|
||||||
config.safeGet('nonexistent', 'nonexistent'), None)
|
self.config.safeGet('nonexistent', 'nonexistent'), None)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.safeGet('nonexistent', 'nonexistent', 42), 42)
|
self.config.safeGet('nonexistent', 'nonexistent', 42), 42)
|
||||||
|
|
||||||
def test_safeGetBoolean(self):
|
def test_safeGetBoolean(self):
|
||||||
"""safeGetBoolean returns False for nonexistent option, no default"""
|
"""safeGetBoolean returns False for nonexistent option, no default"""
|
||||||
config = BMConfigParser()
|
|
||||||
self.assertIs(
|
self.assertIs(
|
||||||
config.safeGetBoolean('nonexistent', 'nonexistent'),
|
self.config.safeGetBoolean('nonexistent', 'nonexistent'), False)
|
||||||
False
|
|
||||||
)
|
|
||||||
# no arg for default
|
# no arg for default
|
||||||
# pylint: disable=too-many-function-args
|
# pylint: disable=too-many-function-args
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
config.safeGetBoolean(
|
self.config.safeGetBoolean('nonexistent', 'nonexistent', True)
|
||||||
'nonexistent', 'nonexistent', True)
|
|
||||||
|
|
||||||
def test_safeGetInt(self):
|
def test_safeGetInt(self):
|
||||||
"""safeGetInt retuns provided default for nonexistent option or 0"""
|
"""safeGetInt retuns provided default for nonexistent option or 0"""
|
||||||
config = BMConfigParser()
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.safeGetInt('nonexistent', 'nonexistent'), 0)
|
self.config.safeGetInt('nonexistent', 'nonexistent'), 0)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.safeGetInt('nonexistent', 'nonexistent', 42), 42)
|
self.config.safeGetInt('nonexistent', 'nonexistent', 42), 42)
|
||||||
|
|
||||||
def test_safeGetFloat(self):
|
def test_safeGetFloat(self):
|
||||||
"""safeGetFloat retuns provided default for nonexistent option or 0.0"""
|
"""
|
||||||
config = BMConfigParser()
|
safeGetFloat retuns provided default for nonexistent option or 0.0
|
||||||
|
"""
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.safeGetFloat('nonexistent', 'nonexistent'), 0.0)
|
self.config.safeGetFloat('nonexistent', 'nonexistent'), 0.0)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.safeGetFloat('nonexistent', 'nonexistent', 42.0), 42.0)
|
self.config.safeGetFloat('nonexistent', 'nonexistent', 42.0), 42.0)
|
||||||
|
|
||||||
|
def test_setTemp(self):
|
||||||
|
"""Set a temporary value and ensure it's returned by get()"""
|
||||||
|
self.config.setTemp('bitmessagesettings', 'connect', 'true')
|
||||||
|
self.assertIs(
|
||||||
|
self.config.safeGetBoolean('bitmessagesettings', 'connect'), True)
|
||||||
|
written_fp = StringIO('')
|
||||||
|
self.config.write(written_fp)
|
||||||
|
self.config._reset()
|
||||||
|
self.config.read_file(written_fp)
|
||||||
|
self.assertIs(
|
||||||
|
self.config.safeGetBoolean('bitmessagesettings', 'connect'), False)
|
||||||
|
|
||||||
def test_reset(self):
|
def test_reset(self):
|
||||||
"""safeGetInt retuns provided default for bitmessagesettings option or 0"""
|
"""Some logic for testing _reset()"""
|
||||||
config = BMConfigParser()
|
|
||||||
test_config_object = StringIO(test_config)
|
test_config_object = StringIO(test_config)
|
||||||
config.readfp(test_config_object)
|
self.config.read_file(test_config_object)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 100)
|
self.config.safeGetInt(
|
||||||
# pylint: disable=protected-access
|
'bitmessagesettings', 'maxaddrperstreamsend'), 100)
|
||||||
config._reset()
|
self.config._reset()
|
||||||
self.assertEqual(config.sections(), [])
|
self.assertEqual(self.config.sections(), [])
|
||||||
|
|
||||||
def test_defaults(self):
|
def test_defaults(self):
|
||||||
"""Loading defaults"""
|
"""Loading defaults"""
|
||||||
config = BMConfigParser()
|
self.config.set('bitmessagesettings', 'maxaddrperstreamsend', '100')
|
||||||
config.add_section('bitmessagesettings')
|
self.config.read()
|
||||||
config.set("bitmessagesettings", "maxaddrperstreamsend", "100")
|
|
||||||
config.read()
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.safeGetInt('bitmessagesettings', 'maxaddrperstreamsend'), 500)
|
self.config.safeGetInt(
|
||||||
|
'bitmessagesettings', 'maxaddrperstreamsend'), 500)
|
||||||
|
|
Reference in New Issue
Block a user
why not just remove?
Is that not what the minus signs indicate?
I sure didn't intend to leave "march=native" so hopefully github is not doing that.
I mean, aren't those values the defaults, that will be applied if you just remove the
-march=native
? Though maybe it's better to set that explicitly.It turns out that there is no default value for the march option.
https://gcc-help.gcc.gnu.narkive.com/Z259fPcD/default-value-for-march-option
Though you can find what your platform will use as default (if it is not specified) with the command:
gcc -Q --help=target
https://stackoverflow.com/questions/27786932/what-is-the-default-for-gcc-march-option