From: W. Trevor King Date: Thu, 6 Dec 2012 17:45:19 +0000 (-0500) Subject: emerge-lastsync.py: convert lastsync.pl to Python X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3710b2978b344e7d98ba602e45580256e4cef58a;p=blog.git emerge-lastsync.py: convert lastsync.pl to Python I don't always have Perl installed. --- 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";