mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-07 18:51:34 +03:00
Merge pull request #239 from asergi/master
Add support for local conf file
This commit is contained in:
commit
b36ade0dd7
2
README
2
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):
|
||||
|
@ -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):
|
||||
|
0
glances/conf/glances.conf
Executable file → Normal file
0
glances/conf/glances.conf
Executable file → Normal file
7
glances/glances.py
Executable file → Normal file
7
glances/glances.py
Executable file → Normal file
@ -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'),
|
||||
|
0
glances/tests/test_glances.py
Executable file → Normal file
0
glances/tests/test_glances.py
Executable file → Normal file
Loading…
Reference in New Issue
Block a user