summaryrefslogtreecommitdiff
path: root/archey3
diff options
context:
space:
mode:
authorLaurie Clark-Michalek <lclarkmichalek@gmail.com>2013-05-10 08:44:45 -0700
committerLaurie Clark-Michalek <lclarkmichalek@gmail.com>2013-05-10 08:44:45 -0700
commitb4cc4bb04e5d3f6f72b28800932affba474a07b7 (patch)
treefe3a51cbe30fc58e97a2f274169531619203a360 /archey3
parent2d5e0a2105b10ccde75fd23b3db72ff15d997d5f (diff)
parent712599851ef4d51e8b97e62488edca6ebda52ad7 (diff)
Merge pull request #12 from mikeframpo/master
Time since last system upgrade feature.
Diffstat (limited to 'archey3')
-rwxr-xr-xarchey329
1 files changed, 29 insertions, 0 deletions
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):