mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-27 03:04:16 +03:00
Fix local path handling to reflect new source layout
This commit is contained in:
parent
bd78f25f12
commit
c5c58f69b7
@ -50,7 +50,6 @@ class Config:
|
|||||||
self.parser = RawConfigParser()
|
self.parser = RawConfigParser()
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
"""
|
"""
|
||||||
Load a config file from the list of paths, if it exists
|
Load a config file from the list of paths, if it exists
|
||||||
@ -69,14 +68,12 @@ class Config:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def get_config_path(self):
|
def get_config_path(self):
|
||||||
"""
|
"""
|
||||||
Return the readed configuration file path
|
Return the readed configuration file path
|
||||||
"""
|
"""
|
||||||
return self.config_path
|
return self.config_path
|
||||||
|
|
||||||
|
|
||||||
def get_paths_list(self):
|
def get_paths_list(self):
|
||||||
"""
|
"""
|
||||||
Get a list of config file paths, taking into account of the OS,
|
Get a list of config file paths, taking into account of the OS,
|
||||||
@ -95,7 +92,7 @@ class Config:
|
|||||||
* {/usr/local,}/etc directory (system-wide settings)
|
* {/usr/local,}/etc directory (system-wide settings)
|
||||||
"""
|
"""
|
||||||
paths = []
|
paths = []
|
||||||
conf_path = os.path.realpath(os.path.join(work_path, '..', 'conf'))
|
conf_path = os.path.realpath(os.path.join(work_path, '..', '..', 'conf'))
|
||||||
|
|
||||||
if self.location is not None:
|
if self.location is not None:
|
||||||
paths.append(self.location)
|
paths.append(self.location)
|
||||||
@ -126,21 +123,18 @@ class Config:
|
|||||||
|
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
|
|
||||||
def items(self, section):
|
def items(self, section):
|
||||||
"""
|
"""
|
||||||
Return the items list of a section
|
Return the items list of a section
|
||||||
"""
|
"""
|
||||||
return self.parser.items(section)
|
return self.parser.items(section)
|
||||||
|
|
||||||
|
|
||||||
def has_section(self, section):
|
def has_section(self, section):
|
||||||
"""
|
"""
|
||||||
Return info about the existence of a section
|
Return info about the existence of a section
|
||||||
"""
|
"""
|
||||||
return self.parser.has_section(section)
|
return self.parser.has_section(section)
|
||||||
|
|
||||||
|
|
||||||
def get_option(self, section, option):
|
def get_option(self, section, option):
|
||||||
"""
|
"""
|
||||||
Get the float value of an option, if it exists
|
Get the float value of an option, if it exists
|
||||||
@ -152,7 +146,6 @@ class Config:
|
|||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def get_raw_option(self, section, option):
|
def get_raw_option(self, section, option):
|
||||||
"""
|
"""
|
||||||
Get the raw value of an option, if it exists
|
Get the raw value of an option, if it exists
|
||||||
|
@ -47,7 +47,7 @@ psutil_version = tuple([int(num) for num in __psutil_version__.split('.')])
|
|||||||
if psutil_version < (0, 5, 0):
|
if psutil_version < (0, 5, 0):
|
||||||
print('PsUtil version %s detected.' % '.'.join(psutil_version))
|
print('PsUtil version %s detected.' % '.'.join(psutil_version))
|
||||||
print('PsUtil 0.5.1 or higher is needed. Glances cannot start.')
|
print('PsUtil 0.5.1 or higher is needed. Glances cannot start.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Path definitions
|
# Path definitions
|
||||||
work_path = os.path.realpath(os.path.dirname(__file__))
|
work_path = os.path.realpath(os.path.dirname(__file__))
|
||||||
@ -65,7 +65,7 @@ is_Windows = sys.platform.startswith('win')
|
|||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
gettext_domain = 'glances'
|
gettext_domain = 'glances'
|
||||||
# get locale directory
|
# get locale directory
|
||||||
i18n_path = os.path.realpath(os.path.join(work_path, '..', 'i18n'))
|
i18n_path = os.path.realpath(os.path.join(work_path, '..', '..', 'i18n'))
|
||||||
sys_i18n_path = os.path.join(sys_prefix, 'share', 'locale')
|
sys_i18n_path = os.path.join(sys_prefix, 'share', 'locale')
|
||||||
if os.path.exists(i18n_path):
|
if os.path.exists(i18n_path):
|
||||||
locale_dir = i18n_path
|
locale_dir = i18n_path
|
||||||
|
Loading…
Reference in New Issue
Block a user