提交 54e8e7b8 编写于 作者: M meganomic

Add strftime config option

上级 627ef431
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册