Merge pull request #441 from Atheros1/master
refactored helper_startup.py so that it can make use of a pre-set shared.appdata variable
This commit is contained in:
commit
1496177892
|
@ -8,23 +8,36 @@ from namecoin import ensureNamecoinOptions
|
||||||
storeConfigFilesInSameDirectoryAsProgramByDefault = False # The user may de-select Portable Mode in the settings if they want the config files to stay in the application data folder.
|
storeConfigFilesInSameDirectoryAsProgramByDefault = False # The user may de-select Portable Mode in the settings if they want the config files to stay in the application data folder.
|
||||||
|
|
||||||
def loadConfig():
|
def loadConfig():
|
||||||
# First try to load the config file (the keys.dat file) from the program
|
if shared.appdata:
|
||||||
# directory
|
shared.config.read(shared.appdata + 'keys.dat')
|
||||||
|
#shared.appdata must have been specified as a startup option.
|
||||||
|
try:
|
||||||
|
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||||
|
print 'Loading config files from directory specified on startup: ' + shared.appdata
|
||||||
|
needToCreateKeysFile = False
|
||||||
|
except:
|
||||||
|
needToCreateKeysFile = True
|
||||||
|
|
||||||
|
else:
|
||||||
shared.config.read('keys.dat')
|
shared.config.read('keys.dat')
|
||||||
try:
|
try:
|
||||||
shared.config.get('bitmessagesettings', 'settingsversion')
|
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||||
print 'Loading config files from same directory as program'
|
print 'Loading config files from same directory as program.'
|
||||||
|
needToCreateKeysFile = False
|
||||||
shared.appdata = ''
|
shared.appdata = ''
|
||||||
except:
|
except:
|
||||||
# Could not load the keys.dat file in the program directory. Perhaps it
|
# Could not load the keys.dat file in the program directory. Perhaps it
|
||||||
# is in the appdata directory.
|
# is in the appdata directory.
|
||||||
shared.appdata = shared.lookupAppdataFolder()
|
shared.appdata = shared.lookupAppdataFolder()
|
||||||
shared.config = ConfigParser.SafeConfigParser()
|
|
||||||
shared.config.read(shared.appdata + 'keys.dat')
|
shared.config.read(shared.appdata + 'keys.dat')
|
||||||
try:
|
try:
|
||||||
shared.config.get('bitmessagesettings', 'settingsversion')
|
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||||
print 'Loading existing config files from', shared.appdata
|
print 'Loading existing config files from', shared.appdata
|
||||||
|
needToCreateKeysFile = False
|
||||||
except:
|
except:
|
||||||
|
needToCreateKeysFile = True
|
||||||
|
|
||||||
|
if needToCreateKeysFile:
|
||||||
# This appears to be the first time running the program; there is
|
# This appears to be the first time running the program; there is
|
||||||
# no config file (or it cannot be accessed). Create config file.
|
# no config file (or it cannot be accessed). Create config file.
|
||||||
shared.config.add_section('bitmessagesettings')
|
shared.config.add_section('bitmessagesettings')
|
||||||
|
|
|
@ -270,7 +270,7 @@ def ensureNamecoinOptions ():
|
||||||
nmc.close ()
|
nmc.close ()
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print "Failure reading namecoin config file: %s" % str (exc)
|
print "Could not read the Namecoin config file probably because you don't have Namecoin installed. That's ok; we don't really need it. Detailed error message: %s" % str (exc)
|
||||||
|
|
||||||
# If still nothing found, set empty at least.
|
# If still nothing found, set empty at least.
|
||||||
if (not hasUser):
|
if (not hasUser):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user