diff options
author | Mike Frampton <michael.frampton@pg.canterbury.ac.nz> | 2013-05-09 23:26:30 +1200 |
---|---|---|
committer | Mike Frampton <michael.frampton@pg.canterbury.ac.nz> | 2013-05-09 23:26:30 +1200 |
commit | 712599851ef4d51e8b97e62488edca6ebda52ad7 (patch) | |
tree | fe3a51cbe30fc58e97a2f274169531619203a360 /archey3 | |
parent | 2d5e0a2105b10ccde75fd23b3db72ff15d997d5f (diff) |
Added an extra output. Can now print the time since the last full
system upgrade.
Diffstat (limited to 'archey3')
-rwxr-xr-x | archey3 | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -18,6 +18,7 @@ from optparse import OptionParser from getpass import getuser from time import ctime, sleep from os import getenv +from datetime import datetime import re import os.path import multiprocessing @@ -509,6 +510,34 @@ class mpdDisplay(display): return ('{statname} in MPD database'.format(statname=self.stat.title()), stats[self.stat]) +@module_register("system_upgrade") +class systemUpgrade(display): + + _upgrade_message = 'starting full system upgrade' + + def render(self): + try: + datestr = None + for line in reversed(list(open('/var/log/pacman.log'))): + if line.rstrip().endswith(self._upgrade_message): + datestart = line.find('[') + dateend = line.find(']') + if datestart != -1 and dateend != -1: + datestr = line[datestart + 1 : dateend] + break + except Exception as err: + print(err) + + if not datestr: + datestr = 'Unknown' + else: + currenttime = datetime.today() + updatetime = datetime.strptime(datestr, '%Y-%m-%d %H:%M') + numdays = (currenttime - updatetime).days + datestr = '{0} ({1} days ago)'.format(datestr, numdays) + + return "Last Upgrade", datestr + #------------ Config ----------- class ArcheyConfigParser(configparser.SafeConfigParser): |