From 470bef5f05826e4c005994e586b8989ece490b0b Mon Sep 17 00:00:00 2001 From: "Michael F. Lamb" Date: Tue, 20 Oct 2015 02:37:37 -0400 Subject: [PATCH] +replace manual diff with call out to diff(1) --- tildetown/stats.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tildetown/stats.py b/tildetown/stats.py index 7176f8f..d8a8ec6 100644 --- a/tildetown/stats.py +++ b/tildetown/stats.py @@ -5,6 +5,7 @@ from os.path import getmtime, join from datetime import datetime from sh import find, uptime, who, sort, wc, cut from tildetown.util import slurp, thread, p +import subprocess # this script emits json on standard out that has information about tilde.town # users. It denotes who has not updated their page from the default. It also @@ -12,12 +13,14 @@ from tildetown.util import slurp, thread, p SYSTEM_USERS = ['wiki', 'root', 'ubuntu', 'nate'] -DEFAULT_HTML = slurp("/etc/skel/public_html/index.html") +DEFAULT_HTML_FILENAME = "/etc/skel/public_html/index.html" username_to_html_path = lambda u: "/home/{}/public_html".format(u) def default_p(username): - return DEFAULT_HTML == slurp(join(username_to_html_path(username), "index.html")) + return subprocess.call( + ['diff', '-q', DEFAULT_HTML_FILENAME, user_html_filename], + stdout=subprocess.DEVNULL) == 0 def bounded_find(path): # find might return 1 but still have worked fine.