refactored helper_startup.py so that it can make use of a pre-set shared.appdata variable
This commit is contained in:
parent
f317fafbb3
commit
1b5158d658
|
@ -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.
|
||||
|
||||
def loadConfig():
|
||||
# First try to load the config file (the keys.dat file) from the program
|
||||
# directory
|
||||
if shared.appdata:
|
||||
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')
|
||||
try:
|
||||
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 = ''
|
||||
except:
|
||||
# Could not load the keys.dat file in the program directory. Perhaps it
|
||||
# is in the appdata directory.
|
||||
shared.appdata = shared.lookupAppdataFolder()
|
||||
shared.config = ConfigParser.SafeConfigParser()
|
||||
shared.config.read(shared.appdata + 'keys.dat')
|
||||
try:
|
||||
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||
print 'Loading existing config files from', shared.appdata
|
||||
needToCreateKeysFile = False
|
||||
except:
|
||||
needToCreateKeysFile = True
|
||||
|
||||
if needToCreateKeysFile:
|
||||
# This appears to be the first time running the program; there is
|
||||
# no config file (or it cannot be accessed). Create config file.
|
||||
shared.config.add_section('bitmessagesettings')
|
||||
|
|
|
@ -270,7 +270,7 @@ def ensureNamecoinOptions ():
|
|||
nmc.close ()
|
||||
|
||||
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 (not hasUser):
|
||||
|
|
Reference in New Issue
Block a user