mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-01 04:38:12 +00:00
The gns3_controller.conf is located in the same directory of gns3_server.conf
Fix #701
This commit is contained in:
parent
1e0b724e47
commit
bfb82a9618
@ -43,13 +43,15 @@ class Config:
|
||||
|
||||
self._files = files
|
||||
self._profile = profile
|
||||
if files and len(files):
|
||||
self._main_config_file = files[0]
|
||||
else:
|
||||
self._main_config_file = None
|
||||
|
||||
# Monitor configuration files for changes
|
||||
self._watched_files = {}
|
||||
|
||||
if hasattr(sys, "_called_from_test"):
|
||||
self._files = files
|
||||
elif sys.platform.startswith("win"):
|
||||
if sys.platform.startswith("win"):
|
||||
|
||||
appname = "GNS3"
|
||||
|
||||
@ -69,7 +71,7 @@ class Config:
|
||||
user_dir = os.path.join(appdata, appname)
|
||||
|
||||
filename = "gns3_server.ini"
|
||||
if self._files is None:
|
||||
if self._files is None and not hasattr(sys, "_called_from_test"):
|
||||
self._files = [os.path.join(os.getcwd(), filename),
|
||||
os.path.join(user_dir, filename),
|
||||
os.path.join(appdata, appname + ".ini"),
|
||||
@ -93,7 +95,7 @@ class Config:
|
||||
else:
|
||||
user_dir = os.path.join(home, ".config", appname)
|
||||
|
||||
if self._files is None:
|
||||
if self._files is None and not hasattr(sys, "_called_from_test"):
|
||||
self._files = [os.path.join(os.getcwd(), filename),
|
||||
os.path.join(user_dir, filename),
|
||||
os.path.join(home, ".config", appname + ".conf"),
|
||||
@ -103,6 +105,14 @@ class Config:
|
||||
|
||||
if self._files is None:
|
||||
self._files = []
|
||||
|
||||
if self._main_config_file is None:
|
||||
self._main_config_file = os.path.join(user_dir, filename)
|
||||
for file in self._files:
|
||||
if os.path.exists(file):
|
||||
self._main_config_file = file
|
||||
break
|
||||
|
||||
self.clear()
|
||||
self._watch_config_file()
|
||||
|
||||
@ -113,6 +123,10 @@ class Config:
|
||||
"""
|
||||
return self._profile
|
||||
|
||||
@property
|
||||
def config_dir(self):
|
||||
return os.path.dirname(self._main_config_file)
|
||||
|
||||
def clear(self):
|
||||
"""Restart with a clean config"""
|
||||
self._config = configparser.RawConfigParser()
|
||||
|
@ -48,16 +48,7 @@ class Controller:
|
||||
# Store settings shared by the different GUI will be replace by dedicated API later
|
||||
self._settings = {}
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
config_path = os.path.join(os.path.expandvars("%APPDATA%"), "GNS3")
|
||||
else:
|
||||
config_path = os.path.join(os.path.expanduser("~"), ".config", "GNS3")
|
||||
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
|
||||
if Config.instance().profile:
|
||||
config_path = os.path.join(config_path, "profiles", Config.instance().profile)
|
||||
self._config_file = os.path.join(config_path, "gns3_controller.conf")
|
||||
self._config_file = os.path.join(Config.instance().config_dir, "gns3_controller.conf")
|
||||
log.info("Load controller configuration file {}".format(self._config_file))
|
||||
|
||||
@asyncio.coroutine
|
||||
|
Loading…
Reference in New Issue
Block a user