Solved TestProcessConfig's settingsversion issue
This commit is contained in:
parent
c8eaa28f0f
commit
57d22a5cd6
|
@ -95,7 +95,7 @@ class sqlThread(threading.Thread):
|
||||||
# In the Python3 I am below condition converting into int
|
# In the Python3 I am below condition converting into int
|
||||||
# settingsversion = int(BMConfigParser().get('bitmessagesettings', 'settingsversion') \
|
# settingsversion = int(BMConfigParser().get('bitmessagesettings', 'settingsversion') \
|
||||||
# if BMConfigParser().get('bitmessagesettings', 'settingsversion') else 0)
|
# if BMConfigParser().get('bitmessagesettings', 'settingsversion') else 0)
|
||||||
settingsversion = BMConfigParser().safeGetInt('bitmessagesettings', 'settingsvesion')
|
settingsversion = BMConfigParser().safeGetInt('bitmessagesettings', 'settingsversion')
|
||||||
# People running earlier versions of PyBitmessage do not have the
|
# People running earlier versions of PyBitmessage do not have the
|
||||||
# usedpersonally field in their pubkeys table. Let's add it.
|
# usedpersonally field in their pubkeys table. Let's add it.
|
||||||
if settingsversion == 2:
|
if settingsversion == 2:
|
||||||
|
|
|
@ -34,11 +34,8 @@ StoreConfigFilesInSameDirectoryAsProgramByDefault = False
|
||||||
|
|
||||||
def loadConfig():
|
def loadConfig():
|
||||||
"""Load the config"""
|
"""Load the config"""
|
||||||
print('1111111111111111111111111111111111111111')
|
|
||||||
config = BMConfigParser()
|
config = BMConfigParser()
|
||||||
|
|
||||||
if state.appdata:
|
if state.appdata:
|
||||||
print('if loadConfig state.appdata111 -{}'.format(state.appdata))
|
|
||||||
config.read(state.appdata + 'keys.dat')
|
config.read(state.appdata + 'keys.dat')
|
||||||
# state.appdata must have been specified as a startup option.
|
# state.appdata must have been specified as a startup option.
|
||||||
needToCreateKeysFile = config.safeGet(
|
needToCreateKeysFile = config.safeGet(
|
||||||
|
@ -48,31 +45,19 @@ def loadConfig():
|
||||||
'Loading config files from directory specified'
|
'Loading config files from directory specified'
|
||||||
' on startup: %s', state.appdata)
|
' on startup: %s', state.appdata)
|
||||||
else:
|
else:
|
||||||
print('else loadConfig state.appdata2222 -{}'.format(
|
|
||||||
state.appdata))
|
|
||||||
config.read(paths.lookupExeFolder() + 'keys.dat')
|
config.read(paths.lookupExeFolder() + 'keys.dat')
|
||||||
try:
|
try:
|
||||||
config.get('bitmessagesettings', 'settingsversion')
|
config.get('bitmessagesettings', 'settingsversion')
|
||||||
print('try bitmessagesettings', 'settingsversion -{}'.format(
|
|
||||||
config.get('bitmessagesettings', 'settingsversion')))
|
|
||||||
logger.info('Loading config files from same directory as program.')
|
logger.info('Loading config files from same directory as program.')
|
||||||
needToCreateKeysFile = False
|
needToCreateKeysFile = False
|
||||||
state.appdata = paths.lookupExeFolder()
|
state.appdata = paths.lookupExeFolder()
|
||||||
except:
|
except:
|
||||||
print('load the config except except')
|
|
||||||
# Could not load the keys.dat file in the program directory.
|
# Could not load the keys.dat file in the program directory.
|
||||||
# Perhaps it is in the appdata directory.
|
# Perhaps it is in the appdata directory.
|
||||||
state.appdata = paths.lookupAppdataFolder()
|
state.appdata = paths.lookupAppdataFolder()
|
||||||
config.read(state.appdata + 'keys.dat')
|
config.read(state.appdata + 'keys.dat')
|
||||||
needToCreateKeysFile = config.safeGet(
|
needToCreateKeysFile = config.safeGet(
|
||||||
'bitmessagesettings', 'settingsversion') is None
|
'bitmessagesettings', 'settingsversion') is None
|
||||||
print('needToCreateKeysFile -{}'.format(
|
|
||||||
needToCreateKeysFile))
|
|
||||||
if not needToCreateKeysFile:
|
|
||||||
print(
|
|
||||||
'needToCreateKeysFile is false means settingversion is not empty')
|
|
||||||
print(config.get(
|
|
||||||
'bitmessagesettings','settingsversion'))
|
|
||||||
if not needToCreateKeysFile:
|
if not needToCreateKeysFile:
|
||||||
logger.info(
|
logger.info(
|
||||||
'Loading existing config files from %s', state.appdata)
|
'Loading existing config files from %s', state.appdata)
|
||||||
|
@ -139,10 +124,6 @@ def loadConfig():
|
||||||
if not sys.platform.startswith('win'):
|
if not sys.platform.startswith('win'):
|
||||||
os.umask(0o077)
|
os.umask(0o077)
|
||||||
config.save()
|
config.save()
|
||||||
print('7777777777777777777777777777777')
|
|
||||||
print('printing the bitmessage settings -{}'.format(config.get(
|
|
||||||
'bitmessagesettings','settingsversion')))
|
|
||||||
print('7777777777777777777777777777777')
|
|
||||||
else:
|
else:
|
||||||
updateConfig()
|
updateConfig()
|
||||||
|
|
||||||
|
@ -150,10 +131,7 @@ def loadConfig():
|
||||||
def updateConfig():
|
def updateConfig():
|
||||||
"""Save the config"""
|
"""Save the config"""
|
||||||
config = BMConfigParser()
|
config = BMConfigParser()
|
||||||
print('222222222222222222222222222222222222222')
|
settingsversion = BMConfigParser().safeGetInt('bitmessagesettings', 'settingsversion')
|
||||||
# Used python2.7
|
|
||||||
# settingsversion = int(BMConfigParser().get('bitmessagesettings', 'settingsversion') \
|
|
||||||
settingsversion = BMConfigParser().safeGetInt('bitmessagesettings', 'settingsvesion')
|
|
||||||
if settingsversion == 1:
|
if settingsversion == 1:
|
||||||
config.set('bitmessagesettings', 'socksproxytype', 'none')
|
config.set('bitmessagesettings', 'socksproxytype', 'none')
|
||||||
config.set('bitmessagesettings', 'sockshostname', 'localhost')
|
config.set('bitmessagesettings', 'sockshostname', 'localhost')
|
||||||
|
@ -296,15 +274,8 @@ def updateConfig():
|
||||||
# whatever the user selects.
|
# whatever the user selects.
|
||||||
if not config.has_option('bitmessagesettings', 'ttl'):
|
if not config.has_option('bitmessagesettings', 'ttl'):
|
||||||
config.set('bitmessagesettings', 'ttl', '367200')
|
config.set('bitmessagesettings', 'ttl', '367200')
|
||||||
print(
|
|
||||||
'updateConfig111 congfig.get(bitmessagesettings, settingsversion) -{}'.format(
|
|
||||||
config.get('bitmessagesettings','settingsversion')
|
|
||||||
))
|
|
||||||
config.set('bitmessagesettings', 'settingsversion', str(settingsversion))
|
config.set('bitmessagesettings', 'settingsversion', str(settingsversion))
|
||||||
print(
|
|
||||||
'updateConfig222 congfig.get(bitmessagesettings, settingsversion) -{}'.format(
|
|
||||||
config.get('bitmessagesettings','settingsversion')
|
|
||||||
))
|
|
||||||
config.save()
|
config.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user