diff options
author | Laurie Clark-Michalek <lclarkmichalek@gmail.com> | 2013-05-10 08:44:45 -0700 |
---|---|---|
committer | Laurie Clark-Michalek <lclarkmichalek@gmail.com> | 2013-05-10 08:44:45 -0700 |
commit | b4cc4bb04e5d3f6f72b28800932affba474a07b7 (patch) | |
tree | fe3a51cbe30fc58e97a2f274169531619203a360 | |
parent | 2d5e0a2105b10ccde75fd23b3db72ff15d997d5f (diff) | |
parent | 712599851ef4d51e8b97e62488edca6ebda52ad7 (diff) |
Merge pull request #12 from mikeframpo/master
Time since last system upgrade feature.
-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): |