summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessio Sergi <al3hex@gmail.com>2013-04-03 15:41:00 +0200
committerAlessio Sergi <al3hex@gmail.com>2013-04-03 15:41:00 +0200
commit0e52348aed40be806631dffc0fd9921453b8b0b1 (patch)
tree062acbd55f09c3cb5ef5835c521af8aeefa7e198
parent88c1cc8f7868f59f6e95419379865854e400afb9 (diff)
Add support for local conf file
-rw-r--r--README2
-rw-r--r--README.md2
-rw-r--r--glances/glances.py7
3 files changed, 9 insertions, 2 deletions
diff --git a/README b/README
index 7b3474b9..c3fbac49 100644
--- a/README
+++ b/README
@@ -119,7 +119,7 @@ The default configuration file is under:
/etc/glances/glances.conf (Linux)
or
- /usr/local/etc/glances.conf (*BSD and OS X)
+ /usr/local/etc/glances/glances.conf (*BSD and OS X)
To override the default configuration, you can copy the `glances.conf` file to
your `$XDG_CONFIG_HOME` directory (e.g. Linux):
diff --git a/README.md b/README.md
index 7b3474b9..c3fbac49 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,7 @@ The default configuration file is under:
/etc/glances/glances.conf (Linux)
or
- /usr/local/etc/glances.conf (*BSD and OS X)
+ /usr/local/etc/glances/glances.conf (*BSD and OS X)
To override the default configuration, you can copy the `glances.conf` file to
your `$XDG_CONFIG_HOME` directory (e.g. Linux):
diff --git a/glances/glances.py b/glances/glances.py
index 25d99ee7..0a7439c0 100644
--- a/glances/glances.py
+++ b/glances/glances.py
@@ -197,20 +197,27 @@ class Config:
Get a list of config file paths, taking into account of the OS,
priority and location.
+ * running from source: /path/to/glances/glances/conf
* Linux: ~/.config/glances, /etc/glances
* BSD: ~/.config/glances, /usr/local/etc/glances
* Mac: ~/Library/Application Support/glances, /usr/local/etc/glances
The config file will be searched in the following order of priority:
* /path/to/file (via -C flag)
+ * /path/to/glances/glances/conf
* user's home directory (per-user settings)
* /etc directory (system-wide settings)
"""
+ base_path = os.path.dirname(os.path.abspath(__file__))
+ local_path = os.path.join(base_path, 'conf', self.filename)
paths = []
if self.location is not None:
paths.append(self.location)
+ if os.path.exists(local_path):
+ paths.append(local_path)
+
if is_Linux or is_BSD:
paths.append(os.path.join(
os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'),