diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index c1b3e16a..da22a363 100644 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -78,7 +78,6 @@ def get_exec_path(): def get_config(file_name, fallback = True): """Looks in cwd and in self.default_config_path for a config file.""" - # look for example file even if not used here, path is returned to caller config_found,example_found,example_copy = False,False,False config_path, example_path = None,None @@ -88,17 +87,17 @@ def get_config(file_name, fallback = True): config_path = os.path.join(exec_dir, 'pyfpdb', file_name) else: config_path = os.path.join(exec_dir, file_name) -# print "config_path=", config_path + #print "config_path=", config_path if os.path.exists(config_path): # there is a file in the cwd config_found = True # so we use it else: # no file in the cwd, look where it should be in the first place default_dir = get_default_config_path() config_path = os.path.join(default_dir, file_name) -# print "config path 2=", config_path + #print "config path 2=", config_path if os.path.exists(config_path): config_found = True - -# Example configuration for debian package + + # 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 @@ -112,7 +111,14 @@ def get_config(file_name, fallback = True): msg = _("Config file has been created at %s.\n") % config_path logging.info(msg) except IOError: - pass + try: + example_path = file_name + '.example' + shutil.copyfile(example_path, config_path) + example_copy = True + msg = _("Config file has been created at %s.\n") % config_path + logging.info(msg) + except IOError: + pass # OK, fall back to the .example file, should be in the start dir elif os.path.exists(file_name + ".example"):