From 712599851ef4d51e8b97e62488edca6ebda52ad7 Mon Sep 17 00:00:00 2001 From: Mike Frampton Date: Thu, 9 May 2013 23:26:30 +1200 Subject: Added an extra output. Can now print the time since the last full system upgrade. --- archey3 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/archey3 b/archey3 index 3fe7436..536fb66 100755 --- a/archey3 +++ b/archey3 @@ -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): -- cgit v1.2.3-54-g00ecf