Move sample copying after fallback test

Only try to copy the example HUD_config.xml after fallback has been
tested against, and even then only on platform where the debian path can
exist
This commit is contained in:
Mika Bostrom 2010-08-17 08:18:46 +03:00
parent c49565fcb1
commit f18cc00c0d

View File

@ -84,18 +84,26 @@ def get_config(file_name, fallback = True):
# print "config path 2=", config_path # print "config path 2=", config_path
if os.path.exists(config_path): if os.path.exists(config_path):
return (config_path,False) return (config_path,False)
# Copy from example (debian package)
try:
example_path = '/usr/share/python-fpdb/' + file_name + '.example'
shutil.copyfile(example_path, config_path)
return (config_path,False)
except IOError:
pass
# No file found # No file found
if not fallback: if not fallback:
return (False,False) return (False,False)
# Example configuration for debian package
if os.name == 'posix':
# If we're on linux, try to copy example from the place
# debian package puts it; get_default_config_path() creates
# the config directory for us so there's no need to check it
# again
example_path = '/usr/share/python-fpdb/' + file_name + '.example'
try:
shutil.copyfile(example_path, config_path)
msg = 'Configuration file created: %s\n' % config_path
logging.info(msg)
return (config_path,False)
except IOError:
pass
# OK, fall back to the .example file, should be in the start dir # OK, fall back to the .example file, should be in the start dir
if os.path.exists(file_name + ".example"): if os.path.exists(file_name + ".example"):
try: try: