mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-20 15:52:16 +03:00
Add strftime config option
This commit is contained in:
parent
627ef431f9
commit
54e8e7b8dc
@ -107,7 +107,7 @@ class Config(object):
|
||||
# Re patern for optimize research of `foo`
|
||||
self.re_pattern = re.compile(r'(\`.+?\`)')
|
||||
|
||||
self.parser = ConfigParser()
|
||||
self.parser = ConfigParser(interpolation=None)
|
||||
self.read()
|
||||
|
||||
def config_file_paths(self):
|
||||
@ -224,6 +224,11 @@ class Config(object):
|
||||
self.set_default_cwc('processlist', 'cpu')
|
||||
self.set_default_cwc('processlist', 'mem')
|
||||
|
||||
# Now
|
||||
if not self.parser.has_section('strftime'):
|
||||
self.parser.add_section('strftime')
|
||||
self.set_default('strftime', 'format', '')
|
||||
|
||||
@property
|
||||
def loaded_config_file(self):
|
||||
"""Return the loaded configuration file."""
|
||||
|
@ -41,6 +41,10 @@ class Plugin(GlancesPlugin):
|
||||
# Set the message position
|
||||
self.align = 'bottom'
|
||||
|
||||
if config is not None:
|
||||
if 'strftime' in config.as_dict():
|
||||
self.strftime = config.as_dict()['strftime']['format']
|
||||
|
||||
def reset(self):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = ''
|
||||
@ -49,10 +53,14 @@ class Plugin(GlancesPlugin):
|
||||
"""Update current date/time."""
|
||||
# Had to convert it to string because datetime is not JSON serializable
|
||||
# Add the time zone (issue #1249 / #1337 / #1598)
|
||||
if (len(tzname[1]) > 6):
|
||||
self.stats = strftime('%Y-%m-%d %H:%M:%S %z')
|
||||
|
||||
if self.strftime:
|
||||
self.stats = strftime(self.strftime)
|
||||
else:
|
||||
self.stats = strftime('%Y-%m-%d %H:%M:%S %Z')
|
||||
if (len(tzname[1]) > 6):
|
||||
self.stats = strftime('%Y-%m-%d %H:%M:%S %z')
|
||||
else:
|
||||
self.stats = strftime('%Y-%m-%d %H:%M:%S %Z')
|
||||
|
||||
return self.stats
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user