From 3710b2978b344e7d98ba602e45580256e4cef58a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 6 Dec 2012 12:45:19 -0500 Subject: [PATCH] emerge-lastsync.py: convert lastsync.pl to Python I don't always have Perl installed. --- posts/conky/emerge-lastsync.py | 15 +++++++++++++++ posts/conky/lastsync.pl | 7 ------- 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100755 posts/conky/emerge-lastsync.py delete mode 100755 posts/conky/lastsync.pl diff --git a/posts/conky/emerge-lastsync.py b/posts/conky/emerge-lastsync.py new file mode 100755 index 0000000..577977b --- /dev/null +++ b/posts/conky/emerge-lastsync.py @@ -0,0 +1,15 @@ +#!/usr/bin/python +# +# Based on +# http://conky.sourceforge.net/lastsync.pl + +import time + +syncs = [] +for line in file('/var/log/emerge.log', 'r'): + if not 'Sync completed' in line: + continue + sync_time = int(line[:10]) + syncs.append(sync_time) + +print(time.strftime('%a, %b %e', time.localtime(syncs[-1]))) diff --git a/posts/conky/lastsync.pl b/posts/conky/lastsync.pl deleted file mode 100755 index 37bef03..0000000 --- a/posts/conky/lastsync.pl +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/perl -use Date::Manip; - -$date = `grep "Sync completed" /var/log/emerge.log | tail -n1 | cut -c-10`; -$date = &DateCalc("Jan 1, 1970 00:00:00 GMT",$date); -$date = UnixDate("$date","%A %H:%M"); -print "$date"; -- 2.26.2